Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

StressMinimization.h
Go to the documentation of this file.
1 
36 #pragma once
37 
43 
44 namespace ogdf {
45 
47 
51 public:
52  enum class TerminationCriterion { None, PositionDifference, Stress };
53 
56  : m_hasEdgeCostsAttribute(false)
57  , m_hasInitialLayout(false)
58  , m_numberOfIterations(200)
59  , m_edgeCosts(100)
60  , m_avgEdgeCosts(-1)
61  , m_componentLayout(false)
62  , m_terminationCriterion(TerminationCriterion::None)
63  , m_fixXCoords(false)
64  , m_fixYCoords(false)
65  , m_fixZCoords(false)
66  , m_forcing2DLayout(false)
67  , m_use3D(false) { }
68 
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 
108 
113  inline void setForcing2DLayout(bool forcing2DLayout);
114 
115 private:
117  const static double EPSILON;
118 
120  const static int DEFAULT_NUMBER_OF_PIVOTS;
121 
125 
128 
131 
133  double m_edgeCosts;
134 
138 
141 
144 
147 
150 
153 
157 
159  bool m_use3D;
160 
162  double calcStress(const GraphAttributes& GA, NodeArray<NodeArray<double>>& shortestPathMatrix,
163  NodeArray<NodeArray<double>>& weightMatrix);
164 
166  void call(GraphAttributes& GA, NodeArray<NodeArray<double>>& shortestPathMatrix,
167  NodeArray<NodeArray<double>>& weightMatrix);
168 
170  void calcWeights(const Graph& G, NodeArray<NodeArray<double>>& shortestPathMatrix,
171  NodeArray<NodeArray<double>>& weightMatrix);
172 
174  void computeInitialLayout(GraphAttributes& GA);
175 
177  void copyLayout(const GraphAttributes& GA, NodeArray<double>& newX, NodeArray<double>& newY);
178 
180  void copyLayout(const GraphAttributes& GA, NodeArray<double>& newX, NodeArray<double>& newY,
181  NodeArray<double>& newZ);
182 
185  bool finished(GraphAttributes& GA, int numberOfPerformedIterations,
186  NodeArray<double>& prevXCoords, NodeArray<double>& prevYCoords, const double prevStress,
187  const double curStress);
188 
190  void initMatrices(const Graph& G, NodeArray<NodeArray<double>>& shortestPathMatrix,
191  NodeArray<NodeArray<double>>& weightMatrix);
192 
195  void minimizeStress(GraphAttributes& GA, NodeArray<NodeArray<double>>& shortestPathMatrix,
196  NodeArray<NodeArray<double>>& weightMatrix);
197 
200  void nextIteration(GraphAttributes& GA, NodeArray<NodeArray<double>>& shortestPathMatrix,
201  NodeArray<NodeArray<double>>& weightMatrix);
202 
204  void replaceInfinityDistances(NodeArray<NodeArray<double>>& shortestPathMatrix, double newVal);
205 };
206 
208 
210 
211 void StressMinimization::hasInitialLayout(bool hasInitialLayout) {
213 }
214 
216 
217 void StressMinimization::setEdgeCosts(double edgeCosts) {
218  m_edgeCosts = (edgeCosts > 0) ? edgeCosts : 100;
219 }
220 
221 void StressMinimization::setIterations(int numberOfIterations) {
222  m_numberOfIterations = (numberOfIterations > 0) ? numberOfIterations : 100;
223 }
224 
226  m_terminationCriterion = criterion;
227 }
228 
229 void StressMinimization::useEdgeCostsAttribute(bool useEdgeCostsAttribute) {
231 }
232 
233 void StressMinimization::setForcing2DLayout(bool forcing2DLayout) {
234  m_forcing2DLayout = forcing2DLayout;
235 }
236 
237 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
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:211
ogdf::StressMinimization::StressMinimization
StressMinimization()
Constructor: Constructs instance of stress majorization.
Definition: StressMinimization.h:55
ogdf::StressMinimization::m_edgeCosts
double m_edgeCosts
The weight of an edge.
Definition: StressMinimization.h:133
ogdf::StressMinimization::m_terminationCriterion
TerminationCriterion m_terminationCriterion
Indicates whether epsilon convergence is used or not.
Definition: StressMinimization.h:143
PivotMDS.h
Declaration of the pivot MDS. By setting the number of pivots to infinity this algorithm behaves just...
ogdf::StressMinimization
Energy-based layout using stress minimization.
Definition: StressMinimization.h:50
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:140
ogdf::StressMinimization::TerminationCriterion
TerminationCriterion
Definition: StressMinimization.h:52
ogdf::StressMinimization::fixXCoordinates
void fixXCoordinates(bool fix)
Tells whether the x coordinates are allowed to be modified or not.
Definition: StressMinimization.h:207
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:120
ogdf::StressMinimization::m_hasInitialLayout
bool m_hasInitialLayout
Tells whether an initial layout has to be computed or not.
Definition: StressMinimization.h:127
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:215
ogdf::StressMinimization::useEdgeCostsAttribute
void useEdgeCostsAttribute(bool useEdgeCostsAttribute)
Tells whether the edge costs are uniform or defined by some edge costs attribute.
Definition: StressMinimization.h:229
ogdf::StressMinimization::setForcing2DLayout
void setForcing2DLayout(bool forcing2DLayout)
Sets whether a 2D-layout should be calculated even when GraphAttributes::threeD is set.
Definition: StressMinimization.h:233
ogdf::StressMinimization::m_fixZCoords
bool m_fixZCoords
Indicates whether the z coordinates will be modified or not.
Definition: StressMinimization.h:152
ComponentSplitterLayout.h
Splits and packs the components of a Graph.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
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:137
ogdf::StressMinimization::m_fixYCoords
bool m_fixYCoords
Indicates whether the y coordinates will be modified or not.
Definition: StressMinimization.h:149
ogdf::StressMinimization::fixYCoordinates
void fixYCoordinates(bool fix)
Tells whether the y coordinates are allowed to be modified or not.
Definition: StressMinimization.h:209
ogdf::StressMinimization::m_forcing2DLayout
bool m_forcing2DLayout
Indicates whether a 2D-layout is calculated even when GraphAttributes::threeD is set.
Definition: StressMinimization.h:156
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:221
ogdf::StressMinimization::EPSILON
const static double EPSILON
Convergence constant.
Definition: StressMinimization.h:117
ShortestPathAlgorithms.h
Declaration of several shortest path algorithms.
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:124
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:225
ogdf::StressMinimization::m_fixXCoords
bool m_fixXCoords
Indicates whether the x coordinates will be modified or not.
Definition: StressMinimization.h:146
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:217
ogdf::StressMinimization::m_numberOfIterations
int m_numberOfIterations
Number of iterations performed by the stress minimization.
Definition: StressMinimization.h:130
ogdf::StressMinimization::m_use3D
bool m_use3D
Indicates whether a 3D-layout is computed.
Definition: StressMinimization.h:159
simple_graph_alg.h
Declaration of simple graph algorithms.
ogdf::StressMinimization::~StressMinimization
~StressMinimization()
Destructor.
Definition: StressMinimization.h:70
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:44