7 #include "rabundvector.hpp"
8 #include "sparsematrix.hpp"
10 /* This class implements the average UPGMA, average neighbor clustering algorithm */
12 /***********************************************************************/
14 AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) :
18 /***********************************************************************/
19 //THis function clusters based on the average method
20 void AverageLinkage::update(){
24 vector<int> found(nColCells, 0);
26 int rowBin = rabund->get(smallRow);
27 int colBin = rabund->get(smallCol);
28 int totalBin = rowBin + colBin;
30 for(int i=1;i<nRowCells;i++){
34 if(rowCells[i]->row == smallRow){
35 search = rowCells[i]->column;
38 search = rowCells[i]->row;
41 for(int j=1;j<nColCells;j++){
43 if(colCells[j]->row == search || colCells[j]->column == search){
44 colCells[j]->dist = (colBin * colCells[j]->dist + rowBin * rowCells[i]->dist) / totalBin;
48 if(colCells[j]->vectorMap != NULL){
49 *(colCells[j]->vectorMap) = NULL;
50 colCells[j]->vectorMap = NULL;
57 dMatrix->rmCell(rowCells[i]);
63 for(int i=0;i<nColCells;i++){
65 dMatrix->rmCell(colCells[i]);
70 cout << "Standard Error: " << e.what() << " has occurred in the AverageLinkage class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
74 cout << "An unknown error has occurred in the AverageLinkage class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
81 /***********************************************************************/