+++ /dev/null
-#ifndef Clust_h\r
-#define Clust_h\r
-\r
-class Clust;\r
-class ClustNode;\r
-class ClustSet;\r
-class Phylip;\r
-class SortedNode;\r
-\r
-const unsigned RB_NIL = ((unsigned) 0xfff0);\r
-\r
-class ClustNode\r
- {\r
-public:\r
- ClustNode()\r
- {\r
- m_uIndex = uInsane;\r
- m_uSize = uInsane;\r
- m_dLength = (float) dInsane;\r
- m_ptrLeft = 0;\r
- m_ptrRight = 0;\r
- m_ptrParent = 0;\r
- m_ptrNextCluster = 0;\r
- m_ptrPrevCluster = 0;\r
- m_uLeafIndexes = 0;\r
- }\r
- ~ClustNode()\r
- {\r
- delete[] m_uLeafIndexes;\r
- }\r
- unsigned m_uIndex;\r
- unsigned m_uSize;\r
- float m_dLength;\r
- ClustNode *m_ptrLeft;\r
- ClustNode *m_ptrRight;\r
- ClustNode *m_ptrParent;\r
- ClustNode *m_ptrNextCluster;\r
- ClustNode *m_ptrPrevCluster;\r
- unsigned *m_uLeafIndexes;\r
- };\r
-\r
-class Clust\r
- {\r
-public:\r
- Clust();\r
- virtual ~Clust();\r
-\r
- void Create(ClustSet &Set, CLUSTER Method);\r
-\r
- unsigned GetLeafCount() const;\r
-\r
- unsigned GetClusterCount() const;\r
- unsigned GetClusterSize(unsigned uNodeIndex) const;\r
- unsigned GetLeaf(unsigned uClusterIndex, unsigned uLeafIndex) const;\r
-\r
- unsigned GetNodeCount() const { return 2*m_uLeafCount - 1; }\r
- const ClustNode &GetRoot() const { return m_Nodes[GetRootNodeIndex()]; }\r
- unsigned GetRootNodeIndex() const { return m_uNodeCount - 1; }\r
-\r
- const ClustNode &GetNode(unsigned uNodeIndex) const;\r
- bool IsLeaf(unsigned uNodeIndex) const;\r
- unsigned GetLeftIndex(unsigned uNodeIndex) const;\r
- unsigned GetRightIndex(unsigned uNodeIndex) const;\r
- float GetLength(unsigned uNodeIndex) const;\r
- float GetHeight(unsigned uNodeIndex) const;\r
- const char *GetNodeName(unsigned uNodeIndex) const;\r
- unsigned GetNodeId(unsigned uNodeIndex) const;\r
-\r
- JOIN GetJoinStyle() const { return m_JoinStyle; }\r
- LINKAGE GetCentroidStyle() const { return m_CentroidStyle; }\r
-\r
- void SetDist(unsigned uIndex1, unsigned uIndex2, float dDist);\r
- float GetDist(unsigned uIndex1, unsigned uIndex2) const;\r
-\r
- void ToPhylip(Phylip &tree);\r
-\r
- void LogMe() const;\r
-\r
-//private:\r
- void SetLeafCount(unsigned uLeafCount);\r
-\r
- void CreateCluster();\r
- void JoinNodes(unsigned uLeftNodeIndex, unsigned uRightNodeIndex, \r
- float dLeftLength, float dRightLength, unsigned uNewNodeIndex);\r
-\r
- void ChooseJoin(unsigned *ptruLeftIndex, unsigned *ptruRightIndex,\r
- float *ptrdLeftLength, float *ptrdRightLength);\r
- void ChooseJoinNeighborJoining(unsigned *ptruLeftIndex, unsigned *ptruRightIndex,\r
- float *ptrdLeftLength, float *ptrdRightLength);\r
- void ChooseJoinNearestNeighbor(unsigned *ptruLeftIndex, unsigned *ptruRightIndex,\r
- float *ptrdLeftLength, float *ptrdRightLength);\r
-\r
- float ComputeDist(unsigned uNewNodeIndex, unsigned uNodeIndex);\r
- float ComputeDistAverageLinkage(unsigned uNewNodeIndex, unsigned uNodeIndex);\r
- float ComputeDistMinLinkage(unsigned uNewNodeIndex, unsigned uNodeIndex);\r
- float ComputeDistMaxLinkage(unsigned uNewNodeIndex, unsigned uNodeIndex);\r
- float ComputeDistNeighborJoining(unsigned uNewNewIndex, unsigned uNodeIndex);\r
- float ComputeDistMAFFT(unsigned uNewNewIndex, unsigned uNodeIndex);\r
-\r
- float Calc_r(unsigned uNodeIndex) const;\r
-\r
- unsigned VectorIndex(unsigned uIndex1, unsigned uIndex2) const;\r
-\r
- unsigned GetFirstCluster() const;\r
- unsigned GetNextCluster(unsigned uNodeIndex) const;\r
-\r
- float ComputeMetric(unsigned uIndex1, unsigned uIndex2) const;\r
- float ComputeMetricNearestNeighbor(unsigned i, unsigned j) const;\r
- float ComputeMetricNeighborJoining(unsigned i, unsigned j) const;\r
-\r
- void InitMetric(unsigned uMaxNodeIndex);\r
- void InsertMetric(unsigned uIndex1, unsigned uIndex2, float dMetric);\r
- float GetMinMetric(unsigned *ptruIndex1, unsigned *ptruIndex2) const;\r
- float GetMinMetricBruteForce(unsigned *ptruIndex1, unsigned *ptruIndex2) const;\r
- void DeleteMetric(unsigned uIndex);\r
- void DeleteMetric(unsigned uIndex1, unsigned uIndex2);\r
- void ListMetric() const;\r
-\r
- void DeleteFromClusterList(unsigned uNodeIndex);\r
- void AddToClusterList(unsigned uNodeIndex);\r
-\r
- void RBDelete(unsigned RBNode);\r
- unsigned RBInsert(unsigned i, unsigned j, float fMetric);\r
-\r
- unsigned RBNext(unsigned RBNode) const;\r
- unsigned RBPrev(unsigned RBNode) const;\r
- unsigned RBMin(unsigned RBNode) const;\r
- unsigned RBMax(unsigned RBNode) const;\r
-\r
- void ValidateRB(const char szMsg[] = 0) const;\r
- void ValidateRBNode(unsigned Node, const char szMsg[]) const;\r
-\r
-//private:\r
- JOIN m_JoinStyle;\r
- LINKAGE m_CentroidStyle;\r
- ClustNode *m_Nodes;\r
- unsigned *m_ClusterIndexToNodeIndex;\r
- unsigned *m_NodeIndexToClusterIndex;\r
- unsigned m_uLeafCount;\r
- unsigned m_uNodeCount;\r
- unsigned m_uClusterCount;\r
- unsigned m_uTriangularMatrixSize;\r
- float *m_dDist;\r
- ClustSet *m_ptrSet;\r
- ClustNode *m_ptrClusterList;\r
- };\r
-\r
-#endif // Clust_h\r