Next version of JABA
[jabaws.git] / binaries / src / muscle / cluster.h
1 class DistFunc;\r
2 \r
3 class ClusterNode\r
4         {\r
5         friend class ClusterTree;\r
6 public:\r
7         ClusterNode()\r
8                 {\r
9                 m_dWeight = 0.0;\r
10                 m_dWeight2 = 0.0;\r
11                 m_ptrLeft = 0;\r
12                 m_ptrRight = 0;\r
13                 m_ptrParent = 0;\r
14                 m_uIndex = 0;\r
15                 m_ptrPrevDisjoint = 0;\r
16                 m_ptrNextDisjoint = 0;\r
17                 }\r
18         ~ClusterNode() {}\r
19 \r
20 public:\r
21         unsigned GetIndex() const { return m_uIndex; }\r
22         ClusterNode *GetLeft() const { return m_ptrLeft; }\r
23         ClusterNode *GetRight() const { return m_ptrRight; }\r
24         ClusterNode *GetParent() const { return m_ptrParent; }\r
25         double GetWeight() const { return m_dWeight; }\r
26 \r
27         const ClusterNode *GetClusterLeaf(unsigned uLeafIndex) const;\r
28         unsigned GetClusterSize() const;\r
29         double GetClusterWeight() const;\r
30         double GetLeftBranchWeight() const;\r
31         double GetRightBranchWeight() const;\r
32         double GetLeftWeight() const;\r
33         double GetRightWeight() const;\r
34 \r
35         void LogMe() const;\r
36 \r
37         double GetWeight2() const { return m_dWeight2; }\r
38         void SetWeight2(double dWeight2) { m_dWeight2 = dWeight2; }\r
39 \r
40 protected:\r
41         void SetIndex(unsigned uIndex) { m_uIndex = uIndex; }\r
42         void SetWeight(double dWeight) { m_dWeight = dWeight; }\r
43         void SetLeft(ClusterNode *ptrLeft) { m_ptrLeft = ptrLeft; }\r
44         void SetRight(ClusterNode *ptrRight) { m_ptrRight = ptrRight; }\r
45         void SetParent(ClusterNode *ptrParent) { m_ptrParent = ptrParent; }\r
46         void SetNextDisjoint(ClusterNode *ptrNode) { m_ptrNextDisjoint = ptrNode; }\r
47         void SetPrevDisjoint(ClusterNode *ptrNode) { m_ptrPrevDisjoint = ptrNode; }\r
48 \r
49         ClusterNode *GetNextDisjoint() { return m_ptrNextDisjoint; }\r
50         ClusterNode *GetPrevDisjoint() { return m_ptrPrevDisjoint; }\r
51 \r
52 private:\r
53         double m_dWeight;\r
54         double m_dWeight2;\r
55         unsigned m_uIndex;\r
56         ClusterNode *m_ptrLeft;\r
57         ClusterNode *m_ptrRight;\r
58         ClusterNode *m_ptrParent;\r
59         ClusterNode *m_ptrNextDisjoint;\r
60         ClusterNode *m_ptrPrevDisjoint;\r
61         };\r
62 \r
63 class ClusterTree\r
64         {\r
65 public:\r
66         ClusterTree();\r
67         virtual ~ClusterTree();\r
68 \r
69         void Create(const DistFunc &DF);\r
70 \r
71         ClusterNode *GetRoot() const;\r
72         void LogMe() const;\r
73 \r
74 protected:\r
75         void Join(ClusterNode *ptrNode1, ClusterNode *ptrNode2,\r
76           ClusterNode *ptrJoin);\r
77         void AddToDisjoints(ClusterNode *ptrNode);\r
78         void DeleteFromDisjoints(ClusterNode *ptrNode);\r
79         void Validate(unsigned uNodeCount);\r
80 \r
81 private:\r
82         ClusterNode *m_ptrDisjoints;\r
83         ClusterNode *m_Nodes;\r
84         unsigned m_uNodeCount;\r
85         unsigned m_uLeafCount;\r
86         };\r