]> git.donarmstrong.com Git - mothur.git/blob - sparsedistancematrix.h
added modify names parameter to set.dir
[mothur.git] / sparsedistancematrix.h
1 #ifndef Mothur_sparsedistancematrix_h
2 #define Mothur_sparsedistancematrix_h
3
4 //
5 //  sparsedistancematrix.h
6 //  Mothur
7 //
8 //  Created by Sarah Westcott on 7/16/12.
9 //  Copyright (c) 2012 Schloss Lab. All rights reserved.
10 //
11
12 #include "mothur.h"
13 #include "mothurout.h"
14
15
16 class ListVector;
17
18
19 /* For each distance in a sparse matrix we have a row, column and distance.  
20  The PDistCell consists of the column and distance.
21  We know the row by the distances row in the seqVec matrix.  
22  SeqVec is square and each row is sorted so the column values are ascending to save time in the search for the smallest distance. */
23
24 /***********************************************************************/
25 struct PDistCellMin{
26         ull row;
27     ull col;
28         //PDistCell* cell;
29         PDistCellMin(ull r, ull c) :  col(c), row(r) {}
30 };
31 /***********************************************************************/
32
33
34
35 class SparseDistanceMatrix {
36         
37 public:
38         SparseDistanceMatrix();
39         ~SparseDistanceMatrix(){ clear(); }
40         int getNNodes();
41         ull getSmallestCell(ull& index);                //Return the cell with the smallest distance
42         float getSmallDist();
43         
44         int rmCell(ull, ull);
45     int updateCellCompliment(ull, ull);
46     void resize(ull n) { seqVec.resize(n);  }
47     void clear();
48         void addCell(ull, PDistCell);
49     vector<vector<PDistCell> > seqVec;
50     
51 private:
52         PDistCell smallCell;                            //The cell with the smallest distance
53         int numNodes;
54     
55     bool sorted;
56     int sortSeqVec();
57         float smallDist, aboveCutoff;
58     
59         MothurOut* m;
60 };
61
62 /***********************************************************************/
63
64
65
66 #endif