Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

SpringEmbedderFRExact.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Array.h>
35 #include <ogdf/basic/Graph.h>
36 #include <ogdf/basic/SList.h>
37 #include <ogdf/basic/basic.h>
39 
40 #include <cmath>
41 
42 namespace ogdf {
43 class GraphAttributes;
44 
47 public:
48  enum class CoolingFunction { Factor, Logarithmic };
49 
52 
54  virtual void call(GraphAttributes& GA) override;
55 
57  int iterations() const { return m_iterations; }
58 
60  void iterations(int i) {
61  OGDF_ASSERT(i > 0);
62  m_iterations = i;
63  }
64 
66  bool noise() const { return m_noise; }
67 
69  void noise(bool on) { m_noise = on; }
70 
72  void nodeWeights(bool on) { m_useNodeWeight = on; }
73 
75  CoolingFunction coolingFunction() const { return m_coolingFunction; }
76 
78  void coolingFunction(CoolingFunction f) { m_coolingFunction = f; }
79 
81  double idealEdgeLength() const { return m_idealEdgeLength; }
82 
84  void idealEdgeLength(double len) { m_idealEdgeLength = len; }
85 
87  double minDistCC() const { return m_minDistCC; }
88 
90  void minDistCC(double x) { m_minDistCC = x; }
91 
93  double pageRatio() { return m_pageRatio; }
94 
96  void pageRatio(double x) { m_pageRatio = x; }
97 
98  void checkConvergence(bool b) { m_checkConvergence = b; }
99 
100  bool checkConvergence() { return m_checkConvergence; }
101 
102  void convTolerance(double tol) { m_convTolerance = tol; }
103 
104 private:
105  class ArrayGraph {
108  int m_numCC;
109 
114 
115  public:
116  explicit ArrayGraph(GraphAttributes& ga);
117  ~ArrayGraph();
118 
119  void initCC(int i);
120 
121  int numberOfCCs() const { return m_numCC; }
122 
123  int numberOfNodes() const { return m_numNodes; }
124 
125  int numberOfEdges() const { return m_numEdges; }
126 
127  node original(int v) const { return m_orig[v]; }
128 
129  const SList<node>& nodesInCC(int i) const { return m_nodesInCC[i]; }
130 
131  int* m_src;
132  int* m_tgt;
133  double* m_x;
134  double* m_y;
135  double* m_nodeWeight;
136  //this should be part of a multilevel layout interface class later on
137  bool m_useNodeWeight; //should given nodeweights be used or all set to 1.0?
138  };
139 
140  double log2(double x) { return log(x) / log(2.0); }
141 
142  double mylog2(int x) {
143  double result = 0.0;
144  while (x > 0) {
145  result++;
146  x >>= 1;
147  }
148  return result / 2;
149  }
150 
151  void initialize(ArrayGraph& component);
152  void mainStep(ArrayGraph& component);
153  void mainStep_sse3(ArrayGraph& component);
154 
155 #if 0
156  // Fruchterman, Reingold
157  double f_att(double d) { return d*d / m_idealEdgeLength; }
158  double f_rep(double d) { return m_idealEdgeLength*m_idealEdgeLength / d; }
159 
160  // Eades
161  double f_att(double d) { return 5.0 * d * log2(d/m_idealEdgeLength); }
162  double f_rep(double d) { return 20.0 / d; }
163 #endif
164 
165  // cooling function
166  void cool(double& tx, double& ty, int& cF);
167 
169  bool m_noise;
171 
172 #if 0
173  double m_tx;
174  double m_ty;
175 #endif
176 
179 
181  double m_minDistCC;
182  double m_pageRatio;
183 
184 #if 0
185  int m_cF;
186 #endif
187  double m_txNull;
188  double m_tyNull;
189  //see above at ArrayGraph
191  bool m_checkConvergence; //<! If set to true, computation is stopped if movement falls below threshold
192  double m_convTolerance; //<! Fraction of ideal edge length below which convergence is achieved
193 };
194 
195 }
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::SpringEmbedderFRExact::ArrayGraph::m_useNodeWeight
bool m_useNodeWeight
Definition: SpringEmbedderFRExact.h:137
ogdf::SpringEmbedderFRExact::m_minDistCC
double m_minDistCC
The minimal distance between connected components.
Definition: SpringEmbedderFRExact.h:181
ogdf::SpringEmbedderFRExact::log2
double log2(double x)
Definition: SpringEmbedderFRExact.h:140
ogdf::SpringEmbedderFRExact::m_idealEdgeLength
double m_idealEdgeLength
The ideal edge length.
Definition: SpringEmbedderFRExact.h:180
Graph.h
Includes declaration of graph class.
ogdf::SpringEmbedderFRExact::ArrayGraph
Definition: SpringEmbedderFRExact.h:105
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::SpringEmbedderFRExact::ArrayGraph::m_nodesInCC
Array< SList< node > > m_nodesInCC
Definition: SpringEmbedderFRExact.h:112
ogdf::SpringEmbedderFRExact::m_coolFactor_y
double m_coolFactor_y
Definition: SpringEmbedderFRExact.h:178
ogdf::SpringEmbedderFRExact::ArrayGraph::numberOfCCs
int numberOfCCs() const
Definition: SpringEmbedderFRExact.h:121
ogdf::SpringEmbedderFRExact
Fruchterman-Reingold algorithm with (exact) layout.
Definition: SpringEmbedderFRExact.h:46
ogdf::SpringEmbedderFRExact::ArrayGraph::m_nodeWeight
double * m_nodeWeight
Definition: SpringEmbedderFRExact.h:135
ogdf::SpringEmbedderFRExact::CoolingFunction
CoolingFunction
Definition: SpringEmbedderFRExact.h:48
ogdf::SpringEmbedderFRExact::ArrayGraph::m_tgt
int * m_tgt
Definition: SpringEmbedderFRExact.h:132
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:845
ogdf::ForceLayoutModule
Interface of general layout algorithms.
Definition: ForceLayoutModule.h:47
ogdf::SpringEmbedderFRExact::ArrayGraph::m_y
double * m_y
Definition: SpringEmbedderFRExact.h:134
ogdf::SpringEmbedderFRExact::ArrayGraph::m_ga
GraphAttributes * m_ga
Definition: SpringEmbedderFRExact.h:110
ogdf::SpringEmbedderFRExact::m_coolFactor_x
double m_coolFactor_x
Definition: SpringEmbedderFRExact.h:177
ogdf::SpringEmbedderFRExact::ArrayGraph::nodesInCC
const SList< node > & nodesInCC(int i) const
Definition: SpringEmbedderFRExact.h:129
ForceLayoutModule.h
Declaration of interface for energy-based layout algorithms (class ForceLayoutModule)
ogdf::SpringEmbedderFRExact::idealEdgeLength
void idealEdgeLength(double len)
Sets the ideal edge length to len.
Definition: SpringEmbedderFRExact.h:84
ogdf::SpringEmbedderFRExact::m_useNodeWeight
bool m_useNodeWeight
Definition: SpringEmbedderFRExact.h:190
ogdf::SpringEmbedderFRExact::iterations
void iterations(int i)
Sets the number of iterations to i.
Definition: SpringEmbedderFRExact.h:60
ogdf::SpringEmbedderFRExact::checkConvergence
bool checkConvergence()
Definition: SpringEmbedderFRExact.h:100
ogdf::SpringEmbedderFRExact::ArrayGraph::m_numNodes
int m_numNodes
Definition: SpringEmbedderFRExact.h:106
ogdf::SpringEmbedderFRExact::ArrayGraph::m_mapNode
NodeArray< int > m_mapNode
Definition: SpringEmbedderFRExact.h:113
ogdf::SpringEmbedderFRExact::idealEdgeLength
double idealEdgeLength() const
Returns the ideal edge length.
Definition: SpringEmbedderFRExact.h:81
ogdf::SpringEmbedderFRExact::ArrayGraph::m_x
double * m_x
Definition: SpringEmbedderFRExact.h:133
ogdf::SpringEmbedderFRExact::m_noise
bool m_noise
Perform random perturbations?
Definition: SpringEmbedderFRExact.h:169
ogdf::SpringEmbedderFRExact::m_tyNull
double m_tyNull
Definition: SpringEmbedderFRExact.h:188
SList.h
Declaration of singly linked lists and iterators.
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:219
ogdf::SpringEmbedderFRExact::convTolerance
void convTolerance(double tol)
Definition: SpringEmbedderFRExact.h:102
ogdf::MeasureEnum::log
@ log
ogdf::SpringEmbedderFRExact::m_iterations
int m_iterations
The number of iterations.
Definition: SpringEmbedderFRExact.h:168
ogdf::SpringEmbedderFRExact::coolingFunction
void coolingFunction(CoolingFunction f)
Sets the parameter coolingFunction to f.
Definition: SpringEmbedderFRExact.h:78
ogdf::SpringEmbedderFRExact::ArrayGraph::m_numCC
int m_numCC
Definition: SpringEmbedderFRExact.h:108
ogdf::SpringEmbedderFRExact::ArrayGraph::numberOfEdges
int numberOfEdges() const
Definition: SpringEmbedderFRExact.h:125
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::SpringEmbedderFRExact::nodeWeights
void nodeWeights(bool on)
Switches use of node weights given in GraphAttributtes.
Definition: SpringEmbedderFRExact.h:72
ogdf::SpringEmbedderFRExact::mylog2
double mylog2(int x)
Definition: SpringEmbedderFRExact.h:142
ogdf::SpringEmbedderFRExact::checkConvergence
void checkConvergence(bool b)
Definition: SpringEmbedderFRExact.h:98
ogdf::SpringEmbedderFRExact::ArrayGraph::m_orig
node * m_orig
Definition: SpringEmbedderFRExact.h:111
ogdf::SpringEmbedderFRExact::pageRatio
double pageRatio()
Returns the page ratio.
Definition: SpringEmbedderFRExact.h:93
ogdf::SpringEmbedderFRExact::iterations
int iterations() const
Returns the current setting of iterations.
Definition: SpringEmbedderFRExact.h:57
ogdf::SpringEmbedderFRExact::minDistCC
void minDistCC(double x)
Sets the minimum distance between connected components to x.
Definition: SpringEmbedderFRExact.h:90
ogdf::SpringEmbedderFRExact::m_coolingFunction
CoolingFunction m_coolingFunction
The selected cooling function.
Definition: SpringEmbedderFRExact.h:170
ogdf::SpringEmbedderFRExact::ArrayGraph::original
node original(int v) const
Definition: SpringEmbedderFRExact.h:127
basic.h
Basic declarations, included by all source files.
ogdf::SpringEmbedderFRExact::m_pageRatio
double m_pageRatio
The page ratio.
Definition: SpringEmbedderFRExact.h:182
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::SpringEmbedderFRExact::coolingFunction
CoolingFunction coolingFunction() const
Returns the current setting for the cooling function.
Definition: SpringEmbedderFRExact.h:75
ogdf::Math::log2
T log2(T x)
Returns the logarithm of x to the base 2.
Definition: Math.h:111
ogdf::SpringEmbedderFRExact::ArrayGraph::m_numEdges
int m_numEdges
Definition: SpringEmbedderFRExact.h:107
Array.h
Declaration and implementation of Array class and Array algorithms.
ogdf::SpringEmbedderFRExact::noise
void noise(bool on)
Sets the parameter noise to on.
Definition: SpringEmbedderFRExact.h:69
ogdf::SpringEmbedderFRExact::ArrayGraph::numberOfNodes
int numberOfNodes() const
Definition: SpringEmbedderFRExact.h:123
ogdf::SpringEmbedderFRExact::m_convTolerance
double m_convTolerance
Definition: SpringEmbedderFRExact.h:192
ogdf::SpringEmbedderFRExact::ArrayGraph::m_src
int * m_src
Definition: SpringEmbedderFRExact.h:131
ogdf::SpringEmbedderFRExact::minDistCC
double minDistCC() const
Returns the minimum distance between connected components.
Definition: SpringEmbedderFRExact.h:87
ogdf::SpringEmbedderFRExact::noise
bool noise() const
Returns the current setting of nodes.
Definition: SpringEmbedderFRExact.h:66
ogdf::SpringEmbedderFRExact::m_checkConvergence
bool m_checkConvergence
Definition: SpringEmbedderFRExact.h:191
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::SpringEmbedderFRExact::m_txNull
double m_txNull
Definition: SpringEmbedderFRExact.h:187
ogdf::SpringEmbedderFRExact::pageRatio
void pageRatio(double x)
Sets the page ration to x.
Definition: SpringEmbedderFRExact.h:96