Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
46 namespace ogdf {
47 class GraphAttributes;
48 class 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 
134  double m_barycenterX;
135  double m_barycenterY;
136  double m_newImpulseX;
137  double m_newImpulseY;
139  double m_cos;
140  double m_sin;
141 
142  std::minstd_rand m_rng;
143 
144 public:
146  GEMLayout();
147 
149  GEMLayout(const GEMLayout& fl);
150 
151  // destructor
152  ~GEMLayout();
153 
155  GEMLayout& operator=(const GEMLayout& fl);
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 
278 private:
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 
286  void computeImpulse(GraphCopy& GC, GraphAttributes& AGC, node v);
287 
289  void updateNode(GraphCopy& GC, GraphAttributes& AGC, node v);
290 
292 };
293 
294 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
ogdf::GEMLayout::m_barycenterY
double m_barycenterY
Weighted sum of y-coordinates of all nodes.
Definition: GEMLayout.h:135
ogdf::GEMLayout::oscillationSensitivity
void oscillationSensitivity(double x)
Sets the oscillation sensitivity to x (0 <= x <= 1).
Definition: GEMLayout.h:245
Graph.h
Includes declaration of graph class.
ogdf::GEMLayout::initialTemperature
void initialTemperature(double x)
Sets the initial temperature to x; must be >= minimalTemperature.
Definition: GEMLayout.h:176
ogdf::GEMLayout::m_desiredLength
double m_desiredLength
The desired edge length.
Definition: GEMLayout.h:115
ogdf::GEMLayout::m_rotationSensitivity
double m_rotationSensitivity
The rotation sensitivity.
Definition: GEMLayout.h:119
ogdf::GEMLayout::oscillationSensitivity
double oscillationSensitivity() const
Returns the oscillation sensitivity.
Definition: GEMLayout.h:242
ogdf::GEMLayout::maximalDisturbance
double maximalDisturbance() const
Returns the maximal disturbance.
Definition: GEMLayout.h:194
ogdf::GEMLayout::pageRatio
void pageRatio(double x)
Sets the page ratio used for the layout of connected components to x.
Definition: GEMLayout.h:275
ogdf::GEMLayout::rotationSensitivity
double rotationSensitivity() const
Returns the rotation sensitivity.
Definition: GEMLayout.h:228
ogdf::GEMLayout::m_attractionFormula
int m_attractionFormula
The used formula for attraction.
Definition: GEMLayout.h:121
ogdf::GEMLayout::m_maximalDisturbance
double m_maximalDisturbance
The maximal disturbance.
Definition: GEMLayout.h:116
ogdf::GEMLayout::gravitationalConstant
void gravitationalConstant(double x)
Sets the gravitational constant to x; must be >= 0. Attention! Only (very) small values give acceptab...
Definition: GEMLayout.h:185
ogdf::GEMLayout::numberOfRounds
int numberOfRounds() const
Returns the maximal number of rounds per node.
Definition: GEMLayout.h:161
ogdf::GEMLayout::initialTemperature
double initialTemperature() const
Returns the initial temperature.
Definition: GEMLayout.h:173
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:391
ogdf::GEMLayout::m_oscillationSensitivity
double m_oscillationSensitivity
The oscillation sensitivity.
Definition: GEMLayout.h:120
LayoutModule.h
Declaration of interface for layout algorithms (class LayoutModule)
ogdf::GEMLayout::maximalDisturbance
void maximalDisturbance(double x)
Sets the maximal disturbance to x; must be >= 0.
Definition: GEMLayout.h:197
ogdf::GEMLayout::m_newImpulseY
double m_newImpulseY
y-coordinate of the new impulse of the current node.
Definition: GEMLayout.h:137
ogdf::GEMLayout::rotationAngle
void rotationAngle(double x)
Sets the opening angle for rotations to x (0 <= x <= pi / 2).
Definition: GEMLayout.h:203
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:85
ogdf::GEMLayout
The energy-based GEM layout algorithm.
Definition: GEMLayout.h:108
ogdf::GEMLayout::desiredLength
double desiredLength() const
Returns the desired edge length.
Definition: GEMLayout.h:188
ogdf::GEMLayout::m_minDistCC
double m_minDistCC
The minimal distance between connected components.
Definition: GEMLayout.h:122
ogdf::GEMLayout::m_sin
double m_sin
Sine of (pi + m_rotationAngle) / 2.
Definition: GEMLayout.h:140
ogdf::GEMLayout::rotationSensitivity
void rotationSensitivity(double x)
Sets the rotation sensitivity to x (0 <= x <= 1).
Definition: GEMLayout.h:231
ogdf::NodeElement::degree
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:283
ogdf::GEMLayout::minDistCC
double minDistCC() const
Returns the minimal distance between connected components.
Definition: GEMLayout.h:266
ogdf::GEMLayout::desiredLength
void desiredLength(double x)
Sets the desired edge length to x; must be >= 0.
Definition: GEMLayout.h:191
ogdf::GEMLayout::minimalTemperature
void minimalTemperature(double x)
Sets the minimal temperature to x.
Definition: GEMLayout.h:170
ogdf::GEMLayout::m_oscillationAngle
double m_oscillationAngle
The opening angle for oscillations.
Definition: GEMLayout.h:118
ogdf::GEMLayout::m_impulseX
NodeArray< double > m_impulseX
x-coordinate of the last impulse of the node
Definition: GEMLayout.h:127
ogdf::GEMLayout::numberOfRounds
void numberOfRounds(int n)
Sets the maximal number of round per node to n.
Definition: GEMLayout.h:164
ogdf::GEMLayout::m_rng
std::minstd_rand m_rng
Definition: GEMLayout.h:142
ogdf::GEMLayout::gravitationalConstant
double gravitationalConstant() const
Returns the gravitational constant.
Definition: GEMLayout.h:181
ogdf::GEMLayout::m_rotationAngle
double m_rotationAngle
The opening angle for rotations.
Definition: GEMLayout.h:117
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::GEMLayout::m_impulseY
NodeArray< double > m_impulseY
y-coordinate of the last impulse of the node
Definition: GEMLayout.h:128
ogdf::GEMLayout::m_newImpulseX
double m_newImpulseX
x-coordinate of the new impulse of the current node.
Definition: GEMLayout.h:136
ogdf::GEMLayout::weight
double weight(node v) const
Returns the weight of node v according to its degree.
Definition: GEMLayout.h:283
ogdf::Math::pi
constexpr double pi
The constant .
Definition: Math.h:63
ogdf::GEMLayout::m_barycenterX
double m_barycenterX
Weighted sum of x-coordinates of all nodes.
Definition: GEMLayout.h:134
ogdf::GEMLayout::m_globalTemperature
double m_globalTemperature
Average of all node temperatures.
Definition: GEMLayout.h:138
ogdf::GEMLayout::attractionFormula
int attractionFormula() const
Returns the used formula for attraction (1 = Fruchterman / Reingold, 2 = GEM).
Definition: GEMLayout.h:256
Math.h
Mathematical Helpers.
ogdf::GEMLayout::attractionFormula
void attractionFormula(int n)
sets the formula for attraction to n (1 = Fruchterman / Reingold, 2 = GEM).
Definition: GEMLayout.h:259
ogdf::GEMLayout::m_localTemperature
NodeArray< double > m_localTemperature
local temperature of the node
Definition: GEMLayout.h:129
ogdf::GEMLayout::minDistCC
void minDistCC(double x)
Sets the minimal distance between connected components to x.
Definition: GEMLayout.h:269
ogdf::GEMLayout::pageRatio
double pageRatio() const
Returns the page ratio used for the layout of connected components.
Definition: GEMLayout.h:272
ogdf::GEMLayout::m_initialTemperature
double m_initialTemperature
The initial temperature.
Definition: GEMLayout.h:113
basic.h
Basic declarations, included by all source files.
ogdf::GEMLayout::length
double length(double x, double y=0) const
Returns the length of the vector (x,y).
Definition: GEMLayout.h:280
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::GEMLayout::m_numberOfRounds
int m_numberOfRounds
The maximal number of rounds per node.
Definition: GEMLayout.h:111
ogdf::GEMLayout::oscillationAngle
void oscillationAngle(double x)
Sets the opening angle for oscillations to x (0 <= x <= pi / 2).
Definition: GEMLayout.h:217
ogdf::GEMLayout::rotationAngle
double rotationAngle() const
Returns the opening angle for rotations.
Definition: GEMLayout.h:200
ogdf::GEMLayout::m_gravitationalConstant
double m_gravitationalConstant
The gravitational constant.
Definition: GEMLayout.h:114
ogdf::GEMLayout::m_cos
double m_cos
Cosine of m_oscillationAngle / 2.
Definition: GEMLayout.h:139
ogdf::GEMLayout::minimalTemperature
double minimalTemperature() const
Returns the minimal temperature.
Definition: GEMLayout.h:167
ogdf::GEMLayout::oscillationAngle
double oscillationAngle() const
Returns the opening angle for oscillations.
Definition: GEMLayout.h:214
ogdf::GEMLayout::m_pageRatio
double m_pageRatio
The page ratio used for the layout of connected components.
Definition: GEMLayout.h:123
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::GEMLayout::m_skewGauge
NodeArray< double > m_skewGauge
skew gauge of the node
Definition: GEMLayout.h:130
memory.h
Declaration of memory manager for allocating small pieces of memory.
ogdf::GEMLayout::m_minimalTemperature
double m_minimalTemperature
The minimal temperature.
Definition: GEMLayout.h:112
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:45