Fork me on GitHub"

# skbio.tree.TreeNode.lowest_common_ancestor

TreeNode.lowest_common_ancestor(tipnames)

  Lowest common ancestor for a list of tips

  State: Experimental as of 0.4.0.

  Parameters:

    tipnames (list of TreeNode or str) – The nodes of interest

  Returns:

    The lowest common ancestor of the passed in nodes

  Return type:

    TreeNode

  Raises:

    ValueError – If no tips could be found in the tree, or if not all tips were found.

  Examples

      >>> from skbio import TreeNode
      >>> tree = TreeNode.read(["((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