Debian Codegraph @

src/dr/evolution/tree/treemetrics/RobinsonFouldsMetric.java

raw symbols SCIP
1 package dr.evolution.tree.treemetrics;
2
3 import dr.evolution.tree.Clade;
4 import dr.evolution.tree.Tree;
5
6 import java.util.*;
7
8 import static dr.evolution.tree.treemetrics.TreeMetric.Utils.checkTreeTaxa;
9
10 /**
11 * @author Andrew Rambaut
12 * @version $Id$
13 */
14 public class RobinsonFouldsMetric implements TreeMetric {
15 public static Type TYPE = Type.ROBINSON_FOULDS;
16
17 public RobinsonFouldsMetric() {
18
19 }
20
21 @Override
22 public double getMetric(Tree tree1, Tree tree2) {
23
24 checkTreeTaxa(tree1, tree2);
25
26 Set<Clade> clades1 = Clade.getCladeSet(tree1);
27 Set<Clade> clades2 = Clade.getCladeSet(tree2);
28
29 clades1.removeAll(clades2);
30
31 // Technically RF would be twice this because it doesn't assume
32 // the same set of tips in both trees (so may have a different
33 // number of clades missing from each).
34 return clades1.size();
35 }
36
37 @Override
38 public Type getType() {
39 return TYPE;
40 }
41
42 @Override
43 public String toString() {
44 return getType().getShortName();
45 }
46
47 // todo - add in Citable:
48 // Robinson, D. R.; Foulds, L. R. (1981). "Comparison of phylogenetic trees". Mathematical Biosciences. 53: 131-147. doi:10.1016/0025-5564(81)90043-2.
49 }