Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ModifiedNibbleClusterer.h
Go to the documentation of this file.
1
32#pragma once
33
35#include <ogdf/basic/Graph.h>
38#include <ogdf/basic/geometry.h>
39
40#include <cmath>
41#include <vector>
42
43namespace ogdf {
44
46
59public:
62 , m_maxClusterSize(100)
63 , maxClusterNum(100)
65 , m_pG(nullptr)
66 , m_pGC(nullptr)
68
70#if 0
71 delete m_pGC;
72#endif
73 }
74
75 //TODO add a call with GraphAttributes and store in intweight
76
79 long call(Graph& G, NodeArray<long>& clusterNum);
80
87 long call(Graph& G, NodeArray<long>& clusterNum, NodeArray<long>& topLevelNum);
88
91 // TODO long call(ClusterGraph &C, Graph & G) {}
92 void setMaxClusterNum(int i) { maxClusterNum = i; }
93
94 void setMaxClusterSize(long i) { m_maxClusterSize = i; }
95
96 // Smaller clusters are joint with a neighbor (non-recursive) as a postprocessing
97 void setClusterSizeThreshold(int threshold) {
98 if (threshold > 0) {
99 m_clusterThreshold = threshold;
100 }
101 }
102
104
105protected:
106 void initialize(); //1< Initialize values for calculation before first step
109 std::vector<node>& bestCluster);
110 double findBestCluster(NodeArray<bool>& isActive, std::vector<node>& activeNodes,
111 std::vector<node>& cluster);
112 void spreadValues(NodeArray<bool>& isActive, std::vector<node>& activeNodes,
113 NodeArray<double>& probUpdate);
114
115 inline long maxClusterSize() { return m_maxClusterSize; }
116
117 // Arithmetic plus Geometric Progression
118 int aPGP(int i) {
119 const int a = 2;
120 const int d = 7;
121 const double r = 1.5;
122 return static_cast<int>(ceil(a * pot(r, i))) + i * d + a;
123 }
124
125 // TODO we expect i to be very small, but do this efficiently anyway
126 double pot(double r, long i) { return pow(r, static_cast<double>(i)); }
127
129 const int factor = 25;
130 //does not make sense to set it to 500 as they did, as we want less clusters.
131 return factor * m_maxClusterSize;
132 }
133
135
136private:
138 int m_clusterThreshold; // Below that size all remaining nodes are just packed in a cluster
140 long m_maxActiveNodes; // Bound on number of nodes in active set
142 double m_spreadProbability; //how much is spread, i.e. 1-val is the prob to stay at the node
143 node m_startNode; // Node to start a walk from
144 NodeArray<double> m_prob; // Probability of a node along the walk
148
149 // Tests
151 double sum = 0.0;
152 for (node v : m_pGC->nodes) {
153 sum += m_prob[v];
154 }
155 return OGDF_GEOM_ET.equal(sum, 1.0);
156 }
157};
158
159}
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
Includes declaration of graph class.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
Representation of clusters in a clustered graph.
std::enable_if< std::is_integral< T >::value, bool >::type equal(const T &x, const T &y) const
Compare if x is EQUAL to y for integral types.
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:390
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition Graph_d.h:929
The modified nibble clustering algorithm.
void modifiedNibble(node snode, std::vector< node > &bestCluster)
main step with walks starting from snode
long call(Graph &G, NodeArray< long > &clusterNum)
Call method: Creates a clustering of G Returns number of created clusters and sets cluster index for ...
void spreadValues(NodeArray< bool > &isActive, std::vector< node > &activeNodes, NodeArray< double > &probUpdate)
node selectStartNode()
select start node according to some strategy
double findBestCluster(NodeArray< bool > &isActive, std::vector< node > &activeNodes, std::vector< node > &cluster)
long call(Graph &G, NodeArray< long > &clusterNum, NodeArray< long > &topLevelNum)
A convenience method. Due to the characteristics of the algorithm (not very accurate,...
void setMaxClusterNum(int i)
Call method: Creates a clustering of G in C Returns number of created clusters.
Class for the representation of nodes.
Definition Graph_d.h:241
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
The namespace for all OGDF objects.
const EpsilonTest OGDF_GEOM_ET