5#include "../Tree/Tree.h"
15std::vector<size_t> NeighborJoining::getBestPair()
28 vector<size_t> bestPair(2);
33 map<size_t, Node*>::iterator j = i;
51 throw Exception(
"Unexpected error: no maximum criterium found.");
62 d[0] = std::max(.5 * (
matrix_(pair[0], pair[1]) + ratio), 0.);
63 d[1] = std::max(.5 * (
matrix_(pair[0], pair[1]) - ratio), 0.);
67 d[0] = .5 * (
matrix_(pair[0], pair[1]) + ratio);
68 d[1] = .5 * (
matrix_(pair[0], pair[1]) - ratio);
77 std::max(.5 * (
matrix_(pair[0], pos) - branchLengths[0] +
matrix_(pair[1], pos) - branchLengths[1]), 0.)
78 : .5 * (
matrix_(pair[0], pos) - branchLengths[0] +
matrix_(pair[1], pos) - branchLengths[1]);
85 size_t i1 = it->first;
86 Node* n1 = it->second;
88 size_t i2 = it->first;
89 Node* n2 = it->second;
103 size_t i3 = it->first;
104 Node* n3 = it->second;
std::unique_ptr< Tree > tree_
std::map< size_t, Node * > currentNodes_
double computeDistancesFromPair(const std::vector< size_t > &pair, const std::vector< double > &branchLengths, size_t pos)
Actualizes the distance matrix according to a given pair and the corresponding branch lengths.
std::vector< double > sumDist_
void finalStep(int idRoot)
Method called when there ar eonly three remaining node to agglomerate, and creates the root node of t...
std::vector< double > computeBranchLengthsForPair(const std::vector< size_t > &pair)
Compute the branch lengths for two nodes to agglomerate.
The phylogenetic node class.
virtual void setDistanceToFather(double distance)
Set or update the distance toward the father node.
virtual void addSon(size_t pos, Node *node)
The phylogenetic tree class.
Defines the basic types of data flow nodes.