Skip to content

Commit

Permalink
Clarity that path_length is a count, and that distance_between gives …
Browse files Browse the repository at this point in the history
…distance
  • Loading branch information
hyanwong committed Sep 24, 2024
1 parent 782b270 commit 31a07c1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -2970,13 +2970,16 @@ def rf_distance(self, other):

def path_length(self, u, v):
"""
Returns the path length between two nodes
(i.e., the number of edges between two nodes in this tree).
Returns a count of the number of edges between two nodes in this tree.
If the two nodes have a most recent common ancestor, then this is defined as
``tree.depth(u) + tree.depth(v) - 2 * tree.depth(tree.mrca(u, v))``. If the nodes
do not have an MRCA (i.e., they are in disconnected subtrees) the path length
is infinity.
.. note:: This counts the number of "hops" between two nodes. To find the branch
length distance between them, in units of time (i.e. the sum of edge lengths
that separate two nodes) use the :meth:`.distance_between` method instead.
.. seealso:: See also the :meth:`.depth` method
:param int u: The first node for path length computation.
Expand Down

0 comments on commit 31a07c1

Please sign in to comment.