Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

StressMinimization.h
Go to the documentation of this file.
1 
36 #pragma once
37 
43 
44 namespace ogdf {
45 
47 
51 
52 public:
53  enum class TerminationCriterion {
54  None, PositionDifference, Stress
55  };
56 
59  m_hasEdgeCostsAttribute(false), m_hasInitialLayout(false), m_numberOfIterations(
60  200), m_edgeCosts(100), m_avgEdgeCosts(-1), m_componentLayout(
61  false), m_terminationCriterion(TerminationCriterion::None), m_fixXCoords(false), m_fixYCoords(
62  false), m_fixZCoords(false) {
63  }
64 
67  }
68 
70  virtual void call(GraphAttributes& GA) override;
71 
74  inline void hasInitialLayout(bool hasInitialLayout);
75 
77  inline void fixXCoordinates(bool fix);
78 
80  inline void fixYCoordinates(bool fix);
81 
83  inline void fixZCoordinates(bool fix);
84 
87  inline void layoutComponentsSeparately(bool separate);
88 
91  inline void setEdgeCosts(double edgeCosts);
92 
95  inline void setIterations(int numberOfIterations);
96 
98  inline void convergenceCriterion(TerminationCriterion criterion);
99 
101  inline void useEdgeCostsAttribute(bool useEdgeCostsAttribute);
102 
103 private:
104 
106  const static double EPSILON;
107 
109  const static int DEFAULT_NUMBER_OF_PIVOTS;
110 
114 
117 
120 
122  double m_edgeCosts;
123 
127 
130 
133 
136 
139 
142 
144  double calcStress(const GraphAttributes& GA,
145  NodeArray<NodeArray<double> >& shortestPathMatrix,
146  NodeArray<NodeArray<double> >& weightMatrix);
147 
149  void call(GraphAttributes& GA,
150  NodeArray<NodeArray<double> >& shortestPathMatrix,
151  NodeArray<NodeArray<double> >& weightMatrix);
152 
154  void calcWeights(const Graph& G,
155  NodeArray<NodeArray<double> >& shortestPathMatrix,
156  NodeArray<NodeArray<double> >& weightMatrix);
157 
159  void computeInitialLayout(GraphAttributes& GA);
160 
162  void copyLayout(const GraphAttributes& GA, NodeArray<double>& newX,
163  NodeArray<double>& newY);
164 
166  void copyLayout(const GraphAttributes& GA, NodeArray<double>& newX,
167  NodeArray<double>& newY, NodeArray<double>& newZ);
168 
171  bool finished(GraphAttributes& GA, int numberOfPerformedIterations,
172  NodeArray<double>& prevXCoords, NodeArray<double>& prevYCoords,
173  const double prevStress, const double curStress);
174 
176  void initMatrices(const Graph& G,
177  NodeArray<NodeArray<double> >& shortestPathMatrix,
178  NodeArray<NodeArray<double> >& weightMatrix);
179 
182  void minimizeStress(GraphAttributes& GA,
183  NodeArray<NodeArray<double> >& shortestPathMatrix,
184  NodeArray<NodeArray<double> >& weightMatrix);
185 
188  void nextIteration(GraphAttributes& GA,
189  NodeArray<NodeArray<double> >& shortestPathMatrix,
190  NodeArray<NodeArray<double> >& weightMatrix);
191 
193  void replaceInfinityDistances(
194  NodeArray<NodeArray<double> >& shortestPathMatrix, double newVal);
195 
196 }
197 ;
198 
200  m_fixXCoords = fix;
201 }
202 
204  m_fixYCoords = fix;
205 }
206 
207 void StressMinimization::hasInitialLayout(bool hasInitialLayout) {
208  m_hasInitialLayout = hasInitialLayout;
209 }
210 
212  m_componentLayout = separate;
213 }
214 
215 void StressMinimization::setEdgeCosts(double edgeCosts) {
216  m_edgeCosts = (edgeCosts > 0) ? edgeCosts : 100;
217 }
218 
219 void StressMinimization::setIterations(int numberOfIterations) {
220  m_numberOfIterations = (numberOfIterations > 0) ? numberOfIterations : 100;
221 }
222 
224  m_terminationCriterion = criterion;
225 }
226 
227 void StressMinimization::useEdgeCostsAttribute(bool useEdgeCostsAttribute) {
228  m_hasEdgeCostsAttribute = useEdgeCostsAttribute;
229 }
230 
231 }
void layoutComponentsSeparately(bool separate)
Sets whether the graph&#39;s components should be layouted separately or a dummy distance should be used ...
bool m_hasInitialLayout
Tells whether an initial layout has to be computed or not.
double m_avgEdgeCosts
The average edge costs. Needed to define distances of nodes belonging to different graph components...
void fixYCoordinates(bool fix)
Tells whether the y coordinates are allowed to be modified or not.
static const int DEFAULT_NUMBER_OF_PIVOTS
Default number of pivots used for the initial Pivot-MDS layout.
bool m_fixZCoords
Indicates whether the z coordinates will be modified or not.
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
void useEdgeCostsAttribute(bool useEdgeCostsAttribute)
Tells whether the edge costs are uniform or defined by some edge costs attribute. ...
Splits and packs the components of a Graph.
void setIterations(int numberOfIterations)
Sets a fixed number of iterations for stress majorization. If the new value is smaller or equal 0 the...
Energy-based layout using stress minimization.
Declaration of several shortest path algorithms.
bool m_hasEdgeCostsAttribute
Tells whether the stress minimization is based on uniform edge costs or a edge costs attribute...
Declaration of the pivot MDS.
int m_numberOfIterations
Number of iterations performed by the stress minimization.
void hasInitialLayout(bool hasInitialLayout)
Tells whether the current layout should be used or the initial layout needs to be computed...
void convergenceCriterion(TerminationCriterion criterion)
Tells which TerminationCriterion should be used.
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
Stores additional attributes of a graph (like layout information).
double m_edgeCosts
The weight of an edge.
StressMinimization()
Constructor: Constructs instance of stress majorization.
bool m_fixXCoords
Indicates whether the x coordinates will be modified or not.
Declaration of interface for layout algorithms (class LayoutModule)
void setEdgeCosts(double edgeCosts)
Sets the desired distance between adjacent nodes. If the new value is smaller or equal 0 the default ...
Interface of general layout algorithms.
Definition: LayoutModule.h:44
Two geometric objects do not intersect.
Declaration of simple graph algorithms.
static const double EPSILON
Convergence constant.
The namespace for all OGDF objects.
TerminationCriterion m_terminationCriterion
Indicates whether epsilon convergence is used or not.
void fixXCoordinates(bool fix)
Tells whether the x coordinates are allowed to be modified or not.
bool m_componentLayout
Indicates whether the components should be treated separately.
bool m_fixYCoords
Indicates whether the y coordinates will be modified or not.