Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

SpringEmbedderFRExact.h
Go to the documentation of this file.
1 
33 #pragma once
34 
36 #include <ogdf/basic/SList.h>
38 
39 namespace ogdf {
40 
42 {
43 public:
44  enum class CoolingFunction { Factor, Logarithmic };
45 
48 
49  // destructor
51 
52 
54  virtual void call(GraphAttributes &GA) override;
55 
56 
58  int iterations() const {
59  return m_iterations;
60  }
61 
63  void iterations(int i) {
64  OGDF_ASSERT(i > 0);
65  m_iterations = i;
66  }
67 
69  bool noise() const {
70  return m_noise;
71  }
72 
74  void noise(bool on) {
75  m_noise = on;
76  }
77 
79  void nodeWeights(bool on) {
80  m_useNodeWeight = on;
81  }
84  return m_coolingFunction;
85  }
86 
89  m_coolingFunction = f;
90  }
91 
93  double idealEdgeLength() const { return m_idealEdgeLength; }
94 
96  void idealEdgeLength(double len) { m_idealEdgeLength = len; }
97 
99  double minDistCC() const { return m_minDistCC; }
100 
102  void minDistCC(double x) { m_minDistCC = x; }
103 
105  double pageRatio() { return m_pageRatio; }
106 
108  void pageRatio(double x) { m_pageRatio = x; }
109 
110  void checkConvergence(bool b) {m_checkConvergence = b;}
111  bool checkConvergence() {return m_checkConvergence;}
112  void convTolerance(double tol) {m_convTolerance = tol;}
113 
114 private:
116  {
119  int m_numCC;
120 
125 
126  public:
127  explicit ArrayGraph(GraphAttributes &ga);
128  ~ArrayGraph();
129 
130  void initCC(int i);
131 
132  int numberOfCCs() const { return m_numCC; }
133  int numberOfNodes() const { return m_numNodes; }
134  int numberOfEdges() const { return m_numEdges; }
135 
136  node original(int v) const { return m_orig[v]; }
137  const SList<node> &nodesInCC(int i) const { return m_nodesInCC[i]; }
138 
139  int *m_src;
140  int *m_tgt;
141  double *m_x;
142  double *m_y;
143  double *m_nodeWeight;
144  //this should be part of a multilevel layout interface class later on
145  bool m_useNodeWeight; //should given nodeweights be used or all set to 1.0?
146  };
147 
148  double log2(double x) { return log(x) / log(2.0); }
149  double mylog2(int x) {
150  double l = 0.0;
151  while(x > 0) {
152  l++;
153  x >>= 1;
154  }
155  return l/2;
156  }
157 
158  void initialize(ArrayGraph &component);
159  void mainStep(ArrayGraph &component);
160  void mainStep_sse3(ArrayGraph &component);
161 
162 #if 0
163  // Fruchterman, Reingold
164  double f_att(double d) { return d*d / m_idealEdgeLength; }
165  double f_rep(double d) { return m_idealEdgeLength*m_idealEdgeLength / d; }
166 
167  // Eades
168  double f_att(double d) { return 5.0 * d * log2(d/m_idealEdgeLength); }
169  double f_rep(double d) { return 20.0 / d; }
170 #endif
171 
172  // cooling function
173  void cool(double &tx, double &ty, int &cF);
174 
176  bool m_noise;
178 
179 #if 0
180  double m_tx;
181  double m_ty;
182 #endif
183 
186 
188  double m_minDistCC;
189  double m_pageRatio;
190 
191 #if 0
192  int m_cF;
193 #endif
194  double m_txNull;
195  double m_tyNull;
196  //see above at ArrayGraph
198  bool m_checkConvergence; //<! If set to true, computation is stopped if movement falls below threshold
199  double m_convTolerance; //<! Fraction of ideal edge length below which convergence is achieved
200 };
201 
202 
203 } // end namespace ogdf
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.
void minDistCC(double x)
Sets the minimum distance between connected components to x.
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:56
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:777
double m_pageRatio
The page ratio.
int iterations() const
Returns the current setting of iterations.
double idealEdgeLength() const
Returns the ideal edge length.
Declaration of class GraphCopy Attributes which manages access on a copy of an attributed graph...
void idealEdgeLength(double len)
Sets the ideal edge length to len.
Stores additional attributes of a graph (like layout information).
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:167
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.