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
37#include <ogdf/basic/Graph.h>
39#include <ogdf/basic/Math.h>
40#include <ogdf/basic/basic.h>
41#include <ogdf/basic/memory.h>
42
43#include <cmath>
44#include <random>
45
46namespace ogdf {
47class GraphAttributes;
48class GraphCopy;
49
51
109 // algorithm parameters (see below)
110
122 double m_minDistCC;
123 double m_pageRatio;
124
125 // node data used by the algorithm
126
131
132 // other data used by the algorithm
133
139 double m_cos;
140 double m_sin;
141
142 std::minstd_rand m_rng;
143
144public:
147
150
151 // destructor
153
156
158 virtual void call(GraphAttributes& GA) override;
159
161 int numberOfRounds() const { return m_numberOfRounds; }
162
164 void numberOfRounds(int n) { m_numberOfRounds = (n < 0) ? 0 : n; }
165
167 double minimalTemperature() const { return m_minimalTemperature; }
168
170 void minimalTemperature(double x) { m_minimalTemperature = (x < 0) ? 0 : x; }
171
173 double initialTemperature() const { return m_initialTemperature; }
174
176 void initialTemperature(double x) {
177 m_initialTemperature = (x < m_minimalTemperature) ? m_minimalTemperature : x;
178 }
179
181 double gravitationalConstant() const { return m_gravitationalConstant; }
182
185 void gravitationalConstant(double x) { m_gravitationalConstant = (x < 0) ? 0 : x; }
186
188 double desiredLength() const { return m_desiredLength; }
189
191 void desiredLength(double x) { m_desiredLength = (x < 0) ? 0 : x; }
192
194 double maximalDisturbance() const { return m_maximalDisturbance; }
195
197 void maximalDisturbance(double x) { m_maximalDisturbance = (x < 0) ? 0 : x; }
198
200 double rotationAngle() const { return m_rotationAngle; }
201
203 void rotationAngle(double x) {
204 if (x < 0) {
205 x = 0;
206 }
207 if (x > Math::pi / 2.0) {
208 x = Math::pi / 2.0;
209 }
210 m_rotationAngle = x;
211 }
212
214 double oscillationAngle() const { return m_oscillationAngle; }
215
217 void oscillationAngle(double x) {
218 if (x < 0) {
219 x = 0;
220 }
221 if (x > Math::pi / 2.0) {
222 x = Math::pi / 2.0;
223 }
224 m_oscillationAngle = x;
225 }
226
228 double rotationSensitivity() const { return m_rotationSensitivity; }
229
231 void rotationSensitivity(double x) {
232 if (x < 0) {
233 x = 0;
234 }
235 if (x > 1) {
236 x = 1;
237 }
238 m_rotationSensitivity = x;
239 }
240
242 double oscillationSensitivity() const { return m_oscillationSensitivity; }
243
245 void oscillationSensitivity(double x) {
246 if (x < 0) {
247 x = 0;
248 }
249 if (x > 1) {
250 x = 1;
251 }
252 m_oscillationSensitivity = x;
253 }
254
256 int attractionFormula() const { return m_attractionFormula; }
257
259 void attractionFormula(int n) {
260 if (n == 1 || n == 2) {
261 m_attractionFormula = n;
262 }
263 }
264
266 double minDistCC() const { return m_minDistCC; }
267
269 void minDistCC(double x) { m_minDistCC = x; }
270
272 double pageRatio() const { return m_pageRatio; }
273
275 void pageRatio(double x) { m_pageRatio = x; }
276
277
278private:
280 double length(double x, double y = 0) const { return sqrt(x * x + y * y); }
281
283 double weight(node v) const { return (double)(v->degree()) / 2.5 + 1.0; }
284
287
290
292};
293
294}
Includes declaration of graph class.
Declaration of interface for layout algorithms (class LayoutModule)
Mathematical Helpers.
Basic declarations, included by all source files.
The energy-based GEM layout algorithm.
Definition GEMLayout.h:108
double oscillationAngle() const
Returns the opening angle for oscillations.
Definition GEMLayout.h:214
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:242
double m_minimalTemperature
The minimal temperature.
Definition GEMLayout.h:112
void minimalTemperature(double x)
Sets the minimal temperature to x.
Definition GEMLayout.h:170
GEMLayout()
Creates an instance of GEM layout.
double rotationSensitivity() const
Returns the rotation sensitivity.
Definition GEMLayout.h:228
double m_pageRatio
The page ratio used for the layout of connected components.
Definition GEMLayout.h:123
NodeArray< double > m_localTemperature
local temperature of the node
Definition GEMLayout.h:129
double m_cos
Cosine of m_oscillationAngle / 2.
Definition GEMLayout.h:139
double minimalTemperature() const
Returns the minimal temperature.
Definition GEMLayout.h:167
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm for graph attributes GA.
double m_initialTemperature
The initial temperature.
Definition GEMLayout.h:113
void numberOfRounds(int n)
Sets the maximal number of round per node to n.
Definition GEMLayout.h:164
double m_rotationAngle
The opening angle for rotations.
Definition GEMLayout.h:117
double minDistCC() const
Returns the minimal distance between connected components.
Definition GEMLayout.h:266
std::minstd_rand m_rng
Definition GEMLayout.h:142
double m_rotationSensitivity
The rotation sensitivity.
Definition GEMLayout.h:119
double m_barycenterX
Weighted sum of x-coordinates of all nodes.
Definition GEMLayout.h:134
double m_minDistCC
The minimal distance between connected components.
Definition GEMLayout.h:122
NodeArray< double > m_impulseX
x-coordinate of the last impulse of the node
Definition GEMLayout.h:127
double initialTemperature() const
Returns the initial temperature.
Definition GEMLayout.h:173
double m_maximalDisturbance
The maximal disturbance.
Definition GEMLayout.h:116
void rotationAngle(double x)
Sets the opening angle for rotations to x (0 <= x <= pi / 2).
Definition GEMLayout.h:203
void maximalDisturbance(double x)
Sets the maximal disturbance to x; must be >= 0.
Definition GEMLayout.h:197
void oscillationSensitivity(double x)
Sets the oscillation sensitivity to x (0 <= x <= 1).
Definition GEMLayout.h:245
double m_oscillationSensitivity
The oscillation sensitivity.
Definition GEMLayout.h:120
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:161
double rotationAngle() const
Returns the opening angle for rotations.
Definition GEMLayout.h:200
void minDistCC(double x)
Sets the minimal distance between connected components to x.
Definition GEMLayout.h:269
void rotationSensitivity(double x)
Sets the rotation sensitivity to x (0 <= x <= 1).
Definition GEMLayout.h:231
void gravitationalConstant(double x)
Sets the gravitational constant to x; must be >= 0. Attention! Only (very) small values give acceptab...
Definition GEMLayout.h:185
double m_sin
Sine of (pi + m_rotationAngle) / 2.
Definition GEMLayout.h:140
void oscillationAngle(double x)
Sets the opening angle for oscillations to x (0 <= x <= pi / 2).
Definition GEMLayout.h:217
NodeArray< double > m_skewGauge
skew gauge of the node
Definition GEMLayout.h:130
int attractionFormula() const
Returns the used formula for attraction (1 = Fruchterman / Reingold, 2 = GEM).
Definition GEMLayout.h:256
double weight(node v) const
Returns the weight of node v according to its degree.
Definition GEMLayout.h:283
double m_newImpulseY
y-coordinate of the new impulse of the current node.
Definition GEMLayout.h:137
double m_oscillationAngle
The opening angle for oscillations.
Definition GEMLayout.h:118
double pageRatio() const
Returns the page ratio used for the layout of connected components.
Definition GEMLayout.h:272
void pageRatio(double x)
Sets the page ratio used for the layout of connected components to x.
Definition GEMLayout.h:275
double maximalDisturbance() const
Returns the maximal disturbance.
Definition GEMLayout.h:194
void initialTemperature(double x)
Sets the initial temperature to x; must be >= minimalTemperature.
Definition GEMLayout.h:176
double length(double x, double y=0) const
Returns the length of the vector (x,y).
Definition GEMLayout.h:280
double gravitationalConstant() const
Returns the gravitational constant.
Definition GEMLayout.h:181
void attractionFormula(int n)
sets the formula for attraction to n (1 = Fruchterman / Reingold, 2 = GEM).
Definition GEMLayout.h:259
GEMLayout(const GEMLayout &fl)
Copy constructor.
int m_attractionFormula
The used formula for attraction.
Definition GEMLayout.h:121
double desiredLength() const
Returns the desired edge length.
Definition GEMLayout.h:188
void desiredLength(double x)
Sets the desired edge length to x; must be >= 0.
Definition GEMLayout.h:191
int m_numberOfRounds
The maximal number of rounds per node.
Definition GEMLayout.h:111
double m_gravitationalConstant
The gravitational constant.
Definition GEMLayout.h:114
double m_desiredLength
The desired edge length.
Definition GEMLayout.h:115
double m_globalTemperature
Average of all node temperatures.
Definition GEMLayout.h:138
double m_barycenterY
Weighted sum of y-coordinates of all nodes.
Definition GEMLayout.h:135
double m_newImpulseX
x-coordinate of the new impulse of the current node.
Definition GEMLayout.h:136
NodeArray< double > m_impulseY
y-coordinate of the last impulse of the node
Definition GEMLayout.h:128
Stores additional attributes of a graph (like layout information).
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:390
Interface of general layout algorithms.
Class for the representation of nodes.
Definition Graph_d.h:241
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition Graph_d.h:284
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition memory.h:85
Declaration of memory manager for allocating small pieces of memory.
The namespace for all OGDF objects.