]> git.donarmstrong.com Git - mothur.git/blob - weightedlinkage.cpp
added modify names parameter to set.dir
[mothur.git] / weightedlinkage.cpp
1 #ifndef WEIGHTEDLINKAGE_H
2 #define WEIGHTEDLINKAGE_H
3
4
5 #include "mothur.h"
6 #include "cluster.hpp"
7 #include "rabundvector.hpp"
8
9 /* This class implements the WPGMA, weighted average neighbor clustering algorithm */
10
11 /***********************************************************************/
12
13 WeightedLinkage::WeightedLinkage(RAbundVector* rav, ListVector* lv, SparseDistanceMatrix* dm, float c, string s) :
14         Cluster(rav, lv, dm, c, s)
15 {
16         saveRow = -1;
17         saveCol = -1;
18 }
19
20
21 /***********************************************************************/
22 //This function returns the tag of the method.
23 string WeightedLinkage::getTag() {
24         return("wn");
25 }
26
27
28 /***********************************************************************/
29 //This function updates the distance based on the average linkage method.
30 bool WeightedLinkage::updateDistance(PDistCell& colCell, PDistCell& rowCell) {
31         try {
32                 if ((saveRow != smallRow) || (saveCol != smallCol)) {
33 //                      rowBin = rabund->get(smallRow);
34 //                      colBin = rabund->get(smallCol);
35 //                      totalBin = rowBin + colBin;
36                         saveRow = smallRow;
37                         saveCol = smallCol;
38                 }
39                 
40                 colCell.dist = (colCell.dist + rowCell.dist) / 2.0;
41                 
42                 return(true);
43         }
44         catch(exception& e) {
45                 m->errorOut(e, "WeightedLinkage", "updateDistance");
46                 exit(1);
47         }
48 }
49
50 /***********************************************************************/
51
52
53 /***********************************************************************/
54
55 #endif