Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00057 #ifdef _MSC_VER
00058 #pragma once
00059 #endif
00060
00061 #ifndef OGDF_CLUSTERER_H
00062 #define OGDF_CLUSTERER_H
00063
00064 #include <ogdf/module/ClustererModule.h>
00065
00066 namespace ogdf {
00067
00068
00076 class OGDF_EXPORT Clusterer : public ClustererModule
00077 {
00078 public:
00079
00080 Clusterer(const Graph &G);
00081
00082
00083
00084 virtual ~Clusterer() {}
00085
00086
00087
00088
00089
00090 virtual void computeClustering(SList<SimpleCluster*> &sl);
00091
00092
00093 void setClusteringThresholds(const List<double> &threshs);
00094
00095
00096
00097
00098 void setAutomaticThresholds(int numValues)
00099 {m_autoThreshNum = numValues;}
00100
00101 void setRecursive(bool b) {m_recursive = b;}
00102
00103 void computeEdgeStrengths(EdgeArray<double> & strength);
00104 void computeEdgeStrengths(const Graph &G, EdgeArray<double> & strength);
00105
00106 void createClusterGraph(ClusterGraph &C);
00107
00108 void setStopIndex(double stop) {m_stopIndex = stop;}
00109
00110
00111
00112 virtual double computeCIndex(node v)
00113 {
00114 return computeCIndex(*m_pGraph, v);
00115 }
00116 virtual double computeCIndex(const Graph &G, node v)
00117 {
00118 OGDF_ASSERT(v->graphOf() == &G);
00119 if (v->degree()<2) return 1.0;
00120 int conns = 0;
00121 NodeArray<bool> neighbor(G, false);
00122 adjEntry adjE;
00123 forall_adj(adjE, v)
00124 {
00125 neighbor[adjE->twinNode()] = true;
00126 }
00127 forall_adj(adjE, v)
00128 {
00129 adjEntry adjEE;
00130 forall_adj(adjEE, adjE->twinNode())
00131 {
00132 if (neighbor[adjEE->twinNode()])
00133 conns++;
00134 }
00135 }
00136
00137 double index = conns / 2.0;
00138 return index / (v->degree()*(v->degree()-1));
00139 }
00140
00141 protected:
00142 EdgeArray<double> m_edgeValue;
00143 NodeArray<double> m_vertexValue;
00144 List<double> m_thresholds;
00145 List<double> m_autoThresholds;
00146 List<double> m_defaultThresholds;
00147 double m_stopIndex;
00148
00149 bool m_recursive;
00150
00151 int m_autoThreshNum;
00152
00153 };
00154
00155 }
00156
00157 #endif