get_leaf_distances#

biotite.sequence.phylo.get_leaf_distances(tree: DiGraph, topological: bool = False) → ndarray[tuple[int, int], dtype[float64]][source]#

Get the pairwise distances between all leaf nodes of a tree.

Parameters:
treeDiGraph

The tree. The leaf nodes must be the integers 0 to n-1.

topologicalbool, optional

If true, the topological distance is measured, i.e. each edge has a distance of 1. Otherwise, the "distance" attribute of the edges is used.

Returns:
distancesndarray, shape=(n,n), dtype=float

The distance between each pair of leaf nodes, indexed by the leaf node.

See also

get_distance

Distance between two arbitrary nodes.

Examples

>>> tree = from_newick("((0:5.0,1:7.0):3.0,2:10.0);")
>>> print(get_leaf_distances(tree))
[[ 0. 12. 18.]
 [12.  0. 20.]
 [18. 20.  0.]]