Learn R Programming

TreeSearch (version 0.2.2)

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

This function 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 will therefore be the root node, with the exception of the entry for the root node itself, which will be 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]

Examples

Run this code
# NOT RUN {
tr <- ape::rtree(20, br=NULL)
edge <- tr$edge
AllAncestors(edge[, 1], edge[, 2])

# }

Run the code above in your browser using DataLab