Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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