Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
GEMLayout.h
Go to the documentation of this file.
1
35#pragma once
36
40#include <ogdf/basic/Math.h>
41
42#include <random>
43
44namespace ogdf {
45
47
105 // algorithm parameters (see below)
106
118 double m_minDistCC;
119 double m_pageRatio;
120
121 // node data used by the algorithm
122
127
128 // other data used by the algorithm
129
135 double m_cos;
136 double m_sin;
137
138 std::minstd_rand m_rng;
139
140public:
143
146
147 // destructor
149
152
154 virtual void call(GraphAttributes& GA) override;
155
157 int numberOfRounds() const { return m_numberOfRounds; }
158
160 void numberOfRounds(int n) { m_numberOfRounds = (n < 0) ? 0 : n; }
161
163 double minimalTemperature() const { return m_minimalTemperature; }
164
166 void minimalTemperature(double x) { m_minimalTemperature = (x < 0) ? 0 : x; }
167
169 double initialTemperature() const { return m_initialTemperature; }
170
172 void initialTemperature(double x) {
173 m_initialTemperature = (x < m_minimalTemperature) ? m_minimalTemperature : x;
174 }
175
177 double gravitationalConstant() const { return m_gravitationalConstant; }
178
181 void gravitationalConstant(double x) { m_gravitationalConstant = (x < 0) ? 0 : x; }
182
184 double desiredLength() const { return m_desiredLength; }
185
187 void desiredLength(double x) { m_desiredLength = (x < 0) ? 0 : x; }
188
190 double maximalDisturbance() const { return m_maximalDisturbance; }
191
193 void maximalDisturbance(double x) { m_maximalDisturbance = (x < 0) ? 0 : x; }
194
196 double rotationAngle() const { return m_rotationAngle; }
197
199 void rotationAngle(double x) {
200 if (x < 0) {
201 x = 0;
202 }
203 if (x > Math::pi / 2.0) {
204 x = Math::pi / 2.0;
205 }
206 m_rotationAngle = x;
207 }
208
210 double oscillationAngle() const { return m_oscillationAngle; }
211
213 void oscillationAngle(double x) {
214 if (x < 0) {
215 x = 0;
216 }
217 if (x > Math::pi / 2.0) {
218 x = Math::pi / 2.0;
219 }
220 m_oscillationAngle = x;
221 }
222
224 double rotationSensitivity() const { return m_rotationSensitivity; }
225
227 void rotationSensitivity(double x) {
228 if (x < 0) {
229 x = 0;
230 }
231 if (x > 1) {
232 x = 1;
233 }
234 m_rotationSensitivity = x;
235 }
236
238 double oscillationSensitivity() const { return m_oscillationSensitivity; }
239
241 void oscillationSensitivity(double x) {
242 if (x < 0) {
243 x = 0;
244 }
245 if (x > 1) {
246 x = 1;
247 }
248 m_oscillationSensitivity = x;
249 }
250
252 int attractionFormula() const { return m_attractionFormula; }
253
255 void attractionFormula(int n) {
256 if (n == 1 || n == 2) {
257 m_attractionFormula = n;
258 }
259 }
260
262 double minDistCC() const { return m_minDistCC; }
263
265 void minDistCC(double x) { m_minDistCC = x; }
266
268 double pageRatio() const { return m_pageRatio; }
269
271 void pageRatio(double x) { m_pageRatio = x; }
272
273
274private:
276 double length(double x, double y = 0) const { return sqrt(x * x + y * y); }
277
279 double weight(node v) const { return (double)(v->degree()) / 2.5 + 1.0; }
280
283
286
288};
289
290}
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declaration of graph copy classes.
Declaration of interface for layout algorithms (class LayoutModule)
Mathematical Helpers.
The energy-based GEM layout algorithm.
Definition GEMLayout.h:104
double oscillationAngle() const
Returns the opening angle for oscillations.
Definition GEMLayout.h:210
GEMLayout & operator=(const GEMLayout &fl)
Assignment operator.
void updateNode(GraphCopy &GC, GraphAttributes &AGC, node v)
Updates the node data for node v.
double oscillationSensitivity() const
Returns the oscillation sensitivity.
Definition GEMLayout.h:238
double m_minimalTemperature
The minimal temperature.
Definition GEMLayout.h:108
void minimalTemperature(double x)
Sets the minimal temperature to x.
Definition GEMLayout.h:166
GEMLayout()
Creates an instance of GEM layout.
double rotationSensitivity() const
Returns the rotation sensitivity.
Definition GEMLayout.h:224
double m_pageRatio
The page ratio used for the layout of connected components.
Definition GEMLayout.h:119
NodeArray< double > m_localTemperature
local temperature of the node
Definition GEMLayout.h:125
double m_cos
Cosine of m_oscillationAngle / 2.
Definition GEMLayout.h:135
double minimalTemperature() const
Returns the minimal temperature.
Definition GEMLayout.h:163
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm for graph attributes GA.
double m_initialTemperature
The initial temperature.
Definition GEMLayout.h:109
void numberOfRounds(int n)
Sets the maximal number of round per node to n.
Definition GEMLayout.h:160
double m_rotationAngle
The opening angle for rotations.
Definition GEMLayout.h:113
double minDistCC() const
Returns the minimal distance between connected components.
Definition GEMLayout.h:262
std::minstd_rand m_rng
Definition GEMLayout.h:138
double m_rotationSensitivity
The rotation sensitivity.
Definition GEMLayout.h:115
double m_barycenterX
Weighted sum of x-coordinates of all nodes.
Definition GEMLayout.h:130
double m_minDistCC
The minimal distance between connected components.
Definition GEMLayout.h:118
NodeArray< double > m_impulseX
x-coordinate of the last impulse of the node
Definition GEMLayout.h:123
double initialTemperature() const
Returns the initial temperature.
Definition GEMLayout.h:169
double m_maximalDisturbance
The maximal disturbance.
Definition GEMLayout.h:112
void rotationAngle(double x)
Sets the opening angle for rotations to x (0 <= x <= pi / 2).
Definition GEMLayout.h:199
void maximalDisturbance(double x)
Sets the maximal disturbance to x; must be >= 0.
Definition GEMLayout.h:193
void oscillationSensitivity(double x)
Sets the oscillation sensitivity to x (0 <= x <= 1).
Definition GEMLayout.h:241
double m_oscillationSensitivity
The oscillation sensitivity.
Definition GEMLayout.h:116
void computeImpulse(GraphCopy &GC, GraphAttributes &AGC, node v)
Computes the new impulse for node v.
int numberOfRounds() const
Returns the maximal number of rounds per node.
Definition GEMLayout.h:157
double rotationAngle() const
Returns the opening angle for rotations.
Definition GEMLayout.h:196
void minDistCC(double x)
Sets the minimal distance between connected components to x.
Definition GEMLayout.h:265
void rotationSensitivity(double x)
Sets the rotation sensitivity to x (0 <= x <= 1).
Definition GEMLayout.h:227
void gravitationalConstant(double x)
Sets the gravitational constant to x; must be >= 0. Attention! Only (very) small values give acceptab...
Definition GEMLayout.h:181
double m_sin
Sine of (pi + m_rotationAngle) / 2.
Definition GEMLayout.h:136
void oscillationAngle(double x)
Sets the opening angle for oscillations to x (0 <= x <= pi / 2).
Definition GEMLayout.h:213
NodeArray< double > m_skewGauge
skew gauge of the node
Definition GEMLayout.h:126
int attractionFormula() const
Returns the used formula for attraction (1 = Fruchterman / Reingold, 2 = GEM).
Definition GEMLayout.h:252
double weight(node v) const
Returns the weight of node v according to its degree.
Definition GEMLayout.h:279
double m_newImpulseY
y-coordinate of the new impulse of the current node.
Definition GEMLayout.h:133
double m_oscillationAngle
The opening angle for oscillations.
Definition GEMLayout.h:114
double pageRatio() const
Returns the page ratio used for the layout of connected components.
Definition GEMLayout.h:268
void pageRatio(double x)
Sets the page ratio used for the layout of connected components to x.
Definition GEMLayout.h:271
double maximalDisturbance() const
Returns the maximal disturbance.
Definition GEMLayout.h:190
void initialTemperature(double x)
Sets the initial temperature to x; must be >= minimalTemperature.
Definition GEMLayout.h:172
double length(double x, double y=0) const
Returns the length of the vector (x,y).
Definition GEMLayout.h:276
double gravitationalConstant() const
Returns the gravitational constant.
Definition GEMLayout.h:177
void attractionFormula(int n)
sets the formula for attraction to n (1 = Fruchterman / Reingold, 2 = GEM).
Definition GEMLayout.h:255
GEMLayout(const GEMLayout &fl)
Copy constructor.
int m_attractionFormula
The used formula for attraction.
Definition GEMLayout.h:117
double desiredLength() const
Returns the desired edge length.
Definition GEMLayout.h:184
void desiredLength(double x)
Sets the desired edge length to x; must be >= 0.
Definition GEMLayout.h:187
int m_numberOfRounds
The maximal number of rounds per node.
Definition GEMLayout.h:107
double m_gravitationalConstant
The gravitational constant.
Definition GEMLayout.h:110
double m_desiredLength
The desired edge length.
Definition GEMLayout.h:111
double m_globalTemperature
Average of all node temperatures.
Definition GEMLayout.h:134
double m_barycenterY
Weighted sum of y-coordinates of all nodes.
Definition GEMLayout.h:131
double m_newImpulseX
x-coordinate of the new impulse of the current node.
Definition GEMLayout.h:132
NodeArray< double > m_impulseY
y-coordinate of the last impulse of the node
Definition GEMLayout.h:124
Stores additional attributes of a graph (like layout information).
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:254
Interface of general layout algorithms.
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition Graph_d.h:220
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition memory.h:84
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.