Skip to main content
`Ctrl`+`K`

# skbio.tree.TreeNode.distance

TreeNode.distance(other)

  Return the distance between self and other.

  This method can be used to compute the distances between two tips, however, it is not optimized for computing pairwise tip distances.

  Parameters:
    other TreeNode

      The node to compute a distance to

  Returns:
    float

      The distance between two nodes

  Raises:
    NoLengthError

      A NoLengthError will be raised if a node without length is encountered

  See also

  `tip_tip_distances`
  `accumulate_to_ancestor`
  `compare_tip_distances`
  `get_max_distance`

  Examples

      >>> from skbio import TreeNode
      >>> tree = TreeNode.read(["((a:1,b:2)c:3,(d:4,e:5)f:6)root;"])
      >>> tip_a = tree.find('a')
      >>> tip_d = tree.find('d')
      >>> tip_a.distance(tip_d)
      14.0