7#include "../Tree/Node.h"
17void AbstractAgglomerativeDistanceMethod::setDistanceMatrix(
const DistanceMatrix& matrix)
19 if (matrix.
size() <= 3)
20 throw Exception(
"AbstractAgglomerativeDistanceMethod::setDistanceMatrix(): matrix must be at least of dimension 3.");
53 if (
id != bestPair[0] &&
id != bestPair[1])
55 assert (
id < newDist.size());
77 return new Node(
id, name);
virtual Node * getLeafNode(int id, const std::string &name)
Get a leaf node.
virtual double computeDistancesFromPair(const std::vector< size_t > &pair, const std::vector< double > &branchLengths, size_t pos)=0
Actualizes the distance matrix according to a given pair and the corresponding branch lengths.
virtual std::vector< size_t > getBestPair()=0
Get the best pair of nodes to agglomerate.
virtual Node * getParentNode(int id, Node *son1, Node *son2)
Get an inner node.
virtual std::vector< double > computeBranchLengthsForPair(const std::vector< size_t > &pair)=0
Compute the branch lengths for two nodes to agglomerate.
std::unique_ptr< Tree > tree_
virtual void finalStep(int idRoot)=0
Method called when there ar eonly three remaining node to agglomerate, and creates the root node of t...
std::map< size_t, Node * > currentNodes_
void computeTree() override
Compute the tree corresponding to the distance matrix.
const std::string & getName(std::size_t i) const
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)
Defines the basic types of data flow nodes.