Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

StressMinimization.h
Go to the documentation of this file.
1 
36 #pragma once
37 
38 #include <ogdf/basic/Graph.h>
40 #include <ogdf/basic/basic.h>
41 
42 namespace ogdf {
43 class GraphAttributes;
44 
46 
50 public:
51  enum class TerminationCriterion { None, PositionDifference, Stress };
52 
55  : m_hasEdgeCostsAttribute(false)
56  , m_hasInitialLayout(false)
57  , m_numberOfIterations(200)
58  , m_edgeCosts(100)
59  , m_avgEdgeCosts(-1)
60  , m_componentLayout(false)
61  , m_terminationCriterion(TerminationCriterion::None)
62  , m_fixXCoords(false)
63  , m_fixYCoords(false)
64  , m_fixZCoords(false)
65  , m_forcing2DLayout(false)
66  , m_use3D(false) { }
67 
70 
72  virtual void call(GraphAttributes& GA) override;
73 
76  inline void hasInitialLayout(bool hasInitialLayout);
77 
79  inline void fixXCoordinates(bool fix);
80 
82  inline void fixYCoordinates(bool fix);
83 
85  inline void fixZCoordinates(bool fix);
86 
89  inline void layoutComponentsSeparately(bool separate);
90 
93  inline void setEdgeCosts(double edgeCosts);
94 
97  inline void setIterations(int numberOfIterations);
98 
100  inline void convergenceCriterion(TerminationCriterion criterion);
101 
103  inline void useEdgeCostsAttribute(bool useEdgeCostsAttribute);
104 
107 
112  inline void setForcing2DLayout(bool forcing2DLayout);
113 
114 private:
116  const static double EPSILON;
117 
119  const static int DEFAULT_NUMBER_OF_PIVOTS;
120 
124 
127 
130 
132  double m_edgeCosts;
133 
137 
140 
143 
146 
149 
152 
156 
158  bool m_use3D;
159 
161  double calcStress(const GraphAttributes& GA, NodeArray<NodeArray<double>>& shortestPathMatrix,
162  NodeArray<NodeArray<double>>& weightMatrix);
163 
165  void call(GraphAttributes& GA, NodeArray<NodeArray<double>>& shortestPathMatrix,
166  NodeArray<NodeArray<double>>& weightMatrix);
167 
169  void calcWeights(const Graph& G, NodeArray<NodeArray<double>>& shortestPathMatrix,
170  NodeArray<NodeArray<double>>& weightMatrix);
171 
173  void computeInitialLayout(GraphAttributes& GA);
174 
176  void copyLayout(const GraphAttributes& GA, NodeArray<double>& newX, NodeArray<double>& newY);
177 
179  void copyLayout(const GraphAttributes& GA, NodeArray<double>& newX, NodeArray<double>& newY,
180  NodeArray<double>& newZ);
181 
184  bool finished(GraphAttributes& GA, int numberOfPerformedIterations,
185  NodeArray<double>& prevXCoords, NodeArray<double>& prevYCoords, const double prevStress,
186  const double curStress);
187 
189  void initMatrices(const Graph& G, NodeArray<NodeArray<double>>& shortestPathMatrix,
190  NodeArray<NodeArray<double>>& weightMatrix);
191 
194  void minimizeStress(GraphAttributes& GA, NodeArray<NodeArray<double>>& shortestPathMatrix,
195  NodeArray<NodeArray<double>>& weightMatrix);
196 
199  void nextIteration(GraphAttributes& GA, NodeArray<NodeArray<double>>& shortestPathMatrix,
200  NodeArray<NodeArray<double>>& weightMatrix);
201 
203  void replaceInfinityDistances(NodeArray<NodeArray<double>>& shortestPathMatrix, double newVal);
204 };
205 
207 
209 
210 void StressMinimization::hasInitialLayout(bool hasInitialLayout) {
212 }
213 
215 
216 void StressMinimization::setEdgeCosts(double edgeCosts) {
217  m_edgeCosts = (edgeCosts > 0) ? edgeCosts : 100;
218 }
219 
220 void StressMinimization::setIterations(int numberOfIterations) {
221  m_numberOfIterations = (numberOfIterations > 0) ? numberOfIterations : 100;
222 }
223 
225  m_terminationCriterion = criterion;
226 }
227 
228 void StressMinimization::useEdgeCostsAttribute(bool useEdgeCostsAttribute) {
230 }
231 
232 void StressMinimization::setForcing2DLayout(bool forcing2DLayout) {
233  m_forcing2DLayout = forcing2DLayout;
234 }
235 
236 }
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
ogdf::StressMinimization::hasInitialLayout
void hasInitialLayout(bool hasInitialLayout)
Tells whether the current layout should be used or the initial layout needs to be computed.
Definition: StressMinimization.h:210
Graph.h
Includes declaration of graph class.
ogdf::StressMinimization::StressMinimization
StressMinimization()
Constructor: Constructs instance of stress majorization.
Definition: StressMinimization.h:54
ogdf::StressMinimization::m_edgeCosts
double m_edgeCosts
The weight of an edge.
Definition: StressMinimization.h:132
ogdf::StressMinimization::m_terminationCriterion
TerminationCriterion m_terminationCriterion
Indicates whether epsilon convergence is used or not.
Definition: StressMinimization.h:142
ogdf::StressMinimization
Energy-based layout using stress minimization.
Definition: StressMinimization.h:49
LayoutModule.h
Declaration of interface for layout algorithms (class LayoutModule)
ogdf::StressMinimization::m_componentLayout
bool m_componentLayout
Indicates whether the components should be treated separately.
Definition: StressMinimization.h:139
ogdf::StressMinimization::TerminationCriterion
TerminationCriterion
Definition: StressMinimization.h:51
ogdf::StressMinimization::fixXCoordinates
void fixXCoordinates(bool fix)
Tells whether the x coordinates are allowed to be modified or not.
Definition: StressMinimization.h:206
ogdf::StressMinimization::DEFAULT_NUMBER_OF_PIVOTS
const static int DEFAULT_NUMBER_OF_PIVOTS
Default number of pivots used for the initial Pivot-MDS layout.
Definition: StressMinimization.h:119
ogdf::StressMinimization::m_hasInitialLayout
bool m_hasInitialLayout
Tells whether an initial layout has to be computed or not.
Definition: StressMinimization.h:126
ogdf::StressMinimization::layoutComponentsSeparately
void layoutComponentsSeparately(bool separate)
Sets whether the graph's components should be layouted separately or a dummy distance should be used ...
Definition: StressMinimization.h:214
ogdf::StressMinimization::useEdgeCostsAttribute
void useEdgeCostsAttribute(bool useEdgeCostsAttribute)
Tells whether the edge costs are uniform or defined by some edge costs attribute.
Definition: StressMinimization.h:228
ogdf::StressMinimization::setForcing2DLayout
void setForcing2DLayout(bool forcing2DLayout)
Sets whether a 2D-layout should be calculated even when GraphAttributes::threeD is set.
Definition: StressMinimization.h:232
ogdf::StressMinimization::m_fixZCoords
bool m_fixZCoords
Indicates whether the z coordinates will be modified or not.
Definition: StressMinimization.h:151
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::StressMinimization::m_avgEdgeCosts
double m_avgEdgeCosts
The average edge costs. Needed to define distances of nodes belonging to different graph components.
Definition: StressMinimization.h:136
ogdf::StressMinimization::m_fixYCoords
bool m_fixYCoords
Indicates whether the y coordinates will be modified or not.
Definition: StressMinimization.h:148
ogdf::StressMinimization::fixYCoordinates
void fixYCoordinates(bool fix)
Tells whether the y coordinates are allowed to be modified or not.
Definition: StressMinimization.h:208
ogdf::StressMinimization::m_forcing2DLayout
bool m_forcing2DLayout
Indicates whether a 2D-layout is calculated even when GraphAttributes::threeD is set.
Definition: StressMinimization.h:155
ogdf::StressMinimization::setIterations
void setIterations(int numberOfIterations)
Sets a fixed number of iterations for stress majorization. If the new value is smaller or equal 0 the...
Definition: StressMinimization.h:220
ogdf::StressMinimization::EPSILON
const static double EPSILON
Convergence constant.
Definition: StressMinimization.h:116
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::StressMinimization::m_hasEdgeCostsAttribute
bool m_hasEdgeCostsAttribute
Tells whether the stress minimization is based on uniform edge costs or a edge costs attribute.
Definition: StressMinimization.h:123
ogdf::IntersectionType::None
@ None
Two geometric objects do not intersect.
ogdf::StressMinimization::convergenceCriterion
void convergenceCriterion(TerminationCriterion criterion)
Tells which TerminationCriterion should be used.
Definition: StressMinimization.h:224
ogdf::StressMinimization::m_fixXCoords
bool m_fixXCoords
Indicates whether the x coordinates will be modified or not.
Definition: StressMinimization.h:145
ogdf::StressMinimization::setEdgeCosts
void setEdgeCosts(double edgeCosts)
Sets the desired distance between adjacent nodes. If the new value is smaller or equal 0 the default ...
Definition: StressMinimization.h:216
ogdf::StressMinimization::m_numberOfIterations
int m_numberOfIterations
Number of iterations performed by the stress minimization.
Definition: StressMinimization.h:129
ogdf::StressMinimization::m_use3D
bool m_use3D
Indicates whether a 3D-layout is computed.
Definition: StressMinimization.h:158
ogdf::StressMinimization::~StressMinimization
~StressMinimization()
Destructor.
Definition: StressMinimization.h:69
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:45