Energy-based layout using stress minimization. More...
#include <ogdf/energybased/StressMinimization.h>
Public Types | |
enum | TerminationCriterion { TerminationCriterion::None, TerminationCriterion::PositionDifference, TerminationCriterion::Stress } |
Public Member Functions | |
StressMinimization () | |
Constructor: Constructs instance of stress majorization. More... | |
~StressMinimization () | |
Destructor. More... | |
virtual void | call (GraphAttributes &GA) override |
Calls the layout algorithm with uniform edge costs. More... | |
void | convergenceCriterion (TerminationCriterion criterion) |
Tells which TerminationCriterion should be used. More... | |
void | fixXCoordinates (bool fix) |
Tells whether the x coordinates are allowed to be modified or not. More... | |
void | fixYCoordinates (bool fix) |
Tells whether the y coordinates are allowed to be modified or not. More... | |
void | fixZCoordinates (bool fix) |
Tells whether the z coordinates are allowed to be modified or not. More... | |
void | hasInitialLayout (bool hasInitialLayout) |
Tells whether the current layout should be used or the initial layout needs to be computed. More... | |
void | layoutComponentsSeparately (bool separate) |
Sets whether the graph's components should be layouted separately or a dummy distance should be used for nodes within different components. More... | |
void | setEdgeCosts (double edgeCosts) |
Sets the desired distance between adjacent nodes. If the new value is smaller or equal 0 the default value (100) is used. More... | |
void | setForcing2DLayout (bool forcing2DLayout) |
Sets whether a 2D-layout should be calculated even when GraphAttributes::threeD is set. More... | |
void | setIterations (int numberOfIterations) |
Sets a fixed number of iterations for stress majorization. If the new value is smaller or equal 0 the default value (200) is used. More... | |
void | useEdgeCostsAttribute (bool useEdgeCostsAttribute) |
Tells whether the edge costs are uniform or defined by some edge costs attribute. More... | |
Public Member Functions inherited from ogdf::LayoutModule | |
LayoutModule () | |
Initializes a layout module. More... | |
virtual | ~LayoutModule () |
void | operator() (GraphAttributes &GA) |
Computes a layout of graph GA . More... | |
Private Member Functions | |
double | calcStress (const GraphAttributes &GA, NodeArray< NodeArray< double >> &shortestPathMatrix, NodeArray< NodeArray< double >> &weightMatrix) |
Calculates the stress for the given layout. More... | |
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}. More... | |
void | call (GraphAttributes &GA, NodeArray< NodeArray< double >> &shortestPathMatrix, NodeArray< NodeArray< double >> &weightMatrix) |
Runs the stress for a given Graph, shortest path and weight matrix. More... | |
void | computeInitialLayout (GraphAttributes &GA) |
Calculates the intial layout of the graph if necessary. More... | |
void | copyLayout (const GraphAttributes &GA, NodeArray< double > &newX, NodeArray< double > &newY) |
Convenience method copying the layout of the graph in case of epsilon convergence. More... | |
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. More... | |
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 maximum number of iterations. More... | |
void | initMatrices (const Graph &G, NodeArray< NodeArray< double >> &shortestPathMatrix, NodeArray< NodeArray< double >> &weightMatrix) |
Convenience method to initialize the matrices. More... | |
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 matrix. More... | |
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. More... | |
void | replaceInfinityDistances (NodeArray< NodeArray< double >> &shortestPathMatrix, double newVal) |
Replaces infinite distances to the given value. More... | |
Private Attributes | |
double | m_avgEdgeCosts |
The average edge costs. Needed to define distances of nodes belonging to different graph components. More... | |
bool | m_componentLayout |
Indicates whether the components should be treated separately. More... | |
double | m_edgeCosts |
The weight of an edge. More... | |
bool | m_fixXCoords |
Indicates whether the x coordinates will be modified or not. More... | |
bool | m_fixYCoords |
Indicates whether the y coordinates will be modified or not. More... | |
bool | m_fixZCoords |
Indicates whether the z coordinates will be modified or not. More... | |
bool | m_forcing2DLayout |
Indicates whether a 2D-layout is calculated even when GraphAttributes::threeD is set. More... | |
bool | m_hasEdgeCostsAttribute |
Tells whether the stress minimization is based on uniform edge costs or a edge costs attribute. More... | |
bool | m_hasInitialLayout |
Tells whether an initial layout has to be computed or not. More... | |
int | m_numberOfIterations |
Number of iterations performed by the stress minimization. More... | |
TerminationCriterion | m_terminationCriterion |
Indicates whether epsilon convergence is used or not. More... | |
bool | m_use3D |
Indicates whether a 3D-layout is computed. More... | |
Static Private Attributes | |
const static int | DEFAULT_NUMBER_OF_PIVOTS |
Default number of pivots used for the initial Pivot-MDS layout. More... | |
const static double | EPSILON |
Convergence constant. More... | |
Energy-based layout using stress minimization.
Definition at line 49 of file StressMinimization.h.
|
strong |
Enumerator | |
---|---|
None | |
PositionDifference | |
Stress |
Definition at line 51 of file StressMinimization.h.
|
inline |
Constructor: Constructs instance of stress majorization.
Definition at line 54 of file StressMinimization.h.
|
inline |
Destructor.
Definition at line 69 of file StressMinimization.h.
|
private |
Calculates the stress for the given layout.
|
private |
Calculates the weight matrix of the shortest path matrix. This is done by w_ij = s_ij^{-2}.
|
overridevirtual |
Calls the layout algorithm with uniform edge costs.
Implements ogdf::LayoutModule.
|
private |
Runs the stress for a given Graph, shortest path and weight matrix.
|
private |
Calculates the intial layout of the graph if necessary.
|
inline |
Tells which TerminationCriterion should be used.
Definition at line 224 of file StressMinimization.h.
|
private |
Convenience method copying the layout of the graph in case of epsilon convergence.
|
private |
Convenience method copying the layout of the graph in case of epsilon convergence for 3D.
|
private |
Checks for epsilon convergence and whether the performed number of iterations exceed the predefined maximum number of iterations.
|
inline |
Tells whether the x coordinates are allowed to be modified or not.
Definition at line 206 of file StressMinimization.h.
|
inline |
Tells whether the y coordinates are allowed to be modified or not.
Definition at line 208 of file StressMinimization.h.
|
inline |
Tells whether the z coordinates are allowed to be modified or not.
|
inline |
Tells whether the current layout should be used or the initial layout needs to be computed.
Definition at line 210 of file StressMinimization.h.
|
private |
Convenience method to initialize the matrices.
|
inline |
Sets whether the graph's components should be layouted separately or a dummy distance should be used for nodes within different components.
Definition at line 214 of file StressMinimization.h.
|
private |
Minimizes the stress for each component separately given the shortest path matrix and the weight matrix.
|
private |
Runs the next iteration of the stress minimization process. Note that serial update is used.
|
private |
Replaces infinite distances to the given value.
|
inline |
Sets the desired distance between adjacent nodes. If the new value is smaller or equal 0 the default value (100) is used.
Definition at line 216 of file StressMinimization.h.
|
inline |
Sets whether a 2D-layout should be calculated even when GraphAttributes::threeD is set.
If hasInitialLayout() is set to false, the initial layout will also be 2D only. The z-coordinates will never be changed and they will not influence the computation. This setting overrules fixZCoordinates().
Definition at line 232 of file StressMinimization.h.
|
inline |
Sets a fixed number of iterations for stress majorization. If the new value is smaller or equal 0 the default value (200) is used.
Definition at line 220 of file StressMinimization.h.
|
inline |
Tells whether the edge costs are uniform or defined by some edge costs attribute.
Definition at line 228 of file StressMinimization.h.
|
staticprivate |
Default number of pivots used for the initial Pivot-MDS layout.
Definition at line 119 of file StressMinimization.h.
|
staticprivate |
Convergence constant.
Definition at line 116 of file StressMinimization.h.
|
private |
The average edge costs. Needed to define distances of nodes belonging to different graph components.
Definition at line 136 of file StressMinimization.h.
|
private |
Indicates whether the components should be treated separately.
Definition at line 139 of file StressMinimization.h.
|
private |
The weight of an edge.
Definition at line 132 of file StressMinimization.h.
|
private |
Indicates whether the x coordinates will be modified or not.
Definition at line 145 of file StressMinimization.h.
|
private |
Indicates whether the y coordinates will be modified or not.
Definition at line 148 of file StressMinimization.h.
|
private |
Indicates whether the z coordinates will be modified or not.
Definition at line 151 of file StressMinimization.h.
|
private |
Indicates whether a 2D-layout is calculated even when GraphAttributes::threeD is set.
Definition at line 155 of file StressMinimization.h.
|
private |
Tells whether the stress minimization is based on uniform edge costs or a edge costs attribute.
Definition at line 123 of file StressMinimization.h.
|
private |
Tells whether an initial layout has to be computed or not.
Definition at line 126 of file StressMinimization.h.
|
private |
Number of iterations performed by the stress minimization.
Definition at line 129 of file StressMinimization.h.
|
private |
Indicates whether epsilon convergence is used or not.
Definition at line 142 of file StressMinimization.h.
|
private |
Indicates whether a 3D-layout is computed.
Definition at line 158 of file StressMinimization.h.