Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GEMLayout.h
Go to the documentation of this file.
1 
35 #pragma once
36 
38 #include <ogdf/basic/GraphCopy.h>
40 #include <ogdf/basic/Math.h>
41 
42 #include <random>
43 
44 namespace 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 
130  double m_barycenterX;
131  double m_barycenterY;
132  double m_newImpulseX;
133  double m_newImpulseY;
135  double m_cos;
136  double m_sin;
137 
138  std::minstd_rand m_rng;
139 
140 public:
142  GEMLayout();
143 
145  GEMLayout(const GEMLayout& fl);
146 
147  // destructor
148  ~GEMLayout();
149 
151  GEMLayout& operator=(const GEMLayout& fl);
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 
274 private:
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 
282  void computeImpulse(GraphCopy& GC, GraphAttributes& AGC, node v);
283 
285  void updateNode(GraphCopy& GC, GraphAttributes& AGC, node v);
286 
288 };
289 
290 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::GEMLayout::m_barycenterY
double m_barycenterY
Weighted sum of y-coordinates of all nodes.
Definition: GEMLayout.h:131
ogdf::GEMLayout::oscillationSensitivity
void oscillationSensitivity(double x)
Sets the oscillation sensitivity to x (0 <= x <= 1).
Definition: GEMLayout.h:241
ogdf::GEMLayout::initialTemperature
void initialTemperature(double x)
Sets the initial temperature to x; must be >= minimalTemperature.
Definition: GEMLayout.h:172
ogdf::GEMLayout::m_desiredLength
double m_desiredLength
The desired edge length.
Definition: GEMLayout.h:111
ogdf::GEMLayout::m_rotationSensitivity
double m_rotationSensitivity
The rotation sensitivity.
Definition: GEMLayout.h:115
ogdf::GEMLayout::oscillationSensitivity
double oscillationSensitivity() const
Returns the oscillation sensitivity.
Definition: GEMLayout.h:238
ogdf::GEMLayout::maximalDisturbance
double maximalDisturbance() const
Returns the maximal disturbance.
Definition: GEMLayout.h:190
ogdf::GEMLayout::pageRatio
void pageRatio(double x)
Sets the page ratio used for the layout of connected components to x.
Definition: GEMLayout.h:271
ogdf::GEMLayout::rotationSensitivity
double rotationSensitivity() const
Returns the rotation sensitivity.
Definition: GEMLayout.h:224
ogdf::GEMLayout::m_attractionFormula
int m_attractionFormula
The used formula for attraction.
Definition: GEMLayout.h:117
ogdf::GEMLayout::m_maximalDisturbance
double m_maximalDisturbance
The maximal disturbance.
Definition: GEMLayout.h:112
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:181
ogdf::GEMLayout::numberOfRounds
int numberOfRounds() const
Returns the maximal number of rounds per node.
Definition: GEMLayout.h:157
ogdf::GEMLayout::initialTemperature
double initialTemperature() const
Returns the initial temperature.
Definition: GEMLayout.h:169
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:384
ogdf::GEMLayout::m_oscillationSensitivity
double m_oscillationSensitivity
The oscillation sensitivity.
Definition: GEMLayout.h:116
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:193
ogdf::GEMLayout::m_newImpulseY
double m_newImpulseY
y-coordinate of the new impulse of the current node.
Definition: GEMLayout.h:133
ogdf::GEMLayout::rotationAngle
void rotationAngle(double x)
Sets the opening angle for rotations to x (0 <= x <= pi / 2).
Definition: GEMLayout.h:199
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:84
ogdf::GEMLayout
The energy-based GEM layout algorithm.
Definition: GEMLayout.h:104
ogdf::GEMLayout::desiredLength
double desiredLength() const
Returns the desired edge length.
Definition: GEMLayout.h:184
ogdf::GEMLayout::m_minDistCC
double m_minDistCC
The minimal distance between connected components.
Definition: GEMLayout.h:118
ogdf::GEMLayout::m_sin
double m_sin
Sine of (pi + m_rotationAngle) / 2.
Definition: GEMLayout.h:136
ogdf::GEMLayout::rotationSensitivity
void rotationSensitivity(double x)
Sets the rotation sensitivity to x (0 <= x <= 1).
Definition: GEMLayout.h:227
ogdf::NodeElement::degree
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:276
ogdf::GEMLayout::minDistCC
double minDistCC() const
Returns the minimal distance between connected components.
Definition: GEMLayout.h:262
ogdf::GEMLayout::desiredLength
void desiredLength(double x)
Sets the desired edge length to x; must be >= 0.
Definition: GEMLayout.h:187
ogdf::GEMLayout::minimalTemperature
void minimalTemperature(double x)
Sets the minimal temperature to x.
Definition: GEMLayout.h:166
ogdf::GEMLayout::m_oscillationAngle
double m_oscillationAngle
The opening angle for oscillations.
Definition: GEMLayout.h:114
ogdf::GEMLayout::m_impulseX
NodeArray< double > m_impulseX
x-coordinate of the last impulse of the node
Definition: GEMLayout.h:123
ogdf::GEMLayout::numberOfRounds
void numberOfRounds(int n)
Sets the maximal number of round per node to n.
Definition: GEMLayout.h:160
ogdf::GEMLayout::m_rng
std::minstd_rand m_rng
Definition: GEMLayout.h:138
ogdf::GEMLayout::gravitationalConstant
double gravitationalConstant() const
Returns the gravitational constant.
Definition: GEMLayout.h:177
ogdf::GEMLayout::m_rotationAngle
double m_rotationAngle
The opening angle for rotations.
Definition: GEMLayout.h:113
GraphCopy.h
Declaration of graph copy classes.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::GEMLayout::m_impulseY
NodeArray< double > m_impulseY
y-coordinate of the last impulse of the node
Definition: GEMLayout.h:124
ogdf::GEMLayout::m_newImpulseX
double m_newImpulseX
x-coordinate of the new impulse of the current node.
Definition: GEMLayout.h:132
ogdf::GEMLayout::weight
double weight(node v) const
Returns the weight of node v according to its degree.
Definition: GEMLayout.h:279
ogdf::Math::pi
constexpr double pi
The constant .
Definition: Math.h:59
ogdf::GEMLayout::m_barycenterX
double m_barycenterX
Weighted sum of x-coordinates of all nodes.
Definition: GEMLayout.h:130
ogdf::GEMLayout::m_globalTemperature
double m_globalTemperature
Average of all node temperatures.
Definition: GEMLayout.h:134
ogdf::GEMLayout::attractionFormula
int attractionFormula() const
Returns the used formula for attraction (1 = Fruchterman / Reingold, 2 = GEM).
Definition: GEMLayout.h:252
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:255
ogdf::GEMLayout::m_localTemperature
NodeArray< double > m_localTemperature
local temperature of the node
Definition: GEMLayout.h:125
ogdf::GEMLayout::minDistCC
void minDistCC(double x)
Sets the minimal distance between connected components to x.
Definition: GEMLayout.h:265
ogdf::GEMLayout::pageRatio
double pageRatio() const
Returns the page ratio used for the layout of connected components.
Definition: GEMLayout.h:268
ogdf::GEMLayout::m_initialTemperature
double m_initialTemperature
The initial temperature.
Definition: GEMLayout.h:109
ogdf::GEMLayout::length
double length(double x, double y=0) const
Returns the length of the vector (x,y).
Definition: GEMLayout.h:276
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:107
ogdf::GEMLayout::oscillationAngle
void oscillationAngle(double x)
Sets the opening angle for oscillations to x (0 <= x <= pi / 2).
Definition: GEMLayout.h:213
ogdf::GEMLayout::rotationAngle
double rotationAngle() const
Returns the opening angle for rotations.
Definition: GEMLayout.h:196
ogdf::GEMLayout::m_gravitationalConstant
double m_gravitationalConstant
The gravitational constant.
Definition: GEMLayout.h:110
ogdf::GEMLayout::m_cos
double m_cos
Cosine of m_oscillationAngle / 2.
Definition: GEMLayout.h:135
ogdf::GEMLayout::minimalTemperature
double minimalTemperature() const
Returns the minimal temperature.
Definition: GEMLayout.h:163
ogdf::GEMLayout::oscillationAngle
double oscillationAngle() const
Returns the opening angle for oscillations.
Definition: GEMLayout.h:210
ogdf::GEMLayout::m_pageRatio
double m_pageRatio
The page ratio used for the layout of connected components.
Definition: GEMLayout.h:119
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::GEMLayout::m_skewGauge
NodeArray< double > m_skewGauge
skew gauge of the node
Definition: GEMLayout.h:126
ogdf::GEMLayout::m_minimalTemperature
double m_minimalTemperature
The minimal temperature.
Definition: GEMLayout.h:108
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:44