7 #include "rabundvector.hpp"
8 #include "sparsedistancematrix.h"
10 /* This class implements the average UPGMA, average neighbor clustering algorithm */
12 /***********************************************************************/
14 AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseDistanceMatrix* dm, float c, string s, float a) :
15 Cluster(rav, lv, dm, c, s, a)
22 /***********************************************************************/
23 //This function returns the tag of the method.
24 string AverageLinkage::getTag() {
29 /***********************************************************************/
30 //This function updates the distance based on the average linkage method.
31 bool AverageLinkage::updateDistance(PDistCell& colCell, PDistCell& rowCell) {
33 if ((saveRow != smallRow) || (saveCol != smallCol)) {
34 rowBin = rabund->get(smallRow);
35 colBin = rabund->get(smallCol);
36 totalBin = rowBin + colBin;
40 //cout << "colcell.dist = " << colCell.dist << '\t' << smallRow << '\t' << smallCol << '\t' << rowCell.dist << endl;
41 colCell.dist = (colBin * colCell.dist + rowBin * rowCell.dist) / totalBin;
46 m->errorOut(e, "AverageLinkage", "updateDistance");
51 /***********************************************************************/
54 /***********************************************************************/