Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
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
42namespace ogdf {
43class GraphAttributes;
44
47public:
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
104private:
109
114
115 public:
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;
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}
Declaration and implementation of Array class and Array algorithms.
Declaration of interface for energy-based layout algorithms (class ForceLayoutModule)
Includes declaration of graph class.
Declaration of singly linked lists and iterators.
Basic declarations, included by all source files.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
Interface of general layout algorithms.
Stores additional attributes of a graph (like layout information).
Class for the representation of nodes.
Definition Graph_d.h:241
Singly linked lists (maintaining the length of the list).
Definition SList.h:845
const SList< node > & nodesInCC(int i) const
Fruchterman-Reingold algorithm with (exact) layout.
bool noise() const
Returns the current setting of nodes.
double pageRatio()
Returns the page ratio.
SpringEmbedderFRExact()
Creates an instance of Fruchterman/Reingold (exact) layout.
double minDistCC() const
Returns the minimum distance between connected components.
void initialize(ArrayGraph &component)
void coolingFunction(CoolingFunction f)
Sets the parameter coolingFunction to f.
int m_iterations
The number of iterations.
double m_minDistCC
The minimal distance between connected components.
CoolingFunction coolingFunction() const
Returns the current setting for the cooling function.
bool m_noise
Perform random perturbations?
void iterations(int i)
Sets the number of iterations to i.
void noise(bool on)
Sets the parameter noise to on.
double idealEdgeLength() const
Returns the ideal edge length.
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm for graph attributes GA.
CoolingFunction m_coolingFunction
The selected cooling function.
int iterations() const
Returns the current setting of iterations.
void nodeWeights(bool on)
Switches use of node weights given in GraphAttributtes.
void minDistCC(double x)
Sets the minimum distance between connected components to x.
void idealEdgeLength(double len)
Sets the ideal edge length to len.
void pageRatio(double x)
Sets the page ration to x.
double m_idealEdgeLength
The ideal edge length.
void mainStep_sse3(ArrayGraph &component)
void mainStep(ArrayGraph &component)
void cool(double &tx, double &ty, int &cF)
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
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.