]> git.donarmstrong.com Git - mothur.git/blob - sparsedistancematrix.h
changes while testing
[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     int addCellSorted(ull, PDistCell);
50     vector<vector<PDistCell> > seqVec;
51     
52     
53 private:
54         PDistCell smallCell;                            //The cell with the smallest distance
55         int numNodes;
56     
57     bool sorted;
58     int sortSeqVec();
59     int sortSeqVec(int);
60         float smallDist, aboveCutoff;
61     
62         MothurOut* m;
63
64 };
65
66 /***********************************************************************/
67
68
69
70 #endif