Raw File
\title{Reorders object order of hclust, keeping objects within a cluster
contiguous to each other. }
Reorders objects so that  nearby object pairs are adjacent.
%- maybe also 'usage' for other objects documented here.
  \item{hc}{is the result of \code{hclust}.}
  \item{dis}{is a distance matrix or \code{dist}.}  
In hierarchical cluster displays, a decision is needed at 
each merge to specify which subtree should go on the left 
and which on the right. 
This algorithm uses the order suggested by Gruvaeus and Wainer (1972).
At a merge of clusters A and B, the new cluster is one of
(A,B), (A',B), (A,B'),(A',B'), where A' denotes A in reverse order.
The new cluster is chosen to minimize the distance between
the object in A placed adjacent to an object from B.
\value{A permutation of the objects represented by \code{dis} is returned.
\references{Hurley, Catherine B.  ``Clustering Visualisations of Multidimensional 
Data'', to appear in JCGS.

Gruvaeus, G. and Wainer, H. (1972),
``Two Additions to Hierarchical Cluster Analysis",
 British Journal of Mathematical and Statistical Psychology, 25, 200-206.
\author{ Catherine B. Hurley }
%\note{ ~~further notes~~ }
\code{\link{order.hclust}} .}

dis <- as.dist(eurodist)
hc <- hclust(dis, "ave")

op <- par(mar=c(1,1,1,1))
hc1 <- reorder.hclust(hc, dis)

# Both dedrograms correspond to the same tree structure,
# but the second one shows that
# Paris is closer to Cherbourg than Munich, and
# Rome is closer to Gibralter than to Barcelona.

# We can also compare both orderings with an
# image plot of the colors.
# The second ordering seems to place nearby cities
# closer to each other.

op <- par(mar=c(1,6,1,1))
cmat <- dmat.color(eurodist, rev(cm.colors(5)))
plot.colors(cmat[hc$order,hc$order], rlabels=labels(eurodist)[hc$order])

plot.colors(cmat[hc1$order,hc1$order], rlabels=labels(eurodist)[hc1$order])



\keyword{multivariate }
\keyword{cluster }
back to top