Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
45 namespace ogdf {
46 class GraphAttributes;
47 
48 template<typename T>
49 inline bool isinf(T value) {
50  return std::numeric_limits<T>::has_infinity && value == std::numeric_limits<T>::infinity();
51 }
52 
54 
58 public:
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 
101 private:
103  const static double EPSILON;
104 
106  const static double FACTOR;
107 
109  const static unsigned int SEED = 0;
110 
113 
118 
120  double m_edgeCosts;
121 
125 
129 
131  void centerPivotmatrix(Array<Array<double>>& pivotMatrix);
132 
134  void pivotMDSLayout(GraphAttributes& GA);
135 
136  void copySPSS(Array<double>& copyTo, NodeArray<double>& copyFrom);
137 
139  void doPathLayout(GraphAttributes& GA, const node& v);
140 
142  void eigenValueDecomposition(Array<Array<double>>& K, Array<Array<double>>& eVecs,
143  Array<double>& eValues);
144 
146  void getPivotDistanceMatrix(const GraphAttributes& GA, Array<Array<double>>& pivDistMatrix);
147 
149  node getRootedPath(const Graph& G);
150 
152  double normalize(Array<double>& x);
153 
155  double prod(const Array<double>& x, const Array<double>& y);
156 
158  void randomize(Array<Array<double>>& matrix);
159 
161  void selfProduct(const Array<Array<double>>& d, Array<Array<double>>& result);
162 
164  void singularValueDecomposition(Array<Array<double>>& K, Array<Array<double>>& eVecs,
165  Array<double>& eVals);
166 };
167 
168 }
ogdf::PivotMDS::m_edgeCosts
double m_edgeCosts
The costs to traverse an edge.
Definition: PivotMDS.h:120
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::PivotMDS::m_numberOfPivots
int m_numberOfPivots
The number of pivots.
Definition: PivotMDS.h:112
ogdf::PivotMDS::setEdgeCosts
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
Graph.h
Includes declaration of graph class.
ogdf::matching_blossom::infinity
TWeight infinity()
Helper function to get the maximum value for a given weight type.
Definition: utils.h:46
ogdf::PivotMDS::PivotMDS
PivotMDS()
Definition: PivotMDS.h:59
ogdf::PivotMDS::m_dimensionCount
int m_dimensionCount
The dimension count determines the number of evecs that will be computed. Nevertheless PivotMDS only ...
Definition: PivotMDS.h:117
ogdf::PivotMDS::setNumberOfPivots
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
ogdf::PivotMDS::m_hasEdgeCostsAttribute
bool m_hasEdgeCostsAttribute
Tells whether the pivot mds is based on uniform edge costs or a edge costs attribute.
Definition: PivotMDS.h:124
ogdf::PivotMDS::useEdgeCostsAttribute
bool useEdgeCostsAttribute() const
Definition: PivotMDS.h:99
LayoutModule.h
Declaration of interface for layout algorithms (class LayoutModule)
ogdf::PivotMDS::m_forcing2DLayout
bool m_forcing2DLayout
Whether a 2D-layout is calculated even when GraphAttributes::threeD is set.
Definition: PivotMDS.h:128
ogdf::PivotMDS
The Pivot MDS (multi-dimensional scaling) layout algorithm.
Definition: PivotMDS.h:57
ogdf::PivotMDS::~PivotMDS
virtual ~PivotMDS()
Definition: PivotMDS.h:66
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:219
ogdf::isinf
bool isinf(T value)
Definition: PivotMDS.h:49
ogdf::PivotMDS::setForcing2DLayout
void setForcing2DLayout(bool forcing2DLayout)
Sets whether a 2D-layout should be calculated even when GraphAttributes::threeD is set.
Definition: PivotMDS.h:80
ogdf::PivotMDS::EPSILON
const static double EPSILON
Convergence factor used for power iteration.
Definition: PivotMDS.h:103
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::PivotMDS::isForcing2DLayout
bool isForcing2DLayout() const
Returns whether a 2D-layout is calculated even when GraphAttributes::threeD is set.
Definition: PivotMDS.h:84
ogdf::PivotMDS::useEdgeCostsAttribute
void useEdgeCostsAttribute(bool useEdgeCostsAttribute)
Definition: PivotMDS.h:95
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::PivotMDS::FACTOR
const static double FACTOR
Factor used to center the pivot matrix.
Definition: PivotMDS.h:106
Array.h
Declaration and implementation of Array class and Array algorithms.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:45