From 31a07c14e22c97d6e3c66140979beb652cf1e69a Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Tue, 24 Sep 2024 17:19:38 +0100 Subject: [PATCH] Clarity that path_length is a count, and that distance_between gives distance --- python/tskit/trees.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/tskit/trees.py b/python/tskit/trees.py index 5c4120301a..c10f086db8 100644 --- a/python/tskit/trees.py +++ b/python/tskit/trees.py @@ -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.