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
38#include <ogdf/basic/Graph.h>
42#include <ogdf/basic/basic.h>
43#include <ogdf/basic/graphics.h>
44#include <ogdf/basic/memory.h>
45
46#include <algorithm>
47#include <cmath>
48#include <utility>
49
50namespace ogdf {
51template<class E, class INDEX>
52class ArrayBuffer;
53template<class E>
54class SListPure;
55
57
99public:
102
105
107 virtual void call(GraphAttributes& attr) override;
108
112 None,
113 KeepMultiEdgeBends,
116 Complete
118 };
119
122
124 void setRandomInitialPlacement(bool randomInitialPlacement);
125
128
130 void setBendNormalizationAngle(double bendNormalizationAngle);
131
133 void setNumberOfIterations(int numberOfIterations);
134
136 void setMinimalTemperature(double minimalTemperature);
137
140 void setInitialTemperature(double initialTemperature);
141
144 void setTemperatureDecreaseOffset(double temperatureDecreaseOffset);
145
147 void setGravitation(double gravitation);
148
150 void setOscillationAngle(double oscillationAngle);
151
153 void setDesiredMinEdgeLength(double desiredMinEdgeLength);
154
156 void setInitDummiesPerEdge(int initDummiesPerEdge);
157
160 void setMaxDummiesPerEdge(int maxDummiesPerEdge);
161
163 void setDummyInsertionThreshold(double dummyInsertionThreshold);
164
166 void setMaxDisturbance(double maxDisturbance);
167
169 void setRepulsionDistance(double repulsionDistance);
170
172 void setMinDistCC(double minDistCC);
173
175 void setPageRatio(double pageRatio);
176
180
182 bool getRandomInitialPlacement() const { return m_randomInitialPlacement; }
183
185 PostProcessingMode getPostProcessing() const { return m_postProcessing; }
186
188 double getBendNormalizationAngle() const { return m_bendNormalizationAngle; }
189
191 int getNumberOfIterations() const { return m_numberOfIterations; }
192
194 double getMinimalTemperature() const { return m_minimalTemperature; }
195
197 double getInitialTemperature() const { return m_initialTemperature; }
198
200 double getTemperatureDecreaseOffset() const { return m_temperatureDecreaseOffset; }
201
203 double getGravitation() const { return m_gravitation; }
204
206 double getOscillationAngle() const { return m_oscillationAngle; }
207
209 double getDesiredMinEdgeLength() const { return m_desiredMinEdgeLength; }
210
212 int getInitDummiesPerEdge() const { return m_initDummiesPerEdge; }
213
215 int getMaxDummiesPerEdge() const { return m_maxDummiesPerEdge; }
216
218 double getDummyInsertionThreshold() const { return m_dummyInsertionThreshold; }
219
221 double getMaxDisturbance() const { return m_maxDisturbance; }
222
224 double getRepulsionDistance() const { return m_repulsionDistance; }
225
227 double getMinDistCC() const { return m_minDistCC; }
228
230 double getPageRatio() const { return m_pageRatio; }
231
233
234private:
237
240
243
247
250
253
256
261
264
268
271
274
277
281
284
288
291
294
298
301
304
307
310
313
316
319
322
326
329
332
335
338
341
343 double m_factor;
344
346 double m_cos;
347
349
351 void initData();
352
354 void freeData();
355
357 void createBends(const ArrayBuffer<edge>& origEdges, GraphAttributes& attr);
358
363
365 std::pair<double, double> computeImpulse(node v);
366
369 void updateNode(node v, std::pair<double, double> newImpulse);
370
373
376 inline double radius(const GraphAttributes& attr, node v) const {
377 switch (attr.shape(v)) {
378 case Shape::Pentagon:
379 case Shape::Octagon:
380 case Shape::Hexagon:
381 case Shape::Rhomb:
382 case Shape::Ellipse:
383 return std::max(attr.height(v), attr.width(v)) / 2.0;
384
385 default:
386 // For Rect, RoundedRect, Triangle, Trapeze, Parallelogram, InvTriangle,
387 // InvTrapeze, InvParallelogram, Image and unknown shapes.
388 return std::hypot(attr.height(v), attr.width(v)) / 2.0;
389 }
390 }
391
396 inline bool haveSameOriginalEdge(node v, node w) const {
397 if (m_copy.isDummy(v) && m_copy.isDummy(w)) {
398 return m_copy.original(v->firstAdj()->theEdge())
399 == m_copy.original(w->firstAdj()->theEdge());
400 } else if (m_copy.isDummy(v)) {
401 return m_copy.original(v->firstAdj()->theEdge())->isIncident(w);
402 } else if (m_copy.isDummy(w)) {
403 return m_copy.original(w->firstAdj()->theEdge())->isIncident(v);
404 } else {
405 return false;
406 }
407 }
408
410 inline double weight(node v) const { return v->degree() / m_degreeSum; }
411
413};
414
415}
Includes declaration of graph class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declaration of graph copy classes.
Declaration of interface for layout algorithms (class LayoutModule)
Basic declarations, included by all source files.
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition Graph_d.h:161
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:64
Stores additional attributes of a graph (like layout information).
double height(node v) const
Returns the height of the bounding box of node v.
double width(node v) const
Returns the width of the bounding box of node v.
Shape shape(node v) const
Returns the shape type of node v.
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition GraphCopy.h:172
const Graph & original() const
Returns a reference to the original graph.
Definition GraphCopy.h:104
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
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition Graph_d.h:287
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:191
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
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
Declaration of basic types for graphics.
#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.
@ None
Two geometric objects do not intersect.