Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

NodeRespecterLayout.h
Go to the documentation of this file.
1 
36 #pragma once
37 
39 #include <ogdf/basic/GraphCopy.h>
40 
41 namespace ogdf {
42 
44 
86 {
87 
88 public:
91 
94 
96  virtual void call(GraphAttributes &attr) override;
97 
100  enum class PostProcessingMode {
101  None,
102  KeepMultiEdgeBends,
103  Complete
106  };
108 
111 
113  void setRandomInitialPlacement(bool randomInitialPlacement);
114 
116  void setPostProcessing(PostProcessingMode postProcessing);
117 
119  void setBendNormalizationAngle(double bendNormalizationAngle);
120 
122  void setNumberOfIterations(int numberOfIterations);
123 
125  void setMinimalTemperature(double minimalTemperature);
126 
129  void setInitialTemperature(double initialTemperature);
130 
133  void setTemperatureDecreaseOffset(double temperatureDecreaseOffset);
134 
136  void setGravitation(double gravitation);
137 
139  void setOscillationAngle(double oscillationAngle);
140 
142  void setDesiredMinEdgeLength(double desiredMinEdgeLength);
143 
145  void setInitDummiesPerEdge(int initDummiesPerEdge);
146 
149  void setMaxDummiesPerEdge(int maxDummiesPerEdge);
150 
152  void setDummyInsertionThreshold(double dummyInsertionThreshold);
153 
155  void setMaxDisturbance(double maxDisturbance);
156 
158  void setRepulsionDistance(double repulsionDistance);
159 
161  void setMinDistCC(double minDistCC);
162 
164  void setPageRatio(double pageRatio);
165 
169 
171  bool getRandomInitialPlacement() const { return m_randomInitialPlacement; }
172 
174  PostProcessingMode getPostProcessing() const { return m_postProcessing; }
175 
177  double getBendNormalizationAngle() const { return m_bendNormalizationAngle; }
178 
180  int getNumberOfIterations() const { return m_numberOfIterations; }
181 
183  double getMinimalTemperature() const { return m_minimalTemperature; }
184 
186  double getInitialTemperature() const { return m_initialTemperature; }
187 
189  double getTemperatureDecreaseOffset() const { return m_temperatureDecreaseOffset; }
190 
192  double getGravitation() const { return m_gravitation; }
193 
195  double getOscillationAngle() const { return m_oscillationAngle; }
196 
198  double getDesiredMinEdgeLength() const { return m_desiredMinEdgeLength; }
199 
201  int getInitDummiesPerEdge() const { return m_initDummiesPerEdge; }
202 
204  int getMaxDummiesPerEdge() const { return m_maxDummiesPerEdge; }
205 
207  double getDummyInsertionThreshold() const { return m_dummyInsertionThreshold; }
208 
210  double getMaxDisturbance() const { return m_maxDisturbance; }
211 
213  double getRepulsionDistance() const { return m_repulsionDistance; }
214 
216  double getMinDistCC() const { return m_minDistCC; }
217 
219  double getPageRatio() const { return m_pageRatio; }
220 
222 
223 private:
226 
229 
232 
236 
239 
242 
245 
250 
253 
257 
260 
263 
266 
270 
273 
277 
279  double m_minDistCC;
280 
282  double m_pageRatio;
283 
287 
290 
293 
296 
299 
302 
305 
308 
311 
315 
318 
321 
324 
327 
330 
332  double m_factor;
333 
335  double m_cos;
336 
338 
340  void initData();
341 
343  void freeData();
344 
346  void createBends(const ArrayBuffer<edge> &origEdges, GraphAttributes &attr);
347 
351  void updateNodeLoop(SListPure<node> &nodes);
352 
354  std::pair<double,double> computeImpulse(node v);
355 
358  void updateNode(node v, std::pair<double,double> newImpulse);
359 
361  void addDummies(node v, SListPure<node> &nodes);
362 
365  inline double radius(const GraphAttributes &attr, node v) const {
366  switch (attr.shape(v)) {
367  case Shape::Pentagon:
368  case Shape::Octagon:
369  case Shape::Hexagon:
370  case Shape::Rhomb:
371  case Shape::Ellipse:
372  return std::max(attr.height(v), attr.width(v)) / 2.0;
373 
374  default:
375  // For Rect, RoundedRect, Triangle, Trapeze, Parallelogram, InvTriangle,
376  // InvTrapeze, InvParallelogram, Image and unknown shapes.
377  return std::hypot(attr.height(v), attr.width(v)) / 2.0;
378  }
379  }
380 
385  inline bool haveSameOriginalEdge(node v, node w) const {
386  if (m_copy.isDummy(v) && m_copy.isDummy(w)) {
387  return m_copy.original(v->firstAdj()->theEdge()) ==
388  m_copy.original(w->firstAdj()->theEdge());
389  } else if (m_copy.isDummy(v)) {
390  return m_copy.original(v->firstAdj()->theEdge())->isIncident(w);
391  } else if (m_copy.isDummy(w)) {
392  return m_copy.original(w->firstAdj()->theEdge())->isIncident(v);
393  } else {
394  return false;
395  }
396  }
397 
399  inline double weight(node v) const {
400  return v->degree() / m_degreeSum;
401  }
402 
404 };
405 
406 }
double m_maxDisturbance
Maximal disturbance, i.e. maximal random node movement.
double m_temperatureDecreaseOffset
Factor for which holds: If only m_numberOfIterations * m_temperatureDecreaseOffset iterations are lef...
double width(node v) const
Returns the width of the bounding box of node v.
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:96
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
double m_barycenterY
Weighted sum of y-coordinates of all nodes.
int m_iterCounter
Number of iterations for which the algorithm still has to run.
double getBendNormalizationAngle() const
Returns m_bendNormalizationAngle.
PostProcessingMode
Sets whether unnecessary edge bends should be filtered out in a post-processing step.
Singly linked lists.
Definition: SList.h:38
double getDummyInsertionThreshold() const
Returns m_dummyInsertionThreshold.
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:210
double getDesiredMinEdgeLength() const
Returns m_desiredMinEdgeLength.
int getInitDummiesPerEdge() const
Returns m_initDummiesPerEdge.
double getPageRatio() const
Returns m_pageRatio.
NodeArray< double > m_impulseY
Y-coordinate of the last impulse of the node.
int m_degreeSum
Twice the number of all edges in the original graph.
~NodeRespecterLayout()
Destroys an instance of the NodeRespecterLayout.
double m_initialTemperature
Initial temperature of every node.
EdgeArray< bool > m_hasParEdges
Whether the edge has parallel edges.
int m_numberOfIterations
Number of times a single node is moved for each connected component.
NodeArray< double > m_impulseX
X-coordinate of the last impulse of the node.
GraphCopy m_copy
Copy of the given graph which may contain dummy nodes.
double height(node v) const
Returns the height of the bounding box of node v.
double m_pageRatio
Page ratio used for the layout of connected components.
The NodeRespecterLayout layout algorithm.
PostProcessingMode getPostProcessing() const
Returns m_postProcessing.
NodeArray< double > m_localTemperature
Local temperature of the node.
int getNumberOfIterations() const
Returns m_numberOfIterations.
double getMaxDisturbance() const
Returns m_maxDisturbance.
double weight(node v) const
Returns the weight of node v according to its degree.
Stores additional attributes of a graph (like layout information).
double getOscillationAngle() const
Returns m_oscillationAngle.
GraphAttributes m_copyAttr
GraphAttributes for m_copy.
double getMinimalTemperature() const
Returns m_minimalTemperature.
Declaration of graph copy classes.
double getInitialTemperature() const
Returns m_initialTemperature.
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:249
double getRepulsionDistance() const
Returns m_repulsionDistance.
Declaration of interface for layout algorithms (class LayoutModule)
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 m_barycenterX
Weighted sum of x-coordinates of all nodes.
NodeArray< double > m_nodeRadius
Radius of the smallest circle encompassing the node.
Class for the representation of nodes.
Definition: Graph_d.h:169
bool m_randomInitialPlacement
Whether nodes should be initialized in random positions.
NodeArray< NodeArray< double > > m_desiredDistance
Desired distance between each pair of nodes.
#define OGDF_NEW_DELETE
Makes the class use OGDF&#39;s memory allocator.
Definition: memory.h:84
Interface of general layout algorithms.
Definition: LayoutModule.h:44
const Graph & original() const
Returns a reference to the original graph.
Definition: GraphCopy.h:286
double m_gravitation
Gravitational constant scaling attractive forces towards the barycenter.
int getMaxDummiesPerEdge() const
Returns m_maxDummiesPerEdge.
double m_factor
Precomputed constant used to get the max. temperature for each iteration.
Two geometric objects do not intersect.
double m_minimalTemperature
Minimal temperature, lower bound for the global temperature.
double m_cos
Precomputed cosinus of (m_oscillationAngle / 2).
double getTemperatureDecreaseOffset() const
Returns m_temperatureDecreaseOffset.
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...
double getMinDistCC() const
Returns m_minDistCC.
double m_minDistCC
Minimal distance between connected components.
The namespace for all OGDF objects.
double m_desiredMinEdgeLength
Desired minimal node separation/edge length.
PostProcessingMode m_postProcessing
Whether unnecessary bends should be filtered out in a post processing step.
int m_maxDummiesPerEdge
How many dummy nodes should maximally be created for one edge.
double getGravitation() const
Returns m_gravitation.
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...
double m_repulsionDistance
Maximum distance between a dummy and another node such that the former is repulsed by the latter...
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:213
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition: GraphCopy.h:377
rhomb (=diamond)
int m_initDummiesPerEdge
How many dummy nodes should initially be created for one edge.
double m_oscillationAngle
Maximum angle between new and previous impulse such that the node movement is counted as an oscillati...
Shape shape(node v) const
Returns the shape type of node v.
double m_bendNormalizationAngle
Lower bound for the minimum angle between two line segments such that the bend point between them is ...
bool getRandomInitialPlacement() const
Returns m_randomInitialPlacement.
double m_globalTemperature
Average of all local node temperatures.