Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
StressMinimization.h
Go to the documentation of this file.
1
36#pragma once
37
43
44namespace ogdf {
45
47
51public:
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
115private:
117 const static double EPSILON;
118
120 const static int DEFAULT_NUMBER_OF_PIVOTS;
121
125
128
131
134
138
141
144
147
150
153
157
160
164
168
172
175
178
182
187 const double curStress);
188
192
197
202
205};
206
208
210
214
216
220
221void StressMinimization::setIterations(int numberOfIterations) {
222 m_numberOfIterations = (numberOfIterations > 0) ? numberOfIterations : 100;
223}
224
228
232
236
237}
Splits and packs the components of a Graph.
Declaration of interface for layout algorithms (class LayoutModule)
Declaration of the pivot MDS.
Declaration of several shortest path algorithms.
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Interface of general layout algorithms.
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Energy-based layout using stress minimization.
void setForcing2DLayout(bool forcing2DLayout)
Sets whether a 2D-layout should be calculated even when GraphAttributes::threeD is set.
TerminationCriterion m_terminationCriterion
Indicates whether epsilon convergence is used or not.
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm with uniform edge costs.
void initMatrices(const Graph &G, NodeArray< NodeArray< double > > &shortestPathMatrix, NodeArray< NodeArray< double > > &weightMatrix)
Convenience method to initialize the matrices.
bool m_fixYCoords
Indicates whether the y coordinates will be modified or not.
bool m_hasEdgeCostsAttribute
Tells whether the stress minimization is based on uniform edge costs or a edge costs attribute.
void convergenceCriterion(TerminationCriterion criterion)
Tells which TerminationCriterion should be used.
double calcStress(const GraphAttributes &GA, NodeArray< NodeArray< double > > &shortestPathMatrix, NodeArray< NodeArray< double > > &weightMatrix)
Calculates the stress for the given layout.
void call(GraphAttributes &GA, NodeArray< NodeArray< double > > &shortestPathMatrix, NodeArray< NodeArray< double > > &weightMatrix)
Runs the stress for a given Graph, shortest path and weight matrix.
bool m_forcing2DLayout
Indicates whether a 2D-layout is calculated even when GraphAttributes::threeD is set.
void hasInitialLayout(bool hasInitialLayout)
Tells whether the current layout should be used or the initial layout needs to be computed.
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_use3D
Indicates whether a 3D-layout is computed.
bool finished(GraphAttributes &GA, int numberOfPerformedIterations, NodeArray< double > &prevXCoords, NodeArray< double > &prevYCoords, const double prevStress, const double curStress)
Checks for epsilon convergence and whether the performed number of iterations exceed the predefined m...
bool m_componentLayout
Indicates whether the components should be treated separately.
void computeInitialLayout(GraphAttributes &GA)
Calculates the intial layout of the graph if necessary.
void useEdgeCostsAttribute(bool useEdgeCostsAttribute)
Tells whether the edge costs are uniform or defined by some edge costs attribute.
bool m_fixZCoords
Indicates whether the z coordinates will be modified or not.
void nextIteration(GraphAttributes &GA, NodeArray< NodeArray< double > > &shortestPathMatrix, NodeArray< NodeArray< double > > &weightMatrix)
Runs the next iteration of the stress minimization process. Note that serial update is used.
int m_numberOfIterations
Number of iterations performed by the stress minimization.
void fixXCoordinates(bool fix)
Tells whether the x coordinates are allowed to be modified or not.
void layoutComponentsSeparately(bool separate)
Sets whether the graph's components should be layouted separately or a dummy distance should be used ...
void replaceInfinityDistances(NodeArray< NodeArray< double > > &shortestPathMatrix, double newVal)
Replaces infinite distances to the given value.
double m_edgeCosts
The weight of an edge.
static const double EPSILON
Convergence constant.
void setEdgeCosts(double edgeCosts)
Sets the desired distance between adjacent nodes. If the new value is smaller or equal 0 the default ...
void copyLayout(const GraphAttributes &GA, NodeArray< double > &newX, NodeArray< double > &newY)
Convenience method copying the layout of the graph in case of epsilon convergence.
void setIterations(int numberOfIterations)
Sets a fixed number of iterations for stress majorization. If the new value is smaller or equal 0 the...
bool m_hasInitialLayout
Tells whether an initial layout has to be computed or not.
void calcWeights(const Graph &G, NodeArray< NodeArray< double > > &shortestPathMatrix, NodeArray< NodeArray< double > > &weightMatrix)
Calculates the weight matrix of the shortest path matrix. This is done by w_ij = s_ij^{-2}.
double m_avgEdgeCosts
The average edge costs. Needed to define distances of nodes belonging to different graph components.
void fixZCoordinates(bool fix)
Tells whether the z coordinates are allowed to be modified or not.
bool m_fixXCoords
Indicates whether the x coordinates will be modified or not.
void copyLayout(const GraphAttributes &GA, NodeArray< double > &newX, NodeArray< double > &newY, NodeArray< double > &newZ)
Convenience method copying the layout of the graph in case of epsilon convergence for 3D.
void minimizeStress(GraphAttributes &GA, NodeArray< NodeArray< double > > &shortestPathMatrix, NodeArray< NodeArray< double > > &weightMatrix)
Minimizes the stress for each component separately given the shortest path matrix and the weight matr...
StressMinimization()
Constructor: Constructs instance of stress majorization.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
@ None
Two geometric objects do not intersect.
Declaration of simple graph algorithms.