A matrix (table) of ancestors/descendants for each node in a tree

PCMTreeTableAncestors(tree, preorder = PCMTreePreorder(tree))

Arguments

tree

a phylo object

preorder

an integer vector returned by a previous call to PCMTreePreorder(tree). Default PCMTreePreorder(tree).

Value

an integer square matrix of size M x M where M is the number of nodes in the tree. Element j on row i is 0 if j is not an ancestor of i or a positive integer equal to the position of j on the path from the root to i if j is an ancestor of i.

Details

This function has time and memory complexity O(M^2), where M is the number of nodes in the tree. It can take several minutes and gigabytes of memory on trees of more than 10000 tips.