3 \title{Internal Reordering of Trees}
5 This function changes the internal structure of a phylogeny stored as
6 an object of class \code{"phylo"}. The tree returned is the same than
7 the one input, but the ordering of the edges could be different.
10 \method{reorder}{phylo}(x, order = "cladewise", index.only = FALSE, ...)
13 \item{x}{an object of class \code{"phylo"}.}
14 \item{order}{a character string: either \code{"cladewise"} (the
15 default), \code{"postorder"}, \code{"pruningwise"}, or any
16 unambiguous abbreviation of these.}
17 \item{index.only}{should the function return only the ordered indices
18 of the rows of the edge matrix?}
19 \item{\dots}{further arguments passed to or from other methods.}
22 Because in a tree coded as an object of class \code{"phylo"} each
23 branch is represented by a row in the element `edge', there is an
24 arbitrary choice for the ordering of these rows. \code{reorder} allows
25 to reorder these rows according to three rules: in the
26 \code{"cladewise"} order each clade is formed by a series of
27 contiguous rows. In the \code{"postorder"} order, the rows are
28 arranged so that computations following pruning-like algorithm the
29 tree (or postorder tree traversal) can be done by descending along
30 these rows (conversely, a preorder tree traversal can be performed by
31 moving from the last to the first row). The \code{"pruningwise"} order
32 is an alternative ``pruning'' order which is actually a bottom-up
33 traversal order (Valiente 2002). (This third choice might be removed
34 in the future as it merely duplicates the second one which is more
35 efficient.) The possible multichotomies and branch lengths are preserved.
37 Note that for a given order, there are several possible orderings of
41 an object of class \code{"phylo"} (with the attribute \code{"order"}
42 set accordingly), or a numeric vector if \code{index.only = TRUE}.
45 Valiente, G. (2002) \emph{Algorithms on Trees and Graphs.} New York:
48 \author{Emmanuel Paradis}
50 \code{\link{read.tree}} to read tree files in Newick format,
51 \code{\link[stats]{reorder}} for the generic function
55 tr <- reorder(bird.families, "postorder")
56 all.equal(bird.families, tr) # uses all.equal.phylo actually
57 all.equal.list(bird.families, tr) # bypasses the generic