Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
SpringEmbedderFRExact.h
Go to the documentation of this file.
1
32#pragma once
33
35#include <ogdf/basic/SList.h>
37
38namespace ogdf {
39
42public:
43 enum class CoolingFunction { Factor, Logarithmic };
44
47
49 virtual void call(GraphAttributes& GA) override;
50
52 int iterations() const { return m_iterations; }
53
55 void iterations(int i) {
56 OGDF_ASSERT(i > 0);
57 m_iterations = i;
58 }
59
61 bool noise() const { return m_noise; }
62
64 void noise(bool on) { m_noise = on; }
65
67 void nodeWeights(bool on) { m_useNodeWeight = on; }
68
70 CoolingFunction coolingFunction() const { return m_coolingFunction; }
71
73 void coolingFunction(CoolingFunction f) { m_coolingFunction = f; }
74
76 double idealEdgeLength() const { return m_idealEdgeLength; }
77
79 void idealEdgeLength(double len) { m_idealEdgeLength = len; }
80
82 double minDistCC() const { return m_minDistCC; }
83
85 void minDistCC(double x) { m_minDistCC = x; }
86
88 double pageRatio() { return m_pageRatio; }
89
91 void pageRatio(double x) { m_pageRatio = x; }
92
93 void checkConvergence(bool b) { m_checkConvergence = b; }
94
95 bool checkConvergence() { return m_checkConvergence; }
96
97 void convTolerance(double tol) { m_convTolerance = tol; }
98
99private:
104
109
110 public:
113
114 void initCC(int i);
115
116 int numberOfCCs() const { return m_numCC; }
117
118 int numberOfNodes() const { return m_numNodes; }
119
120 int numberOfEdges() const { return m_numEdges; }
121
122 node original(int v) const { return m_orig[v]; }
123
124 const SList<node>& nodesInCC(int i) const { return m_nodesInCC[i]; }
125
126 int* m_src;
127 int* m_tgt;
128 double* m_x;
129 double* m_y;
131 //this should be part of a multilevel layout interface class later on
132 bool m_useNodeWeight; //should given nodeweights be used or all set to 1.0?
133 };
134
135 double log2(double x) { return log(x) / log(2.0); }
136
137 double mylog2(int x) {
138 double result = 0.0;
139 while (x > 0) {
140 result++;
141 x >>= 1;
142 }
143 return result / 2;
144 }
145
146 void initialize(ArrayGraph& component);
147 void mainStep(ArrayGraph& component);
148 void mainStep_sse3(ArrayGraph& component);
149
150#if 0
151 // Fruchterman, Reingold
152 double f_att(double d) { return d*d / m_idealEdgeLength; }
153 double f_rep(double d) { return m_idealEdgeLength*m_idealEdgeLength / d; }
154
155 // Eades
156 double f_att(double d) { return 5.0 * d * log2(d/m_idealEdgeLength); }
157 double f_rep(double d) { return 20.0 / d; }
158#endif
159
160 // cooling function
161 void cool(double& tx, double& ty, int& cF);
162
164 bool m_noise;
166
167#if 0
168 double m_tx;
169 double m_ty;
170#endif
171
174
176 double m_minDistCC;
177 double m_pageRatio;
178
179#if 0
180 int m_cF;
181#endif
182 double m_txNull;
183 double m_tyNull;
184 //see above at ArrayGraph
186 bool m_checkConvergence; //<! If set to true, computation is stopped if movement falls below threshold
187 double m_convTolerance; //<! Fraction of ideal edge length below which convergence is achieved
188};
189
190}
Declaration of interface for energy-based layout algorithms (class ForceLayoutModule)
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declaration of singly linked lists and iterators.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:214
Interface of general layout algorithms.
Stores additional attributes of a graph (like layout information).
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
Singly linked lists (maintaining the length of the list).
Definition SList.h:833
const SList< node > & nodesInCC(int i) const
Fruchterman-Reingold algorithm with (exact) layout.
bool noise() const
Returns the current setting of nodes.
double pageRatio()
Returns the page ratio.
SpringEmbedderFRExact()
Creates an instance of Fruchterman/Reingold (exact) layout.
double minDistCC() const
Returns the minimum distance between connected components.
void initialize(ArrayGraph &component)
void coolingFunction(CoolingFunction f)
Sets the parameter coolingFunction to f.
int m_iterations
The number of iterations.
double m_minDistCC
The minimal distance between connected components.
CoolingFunction coolingFunction() const
Returns the current setting for the cooling function.
bool m_noise
Perform random perturbations?
void iterations(int i)
Sets the number of iterations to i.
void noise(bool on)
Sets the parameter noise to on.
double idealEdgeLength() const
Returns the ideal edge length.
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm for graph attributes GA.
CoolingFunction m_coolingFunction
The selected cooling function.
int iterations() const
Returns the current setting of iterations.
void nodeWeights(bool on)
Switches use of node weights given in GraphAttributtes.
void minDistCC(double x)
Sets the minimum distance between connected components to x.
void idealEdgeLength(double len)
Sets the ideal edge length to len.
void pageRatio(double x)
Sets the page ration to x.
double m_idealEdgeLength
The ideal edge length.
void mainStep_sse3(ArrayGraph &component)
void mainStep(ArrayGraph &component)
void cool(double &tx, double &ty, int &cF)
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.