lczech / genesis

A library for working with phylogenetic and population genetic data.
http://genesis-lib.org/
GNU General Public License v3.0
57 stars 12 forks source link

Kuhner-Felsenstein distance metric #3

Open pierrebarbera opened 8 years ago

pierrebarbera commented 8 years ago

Related to #1, there could be a function for calculating the Kuhner-Felsenstein distance between two trees, as described in Kuhner and Felsenstein, 94, Equation (1).

auto distance = 0.0;
for(auto bipartition : bipartition_map_a) {
  auto other = find(bipartition_map_b, bipartition);
  auto other_length = other ? other.edge_length : 0.0;
  distance += pow(bipartition.edge_length - other_length, 2);
}

Maybe this could be written in such a way that the actual distance can be easily exchanged? As in, the body of the for sans the find could be passed as a functional.