Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

NodeRespecterLayout.h
Go to the documentation of this file.
1 
36 #pragma once
37 
38 #include <ogdf/basic/Graph.h>
40 #include <ogdf/basic/GraphCopy.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 
50 namespace ogdf {
51 template<class E, class INDEX>
52 class ArrayBuffer;
53 template<class E>
54 class SListPure;
55 
57 
99 public:
102 
105 
107  virtual void call(GraphAttributes& attr) override;
108 
111  enum class PostProcessingMode {
112  None,
113  KeepMultiEdgeBends,
114  Complete
117  };
119 
122 
124  void setRandomInitialPlacement(bool randomInitialPlacement);
125 
127  void setPostProcessing(PostProcessingMode postProcessing);
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 
234 private:
237 
240 
243 
247 
250 
253 
256 
261 
264 
268 
271 
274 
277 
281 
284 
288 
290  double m_minDistCC;
291 
293  double m_pageRatio;
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 
362  void updateNodeLoop(SListPure<node>& nodes);
363 
365  std::pair<double, double> computeImpulse(node v);
366 
369  void updateNode(node v, std::pair<double, double> newImpulse);
370 
372  void addDummies(node v, SListPure<node>& nodes);
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 }
ogdf::ArrayBuffer< edge >
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
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::NodeRespecterLayout::m_impulseY
NodeArray< double > m_impulseY
Y-coordinate of the last impulse of the node.
Definition: NodeRespecterLayout.h:309
ogdf::NodeRespecterLayout::m_localTemperature
NodeArray< double > m_localTemperature
Local temperature of the node.
Definition: NodeRespecterLayout.h:312
ogdf::NodeRespecterLayout::getPageRatio
double getPageRatio() const
Returns m_pageRatio.
Definition: NodeRespecterLayout.h:230
Graph.h
Includes declaration of graph class.
ogdf::NodeRespecterLayout::m_pageRatio
double m_pageRatio
Page ratio used for the layout of connected components.
Definition: NodeRespecterLayout.h:293
ogdf::NodeRespecterLayout::m_initDummiesPerEdge
int m_initDummiesPerEdge
How many dummy nodes should initially be created for one edge.
Definition: NodeRespecterLayout.h:273
graphics.h
Declaration of basic types for graphics.
ogdf::NodeRespecterLayout::getRepulsionDistance
double getRepulsionDistance() const
Returns m_repulsionDistance.
Definition: NodeRespecterLayout.h:224
ogdf::NodeRespecterLayout
The NodeRespecterLayout layout algorithm.
Definition: NodeRespecterLayout.h:98
ogdf::NodeRespecterLayout::getMaxDisturbance
double getMaxDisturbance() const
Returns m_maxDisturbance.
Definition: NodeRespecterLayout.h:221
ogdf::NodeRespecterLayout::m_barycenterX
double m_barycenterX
Weighted sum of x-coordinates of all nodes.
Definition: NodeRespecterLayout.h:331
ogdf::GraphCopyBase::isDummy
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition: GraphCopy.h:173
ogdf::NodeRespecterLayout::m_temperatureDecreaseOffset
double m_temperatureDecreaseOffset
Factor for which holds: If only m_numberOfIterations * m_temperatureDecreaseOffset iterations are lef...
Definition: NodeRespecterLayout.h:260
ogdf::NodeRespecterLayout::~NodeRespecterLayout
~NodeRespecterLayout()
Destroys an instance of the NodeRespecterLayout.
Definition: NodeRespecterLayout.h:104
ogdf::NodeRespecterLayout::m_degreeSum
int m_degreeSum
Twice the number of all edges in the original graph.
Definition: NodeRespecterLayout.h:328
ogdf::NodeRespecterLayout::m_randomInitialPlacement
bool m_randomInitialPlacement
Whether nodes should be initialized in random positions.
Definition: NodeRespecterLayout.h:239
ogdf::NodeRespecterLayout::getMinDistCC
double getMinDistCC() const
Returns m_minDistCC.
Definition: NodeRespecterLayout.h:227
ogdf::Shape::Octagon
@ Octagon
octagon
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:391
ogdf::NodeRespecterLayout::haveSameOriginalEdge
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,...
Definition: NodeRespecterLayout.h:396
ogdf::NodeRespecterLayout::m_bendNormalizationAngle
double m_bendNormalizationAngle
Lower bound for the minimum angle between two line segments such that the bend point between them is ...
Definition: NodeRespecterLayout.h:246
LayoutModule.h
Declaration of interface for layout algorithms (class LayoutModule)
ogdf::NodeRespecterLayout::m_repulsionDistance
double m_repulsionDistance
Maximum distance between a dummy and another node such that the former is repulsed by the latter.
Definition: NodeRespecterLayout.h:287
ogdf::NodeRespecterLayout::m_dummyInsertionThreshold
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...
Definition: NodeRespecterLayout.h:280
ogdf::Shape::Rhomb
@ Rhomb
rhomb (=diamond)
ogdf::NodeRespecterLayout::m_numberOfIterations
int m_numberOfIterations
Number of times a single node is moved for each connected component.
Definition: NodeRespecterLayout.h:249
ogdf::NodeRespecterLayout::PostProcessingMode
PostProcessingMode
Sets whether unnecessary edge bends should be filtered out in a post-processing step.
Definition: NodeRespecterLayout.h:111
ogdf::NodeRespecterLayout::m_cos
double m_cos
Precomputed cosinus of (m_oscillationAngle / 2).
Definition: NodeRespecterLayout.h:346
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:85
ogdf::NodeRespecterLayout::getMaxDummiesPerEdge
int getMaxDummiesPerEdge() const
Returns m_maxDummiesPerEdge.
Definition: NodeRespecterLayout.h:215
ogdf::NodeRespecterLayout::getBendNormalizationAngle
double getBendNormalizationAngle() const
Returns m_bendNormalizationAngle.
Definition: NodeRespecterLayout.h:188
ogdf::NodeRespecterLayout::m_hasParEdges
EdgeArray< bool > m_hasParEdges
Whether the edge has parallel edges.
Definition: NodeRespecterLayout.h:318
ogdf::NodeRespecterLayout::getDesiredMinEdgeLength
double getDesiredMinEdgeLength() const
Returns m_desiredMinEdgeLength.
Definition: NodeRespecterLayout.h:209
ogdf::NodeRespecterLayout::m_desiredMinEdgeLength
double m_desiredMinEdgeLength
Desired minimal node separation/edge length.
Definition: NodeRespecterLayout.h:270
ogdf::NodeRespecterLayout::m_minimalTemperature
double m_minimalTemperature
Minimal temperature, lower bound for the global temperature.
Definition: NodeRespecterLayout.h:252
ogdf::GraphAttributes::shape
Shape shape(node v) const
Returns the shape type of node v.
Definition: GraphAttributes.h:429
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:160
ogdf::NodeElement::degree
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:283
ogdf::NodeRespecterLayout::m_maxDisturbance
double m_maxDisturbance
Maximal disturbance, i.e. maximal random node movement.
Definition: NodeRespecterLayout.h:283
ogdf::NodeRespecterLayout::m_gravitation
double m_gravitation
Gravitational constant scaling attractive forces towards the barycenter.
Definition: NodeRespecterLayout.h:263
ogdf::NodeRespecterLayout::weight
double weight(node v) const
Returns the weight of node v according to its degree.
Definition: NodeRespecterLayout.h:410
ogdf::NodeRespecterLayout::getMinimalTemperature
double getMinimalTemperature() const
Returns m_minimalTemperature.
Definition: NodeRespecterLayout.h:194
ogdf::NodeRespecterLayout::m_copy
GraphCopy m_copy
Copy of the given graph which may contain dummy nodes.
Definition: NodeRespecterLayout.h:300
ogdf::NodeRespecterLayout::m_minDistCC
double m_minDistCC
Minimal distance between connected components.
Definition: NodeRespecterLayout.h:290
ogdf::NodeRespecterLayout::m_nodeRadius
NodeArray< double > m_nodeRadius
Radius of the smallest circle encompassing the node.
Definition: NodeRespecterLayout.h:315
ogdf::SListPure
Singly linked lists.
Definition: SList.h:52
ogdf::NodeRespecterLayout::getPostProcessing
PostProcessingMode getPostProcessing() const
Returns m_postProcessing.
Definition: NodeRespecterLayout.h:185
GraphCopy.h
Declaration of graph copy classes.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Shape::Pentagon
@ Pentagon
pentagon
ogdf::GraphAttributes::height
double height(node v) const
Returns the height of the bounding box of node v.
Definition: GraphAttributes.h:393
ogdf::NodeRespecterLayout::getGravitation
double getGravitation() const
Returns m_gravitation.
Definition: NodeRespecterLayout.h:203
ogdf::Shape::Ellipse
@ Ellipse
ellipse
ogdf::NodeRespecterLayout::m_desiredDistance
NodeArray< NodeArray< double > > m_desiredDistance
Desired distance between each pair of nodes.
Definition: NodeRespecterLayout.h:321
ogdf::NodeRespecterLayout::getTemperatureDecreaseOffset
double getTemperatureDecreaseOffset() const
Returns m_temperatureDecreaseOffset.
Definition: NodeRespecterLayout.h:200
ogdf::NodeRespecterLayout::getInitDummiesPerEdge
int getInitDummiesPerEdge() const
Returns m_initDummiesPerEdge.
Definition: NodeRespecterLayout.h:212
ogdf::NodeRespecterLayout::m_impulseX
NodeArray< double > m_impulseX
X-coordinate of the last impulse of the node.
Definition: NodeRespecterLayout.h:306
ogdf::NodeRespecterLayout::getDummyInsertionThreshold
double getDummyInsertionThreshold() const
Returns m_dummyInsertionThreshold.
Definition: NodeRespecterLayout.h:218
basic.h
Basic declarations, included by all source files.
ogdf::NodeRespecterLayout::getOscillationAngle
double getOscillationAngle() const
Returns m_oscillationAngle.
Definition: NodeRespecterLayout.h:206
ogdf::NodeRespecterLayout::m_iterCounter
int m_iterCounter
Number of iterations for which the algorithm still has to run.
Definition: NodeRespecterLayout.h:337
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::NodeRespecterLayout::radius
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...
Definition: NodeRespecterLayout.h:376
ogdf::NodeRespecterLayout::m_oscillationAngle
double m_oscillationAngle
Maximum angle between new and previous impulse such that the node movement is counted as an oscillati...
Definition: NodeRespecterLayout.h:267
ogdf::NodeElement::firstAdj
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:286
ogdf::NodeRespecterLayout::m_globalTemperature
double m_globalTemperature
Average of all local node temperatures.
Definition: NodeRespecterLayout.h:340
ogdf::NodeRespecterLayout::m_maxDummiesPerEdge
int m_maxDummiesPerEdge
How many dummy nodes should maximally be created for one edge.
Definition: NodeRespecterLayout.h:276
ogdf::NodeRespecterLayout::m_postProcessing
PostProcessingMode m_postProcessing
Whether unnecessary bends should be filtered out in a post processing step.
Definition: NodeRespecterLayout.h:242
ogdf::NodeRespecterLayout::getInitialTemperature
double getInitialTemperature() const
Returns m_initialTemperature.
Definition: NodeRespecterLayout.h:197
ogdf::NodeRespecterLayout::getNumberOfIterations
int getNumberOfIterations() const
Returns m_numberOfIterations.
Definition: NodeRespecterLayout.h:191
ogdf::Shape::Hexagon
@ Hexagon
hexagon
ogdf::NodeRespecterLayout::m_initialTemperature
double m_initialTemperature
Initial temperature of every node.
Definition: NodeRespecterLayout.h:255
ogdf::IntersectionType::None
@ None
Two geometric objects do not intersect.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::NodeRespecterLayout::m_copyAttr
GraphAttributes m_copyAttr
GraphAttributes for m_copy.
Definition: NodeRespecterLayout.h:303
memory.h
Declaration of memory manager for allocating small pieces of memory.
ogdf::NodeRespecterLayout::getRandomInitialPlacement
bool getRandomInitialPlacement() const
Returns m_randomInitialPlacement.
Definition: NodeRespecterLayout.h:182
ogdf::NodeRespecterLayout::m_barycenterY
double m_barycenterY
Weighted sum of y-coordinates of all nodes.
Definition: NodeRespecterLayout.h:334
ogdf::NodeRespecterLayout::m_factor
double m_factor
Precomputed constant used to get the max. temperature for each iteration.
Definition: NodeRespecterLayout.h:343
ogdf::GraphCopyBase::original
const Graph & original() const
Returns a reference to the original graph.
Definition: GraphCopy.h:105
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:45
ogdf::GraphAttributes::width
double width(node v) const
Returns the width of the bounding box of node v.
Definition: GraphAttributes.h:357