@@ -824,9 +824,16 @@ def get_distance_fn(topological, asserted=True):
824
824
def robinson_foulds (t1 , t2 , prop = ' name' , normalized = False , strict = False ):
825
825
""" Return the Robinson-Foulds distance between trees t1 and t2.
826
826
827
- The distance is A + B, where
828
- A: number of partitions implied by the 1st tree but not the 2nd
829
- B: number of partitions implied by the 2nd tree but not the 1st
827
+ The distance is A + B, where:
828
+
829
+ - A: number of partitions implied by t1 but not t2
830
+ - B: number of partitions implied by t2 but not t1
831
+
832
+ Every node implies a partition (the leaves that it has at each side).
833
+
834
+ :param prop: Property of the leaves used to identify them in partitions.
835
+ :param normalized: If True, divide by the maximum possible distance.
836
+ :param strict: If True, check that t1 and t2 have unique and same leaves.
830
837
"""
831
838
common_vals = get_common_values(t1, t2, prop, strict)
832
839
@@ -850,8 +857,8 @@ def get_common_values(t1, t2, prop='name', strict=False):
850
857
851
858
If strict, raise AssertionError if t1 and t2 don't share leaves.
852
859
"""
853
- vals1 = set (leaf.props.get(prop) for leaf in t1) # can be names
854
- vals2 = set (leaf.props.get(prop) for leaf in t2)
860
+ vals1 = set (leaf.props.get(prop) for leaf in t1.leaves() ) # can be names
861
+ vals2 = set (leaf.props.get(prop) for leaf in t2.leaves() )
855
862
common_vals = vals1 & vals2 # common leaf values of property prop
856
863
857
864
assert not strict or (
0 commit comments