skbio.core.tree.TreeNode.lowest_common_ancestor

TreeNode.lowest_common_ancestor(tipnames)[source]

Lowest common ancestor for a list of tips

Parameters:

tipnames : list of TreeNode or str

The nodes of interest

Returns:

TreeNode

The lowest common ancestor of the passed in nodes

Raises:

ValueError

If no tips could be found in the tree

Examples

>>> from skbio.core.tree import TreeNode
>>> tree = TreeNode.from_newick("((a,b)c,(d,e)f)root;")
>>> nodes = [tree.find('a'), tree.find('b')]
>>> lca = tree.lowest_common_ancestor(nodes)
>>> print lca.name
c
>>> nodes = [tree.find('a'), tree.find('e')]
>>> lca = tree.lca(nodes)  # lca is an alias for convience
>>> print lca.name
root