Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
PivotMDS.h
Go to the documentation of this file.
1
35#pragma once
36
37#include <ogdf/basic/Array.h>
38#include <ogdf/basic/Graph.h>
40#include <ogdf/basic/basic.h>
41
42#include <algorithm>
43#include <limits>
44
45namespace ogdf {
46class GraphAttributes;
47
48template<typename T>
49inline bool isinf(T value) {
50 return std::numeric_limits<T>::has_infinity && value == std::numeric_limits<T>::infinity();
51}
52
54
58public:
60 : m_numberOfPivots(250)
61 , m_dimensionCount(2)
62 , m_edgeCosts(100)
63 , m_hasEdgeCostsAttribute(false)
64 , m_forcing2DLayout(false) { }
65
66 virtual ~PivotMDS() { }
67
70 void setNumberOfPivots(int numberOfPivots) {
71 m_numberOfPivots = std::max(numberOfPivots, m_dimensionCount);
72 }
73
76 void setEdgeCosts(double edgeCosts) { m_edgeCosts = edgeCosts; }
77
80 void setForcing2DLayout(bool forcing2DLayout) { m_forcing2DLayout = forcing2DLayout; }
81
84 bool isForcing2DLayout() const { return m_forcing2DLayout; }
85
87
93 virtual void call(GraphAttributes& GA) override;
94
95 void useEdgeCostsAttribute(bool useEdgeCostsAttribute) {
96 m_hasEdgeCostsAttribute = useEdgeCostsAttribute;
97 }
98
99 bool useEdgeCostsAttribute() const { return m_hasEdgeCostsAttribute; }
100
101private:
103 const static double EPSILON;
104
106 const static double FACTOR;
107
109 const static unsigned int SEED = 0;
110
113
118
121
125
129
132
135
136 void copySPSS(Array<double>& copyTo, NodeArray<double>& copyFrom);
137
139 void doPathLayout(GraphAttributes& GA, const node& v);
140
143 Array<double>& eValues);
144
147
150
153
155 double prod(const Array<double>& x, const Array<double>& y);
156
159
162
165 Array<double>& eVals);
166};
167
168}
Declaration and implementation of Array class and Array algorithms.
Includes declaration of graph class.
Declaration of interface for layout algorithms (class LayoutModule)
Basic declarations, included by all source files.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Interface of general layout algorithms.
Class for the representation of nodes.
Definition Graph_d.h:241
The Pivot MDS (multi-dimensional scaling) layout algorithm.
Definition PivotMDS.h:57
void copySPSS(Array< double > &copyTo, NodeArray< double > &copyFrom)
virtual ~PivotMDS()
Definition PivotMDS.h:66
void doPathLayout(GraphAttributes &GA, const node &v)
Computes the layout of a path.
double normalize(Array< double > &x)
Normalizes the vector x.
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm for graph attributes GA.
bool isForcing2DLayout() const
Returns whether a 2D-layout is calculated even when GraphAttributes::threeD is set.
Definition PivotMDS.h:84
void pivotMDSLayout(GraphAttributes &GA)
Computes the pivot mds layout of the given connected graph of GA.
void eigenValueDecomposition(Array< Array< double > > &K, Array< Array< double > > &eVecs, Array< double > &eValues)
Computes the eigen value decomposition based on power iteration.
double prod(const Array< double > &x, const Array< double > &y)
Computes the product of two vectors x and y.
void setNumberOfPivots(int numberOfPivots)
Sets the number of pivots. If the new value is smaller or equal 0 the default value (250) is used.
Definition PivotMDS.h:70
int m_numberOfPivots
The number of pivots.
Definition PivotMDS.h:112
void setEdgeCosts(double edgeCosts)
Sets the desired distance between adjacent nodes. If the new value is smaller or equal 0 the default ...
Definition PivotMDS.h:76
static const double FACTOR
Factor used to center the pivot matrix.
Definition PivotMDS.h:106
bool m_forcing2DLayout
Whether a 2D-layout is calculated even when GraphAttributes::threeD is set.
Definition PivotMDS.h:128
bool m_hasEdgeCostsAttribute
Tells whether the pivot mds is based on uniform edge costs or a edge costs attribute.
Definition PivotMDS.h:124
void useEdgeCostsAttribute(bool useEdgeCostsAttribute)
Definition PivotMDS.h:95
void getPivotDistanceMatrix(const GraphAttributes &GA, Array< Array< double > > &pivDistMatrix)
Computes the pivot distance matrix based on the maxmin strategy.
double m_edgeCosts
The costs to traverse an edge.
Definition PivotMDS.h:120
void selfProduct(const Array< Array< double > > &d, Array< Array< double > > &result)
Computes the self product of d.
node getRootedPath(const Graph &G)
Checks whether the given graph is a path or not.
void setForcing2DLayout(bool forcing2DLayout)
Sets whether a 2D-layout should be calculated even when GraphAttributes::threeD is set.
Definition PivotMDS.h:80
void singularValueDecomposition(Array< Array< double > > &K, Array< Array< double > > &eVecs, Array< double > &eVals)
Computes the singular value decomposition of matrix K.
int m_dimensionCount
The dimension count determines the number of evecs that will be computed. Nevertheless PivotMDS only ...
Definition PivotMDS.h:117
void centerPivotmatrix(Array< Array< double > > &pivotMatrix)
Centers the pivot matrix.
void randomize(Array< Array< double > > &matrix)
Fills the given matrix with random doubles d 0 <= d <= 1.
static const double EPSILON
Convergence factor used for power iteration.
Definition PivotMDS.h:103
bool useEdgeCostsAttribute() const
Definition PivotMDS.h:99
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
The namespace for all OGDF objects.
bool isinf(T value)
Definition PivotMDS.h:49