Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

StressMinimization.h
Go to the documentation of this file.
1 
36 #pragma once
37 
43 
44 namespace ogdf {
45 
46 
48 
52 
53 public:
54 
55 
56  enum class TerminationCriterion {
57  None, PositionDifference, Stress
58  };
59 
62  m_hasEdgeCostsAttribute(false), m_hasInitialLayout(false), m_numberOfIterations(
63  200), m_edgeCosts(100), m_avgEdgeCosts(-1), m_componentLayout(
64  false), m_terminationCriterion(TerminationCriterion::None), m_fixXCoords(false), m_fixYCoords(
65  false), m_fixZCoords(false) {
66  }
67 
70  }
71 
73  virtual void call(GraphAttributes& GA) override;
74 
77  inline void hasInitialLayout(bool hasInitialLayout);
78 
80  inline void fixXCoordinates(bool fix);
81 
83  inline void fixYCoordinates(bool fix);
84 
86  inline void fixZCoordinates(bool fix);
87 
90  inline void layoutComponentsSeparately(bool separate);
91 
94  inline void setEdgeCosts(double edgeCosts);
95 
98  inline void setIterations(int numberOfIterations);
99 
101  inline void convergenceCriterion(TerminationCriterion criterion);
102 
104  inline void useEdgeCostsAttribute(bool useEdgeCostsAttribute);
105 
106 private:
107 
109  const static double EPSILON;
110 
112  const static int DEFAULT_NUMBER_OF_PIVOTS;
113 
117 
120 
123 
125  double m_edgeCosts;
126 
130 
133 
136 
139 
142 
145 
147  double calcStress(const GraphAttributes& GA,
148  NodeArray<NodeArray<double> >& shortestPathMatrix,
149  NodeArray<NodeArray<double> >& weightMatrix);
150 
152  void call(GraphAttributes& GA,
153  NodeArray<NodeArray<double> >& shortestPathMatrix,
154  NodeArray<NodeArray<double> >& weightMatrix);
155 
157  void calcWeights(const Graph& G,
158  NodeArray<NodeArray<double> >& shortestPathMatrix,
159  NodeArray<NodeArray<double> >& weightMatrix);
160 
162  void computeInitialLayout(GraphAttributes& GA);
163 
165  void copyLayout(const GraphAttributes& GA, NodeArray<double>& newX,
166  NodeArray<double>& newY);
167 
169  void copyLayout(const GraphAttributes& GA, NodeArray<double>& newX,
170  NodeArray<double>& newY, NodeArray<double>& newZ);
171 
174  bool finished(GraphAttributes& GA, int numberOfPerformedIterations,
175  NodeArray<double>& prevXCoords, NodeArray<double>& prevYCoords,
176  const double prevStress, const double curStress);
177 
179  void initMatrices(const Graph& G,
180  NodeArray<NodeArray<double> >& shortestPathMatrix,
181  NodeArray<NodeArray<double> >& weightMatrix);
182 
185  void minimizeStress(GraphAttributes& GA,
186  NodeArray<NodeArray<double> >& shortestPathMatrix,
187  NodeArray<NodeArray<double> >& weightMatrix);
188 
191  void nextIteration(GraphAttributes& GA,
192  NodeArray<NodeArray<double> >& shortestPathMatrix,
193  NodeArray<NodeArray<double> >& weightMatrix);
194 
196  void replaceInfinityDistances(
197  NodeArray<NodeArray<double> >& shortestPathMatrix, double newVal);
198 
199 }
200 ;
201 
203  m_fixXCoords = fix;
204 }
205 
207  m_fixYCoords = fix;
208 }
209 
210 void StressMinimization::hasInitialLayout(bool hasInitialLayout) {
211  m_hasInitialLayout = hasInitialLayout;
212 }
213 
215  m_componentLayout = separate;
216 }
217 
218 void StressMinimization::setEdgeCosts(double edgeCosts) {
219  m_edgeCosts = (edgeCosts > 0) ? edgeCosts : 100;
220 }
221 
222 void StressMinimization::setIterations(int numberOfIterations) {
223  m_numberOfIterations = (numberOfIterations > 0) ? numberOfIterations : 100;
224 }
225 
227  m_terminationCriterion = criterion;
228 }
229 
230 void StressMinimization::useEdgeCostsAttribute(bool useEdgeCostsAttribute) {
231  m_hasEdgeCostsAttribute = useEdgeCostsAttribute;
232 }
233 
234 } // end namespace
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:472
#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:423
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
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.