TreeTools (version 0.1.3)

AllAncestors: List all ancestral nodes

Description

AllAncestors lists ancestors of each parent node in a tree.

Usage

AllAncestors(parent, child)

Arguments

parent

the first column of the edge matrix of a tree of class phylo, i.e. tree$edge[, 1].

child

the second column of the edge matrix of a tree of class phylo, i.e. tree$edge[, 2].

Value

AllAncestors returns a list. Entry i contains a vector containing, in order, the nodes encountered when traversing the tree from node i to the root node. The last entry of each member of the list is therefore the root node, with the exception of the entry for the root node itself, which is NULL.

Details

Note that the tree's edges must be listed in an order whereby each entry in tr$edge[, 1] (with the exception of the root) has appeared already in tr$edge[, 2].

See Also

Other tree navigation: AncestorEdge, DescendantEdges, EdgeAncestry, EdgeDistances, MRCA, NonDuplicateRoot

Examples

Run this code
# NOT RUN {
  tr <- PectinateTree(4)
  plot(tr)
  ape::tiplabels()
  ape::nodelabels()
  edge <- tr$edge
  AllAncestors(edge[, 1], edge[, 2])

# }

Run the code above in your browser using DataCamp Workspace