tree <- PectinateTree(5)
edge <- tree[["edge"]]
# Identify desired node with:
plot(tree)
nodelabels()
tiplabels()
# Ancestors of specific nodes:
ListAncestors(edge[, 1], edge[, 2], 4L)
ListAncestors(edge[, 1], edge[, 2], 8L)
# Ancestors of each node, if tree numbering system is uncertain:
lapply(seq_len(max(edge)), ListAncestors,
parent = edge[, 1], child = edge[, 2])
# Ancestors of each node, if tree is in preorder:
ListAncestors(edge[, 1], edge[, 2])
# Alias:
AllAncestors(edge[, 1], edge[, 2])
Run the code above in your browser using DataLab