Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

GEMLayout.h
Go to the documentation of this file.
1 
35 #pragma once
36 
38 #include <ogdf/basic/Math.h>
40 #include <ogdf/basic/GraphCopy.h>
41 #include <random>
42 
43 namespace ogdf {
44 
46 
104 {
105 
106  // algorithm parameters (see below)
107 
119  double m_minDistCC;
120  double m_pageRatio;
121 
122  // node data used by the algorithm
123 
128 
129  // other data used by the algorithm
130 
131  double m_barycenterX;
132  double m_barycenterY;
133  double m_newImpulseX;
134  double m_newImpulseY;
136  double m_cos;
137  double m_sin;
138 
139  std::minstd_rand m_rng;
140 
141 public:
142 
144  GEMLayout();
145 
147  GEMLayout(const GEMLayout &fl);
148 
149  // destructor
150  ~GEMLayout();
151 
153  GEMLayout &operator=(const GEMLayout &fl);
154 
156  virtual void call(GraphAttributes &GA) override;
157 
159  int numberOfRounds() const { return m_numberOfRounds; }
160 
162  void numberOfRounds(int n) {
163  m_numberOfRounds = (n < 0) ? 0 : n;
164  }
165 
167  double minimalTemperature() const { return m_minimalTemperature; }
168 
170  void minimalTemperature(double x) {
171  m_minimalTemperature = (x < 0) ? 0 : x;
172  }
173 
175  double initialTemperature() const { return m_initialTemperature; }
176 
178  void initialTemperature(double x) {
179  m_initialTemperature = (x < m_minimalTemperature) ? m_minimalTemperature : x;
180  }
181 
183  double gravitationalConstant() const { return m_gravitationalConstant; }
184 
187  void gravitationalConstant(double x) {
188  m_gravitationalConstant = (x < 0) ? 0 : x;
189  }
190 
192  double desiredLength() const { return m_desiredLength; }
193 
195  void desiredLength(double x) {
196  m_desiredLength = (x < 0) ? 0 : x;
197  }
198 
200  double maximalDisturbance() const { return m_maximalDisturbance; }
201 
203  void maximalDisturbance(double x) {
204  m_maximalDisturbance = (x < 0) ? 0 : x;
205  }
206 
208  double rotationAngle() const { return m_rotationAngle; }
209 
211  void rotationAngle(double x) {
212  if(x < 0) x = 0;
213  if(x > Math::pi / 2.0) x = Math::pi / 2.0;
214  m_rotationAngle = x;
215  }
216 
218  double oscillationAngle() const { return m_oscillationAngle; }
219 
221  void oscillationAngle(double x) {
222  if(x < 0) x = 0;
223  if(x > Math::pi / 2.0) x = Math::pi / 2.0;
224  m_oscillationAngle = x;
225  }
226 
228  double rotationSensitivity() const { return m_rotationSensitivity; }
229 
231  void rotationSensitivity(double x) {
232  if(x < 0) x = 0;
233  if(x > 1) x = 1;
234  m_rotationSensitivity = x;
235  }
236 
238  double oscillationSensitivity() const { return m_oscillationSensitivity; }
239 
241  void oscillationSensitivity(double x) {
242  if(x < 0) x = 0;
243  if(x > 1) x = 1;
244  m_oscillationSensitivity = x;
245  }
246 
248  int attractionFormula() const { return m_attractionFormula; }
249 
251  void attractionFormula(int n) {
252  if(n == 1 || n == 2) m_attractionFormula = n;
253  }
254 
256  double minDistCC() const { return m_minDistCC; }
257 
259  void minDistCC(double x) { m_minDistCC = x; }
260 
262  double pageRatio() const { return m_pageRatio; }
263 
265  void pageRatio(double x) { m_pageRatio = x; }
266 
267 
268 private:
270  double length(double x,double y = 0) const {
271  return sqrt(x * x + y * y);
272  }
273 
275  double weight(node v) const {
276  return (double)(v->degree()) / 2.5 + 1.0;
277  }
278 
280  void computeImpulse(GraphCopy &GC, GraphAttributes &AGC,node v);
281 
283  void updateNode(GraphCopy &GC, GraphAttributes &AGC,node v);
284 
286 };
287 
288 }
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:67
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:132
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:178
ogdf::GEMLayout::m_desiredLength
double m_desiredLength
The desired edge length.
Definition: GEMLayout.h:112
ogdf::GEMLayout::m_rotationSensitivity
double m_rotationSensitivity
The rotation sensitivity.
Definition: GEMLayout.h:116
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:200
ogdf::GEMLayout::pageRatio
void pageRatio(double x)
Sets the page ratio used for the layout of connected components to x.
Definition: GEMLayout.h:265
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:118
ogdf::GEMLayout::m_maximalDisturbance
double m_maximalDisturbance
The maximal disturbance.
Definition: GEMLayout.h:113
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:187
ogdf::GEMLayout::numberOfRounds
int numberOfRounds() const
Returns the maximal number of rounds per node.
Definition: GEMLayout.h:159
ogdf::GEMLayout::initialTemperature
double initialTemperature() const
Returns the initial temperature.
Definition: GEMLayout.h:175
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:255
ogdf::GEMLayout::m_oscillationSensitivity
double m_oscillationSensitivity
The oscillation sensitivity.
Definition: GEMLayout.h:117
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:203
ogdf::GEMLayout::m_newImpulseY
double m_newImpulseY
y-coordinate of the new impulse of the current node.
Definition: GEMLayout.h:134
ogdf::GEMLayout::rotationAngle
void rotationAngle(double x)
Sets the opening angle for rotations to x (0 <= x <= pi / 2).
Definition: GEMLayout.h:211
ogdf::NodeArray< double >
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:103
ogdf::GEMLayout::desiredLength
double desiredLength() const
Returns the desired edge length.
Definition: GEMLayout.h:192
ogdf::GEMLayout::m_minDistCC
double m_minDistCC
The minimal distance between connected components.
Definition: GEMLayout.h:119
ogdf::GEMLayout::m_sin
double m_sin
Sine of (pi + m_rotationAngle) / 2.
Definition: GEMLayout.h:137
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:210
ogdf::GEMLayout::minDistCC
double minDistCC() const
Returns the minimal distance between connected components.
Definition: GEMLayout.h:256
ogdf::GEMLayout::desiredLength
void desiredLength(double x)
Sets the desired edge length to x; must be >= 0.
Definition: GEMLayout.h:195
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:115
ogdf::GEMLayout::m_impulseX
NodeArray< double > m_impulseX
x-coordinate of the last impulse of the node
Definition: GEMLayout.h:124
ogdf::GEMLayout::numberOfRounds
void numberOfRounds(int n)
Sets the maximal number of round per node to n.
Definition: GEMLayout.h:162
Math.h
Mathematical Helpers.
ogdf::GEMLayout::m_rng
std::minstd_rand m_rng
Definition: GEMLayout.h:139
ogdf::GEMLayout::gravitationalConstant
double gravitationalConstant() const
Returns the gravitational constant.
Definition: GEMLayout.h:183
ogdf::GEMLayout::m_rotationAngle
double m_rotationAngle
The opening angle for rotations.
Definition: GEMLayout.h:114
GraphCopy.h
Declaration of graph copy classes.
ogdf::GEMLayout::m_impulseY
NodeArray< double > m_impulseY
y-coordinate of the last impulse of the node
Definition: GEMLayout.h:125
ogdf::GEMLayout::m_newImpulseX
double m_newImpulseX
x-coordinate of the new impulse of the current node.
Definition: GEMLayout.h:133
ogdf::GEMLayout::weight
double weight(node v) const
Returns the weight of node v according to its degree.
Definition: GEMLayout.h:275
ogdf::Math::pi
constexpr double pi
The constant .
Definition: Math.h:62
ogdf::GEMLayout::m_barycenterX
double m_barycenterX
Weighted sum of x-coordinates of all nodes.
Definition: GEMLayout.h:131
ogdf::GEMLayout::m_globalTemperature
double m_globalTemperature
Average of all node temperatures.
Definition: GEMLayout.h:135
ogdf::GEMLayout::attractionFormula
int attractionFormula() const
Returns the used formula for attraction (1 = Fruchterman / Reingold, 2 = GEM).
Definition: GEMLayout.h:248
ogdf::GEMLayout::attractionFormula
void attractionFormula(int n)
sets the formula for attraction to n (1 = Fruchterman / Reingold, 2 = GEM).
Definition: GEMLayout.h:251
ogdf::GEMLayout::m_localTemperature
NodeArray< double > m_localTemperature
local temperature of the node
Definition: GEMLayout.h:126
ogdf::GEMLayout::minDistCC
void minDistCC(double x)
Sets the minimal distance between connected components to x.
Definition: GEMLayout.h:259
ogdf::GEMLayout::pageRatio
double pageRatio() const
Returns the page ratio used for the layout of connected components.
Definition: GEMLayout.h:262
ogdf::GEMLayout::m_initialTemperature
double m_initialTemperature
The initial temperature.
Definition: GEMLayout.h:110
ogdf::GEMLayout::length
double length(double x, double y=0) const
Returns the length of the vector (x,y).
Definition: GEMLayout.h:270
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
ogdf::GEMLayout::m_numberOfRounds
int m_numberOfRounds
The maximal number of rounds per node.
Definition: GEMLayout.h:108
ogdf::GEMLayout::oscillationAngle
void oscillationAngle(double x)
Sets the opening angle for oscillations to x (0 <= x <= pi / 2).
Definition: GEMLayout.h:221
ogdf::GEMLayout::rotationAngle
double rotationAngle() const
Returns the opening angle for rotations.
Definition: GEMLayout.h:208
ogdf::GEMLayout::m_gravitationalConstant
double m_gravitationalConstant
The gravitational constant.
Definition: GEMLayout.h:111
ogdf::GEMLayout::m_cos
double m_cos
Cosine of m_oscillationAngle / 2.
Definition: GEMLayout.h:136
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:218
ogdf::GEMLayout::m_pageRatio
double m_pageRatio
The page ratio used for the layout of connected components.
Definition: GEMLayout.h:120
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:169
ogdf::GEMLayout::m_skewGauge
NodeArray< double > m_skewGauge
skew gauge of the node
Definition: GEMLayout.h:127
ogdf::GEMLayout::m_minimalTemperature
double m_minimalTemperature
The minimal temperature.
Definition: GEMLayout.h:109
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:44