Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
NodeRespecterLayout.h
Go to the documentation of this file.
1
36#pragma once
37
40
41namespace ogdf {
42
44
86public:
89
92
94 virtual void call(GraphAttributes& attr) override;
95
98 enum class PostProcessingMode {
99 None,
100 KeepMultiEdgeBends,
103 Complete
105 };
106
109
112
115
118
120 void setNumberOfIterations(int numberOfIterations);
121
123 void setMinimalTemperature(double minimalTemperature);
124
127 void setInitialTemperature(double initialTemperature);
128
132
135
137 void setOscillationAngle(double oscillationAngle);
138
141
144
148
151
154
157
159 void setMinDistCC(double minDistCC);
160
162 void setPageRatio(double pageRatio);
163
167
169 bool getRandomInitialPlacement() const { return m_randomInitialPlacement; }
170
172 PostProcessingMode getPostProcessing() const { return m_postProcessing; }
173
175 double getBendNormalizationAngle() const { return m_bendNormalizationAngle; }
176
178 int getNumberOfIterations() const { return m_numberOfIterations; }
179
181 double getMinimalTemperature() const { return m_minimalTemperature; }
182
184 double getInitialTemperature() const { return m_initialTemperature; }
185
187 double getTemperatureDecreaseOffset() const { return m_temperatureDecreaseOffset; }
188
190 double getGravitation() const { return m_gravitation; }
191
193 double getOscillationAngle() const { return m_oscillationAngle; }
194
196 double getDesiredMinEdgeLength() const { return m_desiredMinEdgeLength; }
197
199 int getInitDummiesPerEdge() const { return m_initDummiesPerEdge; }
200
202 int getMaxDummiesPerEdge() const { return m_maxDummiesPerEdge; }
203
205 double getDummyInsertionThreshold() const { return m_dummyInsertionThreshold; }
206
208 double getMaxDisturbance() const { return m_maxDisturbance; }
209
211 double getRepulsionDistance() const { return m_repulsionDistance; }
212
214 double getMinDistCC() const { return m_minDistCC; }
215
217 double getPageRatio() const { return m_pageRatio; }
218
220
221private:
224
227
230
234
237
240
243
248
251
255
258
261
264
268
271
275
278
281
285
288
291
294
297
300
303
306
309
313
316
319
322
325
328
330 double m_factor;
331
333 double m_cos;
334
336
338 void initData();
339
341 void freeData();
342
345
350
352 std::pair<double, double> computeImpulse(node v);
353
356 void updateNode(node v, std::pair<double, double> newImpulse);
357
360
363 inline double radius(const GraphAttributes& attr, node v) const {
364 switch (attr.shape(v)) {
365 case Shape::Pentagon:
366 case Shape::Octagon:
367 case Shape::Hexagon:
368 case Shape::Rhomb:
369 case Shape::Ellipse:
370 return std::max(attr.height(v), attr.width(v)) / 2.0;
371
372 default:
373 // For Rect, RoundedRect, Triangle, Trapeze, Parallelogram, InvTriangle,
374 // InvTrapeze, InvParallelogram, Image and unknown shapes.
375 return std::hypot(attr.height(v), attr.width(v)) / 2.0;
376 }
377 }
378
383 inline bool haveSameOriginalEdge(node v, node w) const {
384 if (m_copy.isDummy(v) && m_copy.isDummy(w)) {
385 return m_copy.original(v->firstAdj()->theEdge())
386 == m_copy.original(w->firstAdj()->theEdge());
387 } else if (m_copy.isDummy(v)) {
388 return m_copy.original(v->firstAdj()->theEdge())->isIncident(w);
389 } else if (m_copy.isDummy(w)) {
390 return m_copy.original(w->firstAdj()->theEdge())->isIncident(v);
391 } else {
392 return false;
393 }
394 }
395
397 inline double weight(node v) const { return v->degree() / m_degreeSum; }
398
400};
401
402}
Declaration of graph copy classes.
Declaration of interface for layout algorithms (class LayoutModule)
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition Graph_d.h:97
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:56
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Stores additional attributes of a graph (like layout information).
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:254
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition GraphCopy.h:380
const Graph & original() const
Returns a reference to the original graph.
Definition GraphCopy.h:289
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
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition Graph_d.h:223
The NodeRespecterLayout layout algorithm.
int m_numberOfIterations
Number of times a single node is moved for each connected component.
double getOscillationAngle() const
Returns m_oscillationAngle.
void setPostProcessing(PostProcessingMode postProcessing)
Sets m_postProcessing to postProcessing.
NodeArray< double > m_localTemperature
Local temperature of the node.
double getRepulsionDistance() const
Returns m_repulsionDistance.
double getGravitation() const
Returns m_gravitation.
double m_oscillationAngle
Maximum angle between new and previous impulse such that the node movement is counted as an oscillati...
NodeArray< NodeArray< double > > m_desiredDistance
Desired distance between each pair of nodes.
double m_initialTemperature
Initial temperature of every node.
void freeData()
Frees all graph data used by the algorithm.
double m_repulsionDistance
Maximum distance between a dummy and another node such that the former is repulsed by the latter.
PostProcessingMode getPostProcessing() const
Returns m_postProcessing.
int getInitDummiesPerEdge() const
Returns m_initDummiesPerEdge.
void setGravitation(double gravitation)
Sets m_gravitation to gravitation >= 0.
void setDummyInsertionThreshold(double dummyInsertionThreshold)
Sets m_dummyInsertionThreshold to dummyInsertionThreshold >= 1.
double m_bendNormalizationAngle
Lower bound for the minimum angle between two line segments such that the bend point between them is ...
double getMinimalTemperature() const
Returns m_minimalTemperature.
double getTemperatureDecreaseOffset() const
Returns m_temperatureDecreaseOffset.
PostProcessingMode
Sets whether unnecessary edge bends should be filtered out in a post-processing step.
int m_initDummiesPerEdge
How many dummy nodes should initially be created for one edge.
void setOscillationAngle(double oscillationAngle)
Sets m_oscillationAngle to oscillationAngle in [0...Pi].
~NodeRespecterLayout()
Destroys an instance of the NodeRespecterLayout.
virtual void call(GraphAttributes &attr) override
Calls the layout algorithm for the GraphAttributes attr.
double m_minimalTemperature
Minimal temperature, lower bound for the global temperature.
double m_factor
Precomputed constant used to get the max. temperature for each iteration.
double m_cos
Precomputed cosinus of (m_oscillationAngle / 2).
void setMinDistCC(double minDistCC)
Sets m_minDistCC to minDistCC >= 0.
NodeRespecterLayout()
Creates an instance of the NodeRespecterLayout.
void addDummies(node v, SListPure< node > &nodes)
Adds dummy nodes to incident edges of v if they are too long.
void setPageRatio(double pageRatio)
Sets m_pageRatio to pageRatio > 0.
double m_globalTemperature
Average of all local node temperatures.
double m_maxDisturbance
Maximal disturbance, i.e. maximal random node movement.
void setRepulsionDistance(double repulsionDistance)
Sets m_repulsionDistance to repulsionDistance >= 0.
double radius(const GraphAttributes &attr, node v) const
Returns the radius of the smallest circle surrounding the shape of v (while still having its center a...
int getMaxDummiesPerEdge() const
Returns m_maxDummiesPerEdge.
void setMaxDisturbance(double maxDisturbance)
Sets m_maxDisturbance to maxDisturbance >= 0.
int getNumberOfIterations() const
Returns m_numberOfIterations.
double getDummyInsertionThreshold() const
Returns m_dummyInsertionThreshold.
int m_degreeSum
Twice the number of all edges in the original graph.
void setRandomInitialPlacement(bool randomInitialPlacement)
Sets m_randomInitialPlacement to randomInitialPlacement.
int m_maxDummiesPerEdge
How many dummy nodes should maximally be created for one edge.
bool m_randomInitialPlacement
Whether nodes should be initialized in random positions.
GraphCopy m_copy
Copy of the given graph which may contain dummy nodes.
void createBends(const ArrayBuffer< edge > &origEdges, GraphAttributes &attr)
Creates bends in attr at the coordinates of dummy nodes in copy.
double m_dummyInsertionThreshold
How many times larger than the desired edge length an edge has to be in order for a new dummy node to...
void setMaxDummiesPerEdge(int maxDummiesPerEdge)
Sets m_maxDummiesPerEdge to maxDummiesPerEdge > m_initDummiesPerEdge.
NodeArray< double > m_impulseX
X-coordinate of the last impulse of the node.
void setInitDummiesPerEdge(int initDummiesPerEdge)
Sets m_initDummiesPerEdge to initDummiesPerEdge >= 0.
int m_iterCounter
Number of iterations for which the algorithm still has to run.
double getBendNormalizationAngle() const
Returns m_bendNormalizationAngle.
void updateNode(node v, std::pair< double, double > newImpulse)
Updates the node data for node v using newImpulse as the x- and y-coordinate of the new impulse onto ...
double m_temperatureDecreaseOffset
Factor for which holds: If only m_numberOfIterations * m_temperatureDecreaseOffset iterations are lef...
double weight(node v) const
Returns the weight of node v according to its degree.
void setDesiredMinEdgeLength(double desiredMinEdgeLength)
Sets m_desiredMinEdgeLength to desiredMinEdgeLength > 0.
double m_barycenterY
Weighted sum of y-coordinates of all nodes.
double getInitialTemperature() const
Returns m_initialTemperature.
void setTemperatureDecreaseOffset(double temperatureDecreaseOffset)
Sets m_temperatureDecreaseOffset to temperatureDecreaseOffset in [0...1].
void setNumberOfIterations(int numberOfIterations)
Sets m_numberOfIterations to numberOfIterations >= 0.
void initData()
Initializes all graph data used by the algorithm.
double m_gravitation
Gravitational constant scaling attractive forces towards the barycenter.
double m_pageRatio
Page ratio used for the layout of connected components.
NodeArray< double > m_nodeRadius
Radius of the smallest circle encompassing the node.
bool getRandomInitialPlacement() const
Returns m_randomInitialPlacement.
double getMinDistCC() const
Returns m_minDistCC.
PostProcessingMode m_postProcessing
Whether unnecessary bends should be filtered out in a post processing step.
double m_desiredMinEdgeLength
Desired minimal node separation/edge length.
bool haveSameOriginalEdge(node v, node w) const
Returns whether v and w belong to the same original edge. If only one of the nodes is a dummy node,...
double getDesiredMinEdgeLength() const
Returns m_desiredMinEdgeLength.
void setBendNormalizationAngle(double bendNormalizationAngle)
Sets m_bendNormalizationAngle to bendNormalizationAngle in [0...Pi].
double getMaxDisturbance() const
Returns m_maxDisturbance.
EdgeArray< bool > m_hasParEdges
Whether the edge has parallel edges.
void setMinimalTemperature(double minimalTemperature)
Sets m_minimalTemperature to minimalTemperature >= 0.
void setInitialTemperature(double initialTemperature)
Sets m_initialTemperature to initialTemperature > m_minimalTemperature.
double m_minDistCC
Minimal distance between connected components.
GraphAttributes m_copyAttr
GraphAttributes for m_copy.
std::pair< double, double > computeImpulse(node v)
Returns the new impulse for node v.
NodeArray< double > m_impulseY
Y-coordinate of the last impulse of the node.
double m_barycenterX
Weighted sum of x-coordinates of all nodes.
double getPageRatio() const
Returns m_pageRatio.
void updateNodeLoop(SListPure< node > &nodes)
Computes new impulses and updates positions for random permutations of nodes until m_numberOfIteratio...
Singly linked lists.
Definition SList.h:179
#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.
@ None
Two geometric objects do not intersect.