]> git.donarmstrong.com Git - mothur.git/blobdiff - completelinkage.cpp
fixes while testing 1.33.0
[mothur.git] / completelinkage.cpp
index 3c779b9344866cc4729e460cb3d7b6e6c68dc682..0a3c7b3e42f68347d0315299d5ed050b89ebb796 100644 (file)
@@ -1,71 +1,34 @@
 
 #include "cluster.hpp"
-#include "mothur.h"
 
 /***********************************************************************/
 
-CompleteLinkage::CompleteLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm) :
-Cluster(rav, lv, dm)
+CompleteLinkage::CompleteLinkage(RAbundVector* rav, ListVector* lv, SparseDistanceMatrix* dm, float c, string s, float a) :
+       Cluster(rav, lv, dm, c, s, a)
 {}
 
 /***********************************************************************/
-//This function clusters based on the furthest neighbor method.
-void CompleteLinkage::update(){
+//This function returns the tag of the method.
+string CompleteLinkage::getTag() {
+       return("fn");
+}
+
+
+/***********************************************************************/
+//This function updates the distance based on the furthest neighbor method.
+bool CompleteLinkage::updateDistance(PDistCell& colCell, PDistCell& rowCell) {
        try {
-               getRowColCells();       
-       
-               vector<int> found(nColCells, 0);
-       
-               for(int i=1;i<nRowCells;i++){
-               
-                       int search;
-               
-                       if(rowCells[i]->row == smallRow){
-                               search = rowCells[i]->column;
-                       }
-                       else{
-                               search = rowCells[i]->row;
-                       }
-               
-                       for(int j=1;j<nColCells;j++){
-                       
-                               if(colCells[j]->row == search || colCells[j]->column == search){
-                               
-                                       if(colCells[j]->dist < rowCells[i]->dist){
-                                               colCells[j]->dist = rowCells[i]->dist;
-                                       
-                                               if(colCells[j]->vectorMap != NULL){
-                                                       *(colCells[j]->vectorMap) = NULL;
-                                                       colCells[j]->vectorMap = NULL;
-                                               }
-                                       
-                                       }
-                               
-                                       found[j] = 1;
-                                       break;
-                               }
-                       }
-                       dMatrix->rmCell(rowCells[i]);
-               
+               bool changed = false;
+               if (colCell.dist < rowCell.dist) {
+                       colCell.dist = rowCell.dist;
+                       changed = true;
                }       
-               clusterBins();
-               clusterNames();
-       
-               for(int i=0;i<nColCells;i++){
-                       if(found[i] == 0){
-                               dMatrix->rmCell(colCells[i]);
-                       }
-               }
+               return(changed);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the CompleteLinkage class Function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "CompleteLinkage", "updateDistance");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the CompleteLinkage class function update. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
 }
 
 /***********************************************************************/