5 #include "rabundvector.hpp"
6 #include "sparsematrix.hpp"
9 /* This class implements the average UPGMA, average neighbor clustering algorithm */
11 /***********************************************************************/
13 AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) :
17 /***********************************************************************/
18 //THis function clusters based on the average method
19 void AverageLinkage::update(){
23 vector<int> found(nColCells, 0);
25 int rowBin = rabund->get(smallRow);
26 int colBin = rabund->get(smallCol);
27 int totalBin = rowBin + colBin;
29 for(int i=1;i<nRowCells;i++){
33 if(rowCells[i]->row == smallRow){
34 search = rowCells[i]->column;
37 search = rowCells[i]->row;
40 for(int j=1;j<nColCells;j++){
42 if(colCells[j]->row == search || colCells[j]->column == search){
43 colCells[j]->dist = (colBin * colCells[j]->dist + rowBin * rowCells[i]->dist) / totalBin;
47 if(colCells[j]->vectorMap != NULL){
48 *(colCells[j]->vectorMap) = NULL;
49 colCells[j]->vectorMap = NULL;
56 dMatrix->rmCell(rowCells[i]);
62 for(int i=0;i<nColCells;i++){
64 dMatrix->rmCell(colCells[i]);
69 cout << "Standard Error: " << e.what() << " has occurred in the AverageLinkage class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
73 cout << "An unknown error has occurred in the AverageLinkage class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
80 /***********************************************************************/