Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
MasterBase.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Array.h>
35#include <ogdf/basic/Barrier.h>
36#include <ogdf/basic/Graph.h>
38#include <ogdf/basic/geometry.h>
40
41#include <cmath>
42#include <limits>
43
44namespace ogdf {
45class GraphAttributes;
46
47namespace spring_embedder {
48
50template<typename NodeInfo, typename ForceModelBase>
52protected:
57
62
63 ForceModelBase* m_forceModel;
64 ForceModelBase* m_forceModelImprove;
65
67
69
70 double m_tNull;
71 double m_cF;
72 double m_t;
74
78
79public:
81 DPoint& boundingBox)
82 : m_spring(spring)
83 , m_gc(gc)
84 , m_ga(ga)
85 , m_boundingBox(boundingBox)
86 , m_index(gc)
88 , m_disp(gc.numberOfNodes())
89 , m_adjLists(2 * gc.numberOfEdges())
90 , m_forceModel(nullptr)
91 , m_forceModelImprove(nullptr)
92 , m_barrier(nullptr)
93 , m_avgDisplacement(std::numeric_limits<double>::max())
94 , m_maxDisplacement(std::numeric_limits<double>::max()) { }
95
97 delete m_barrier;
98 delete m_forceModel;
100 }
101
102 int numberOfNodes() const { return m_vInfo.size(); }
103
104 int numberOfIterations() const { return m_spring.iterations(); }
105
107
109 // cool down
110 m_t = m_tNull = 0.25 * m_idealEdgeLength * sqrt(numberOfNodes());
111 m_cF = 2.0;
113
114 // convergence
115 m_avgDisplacement = std::numeric_limits<double>::max();
116 m_maxDisplacement = std::numeric_limits<double>::max();
117 }
118
120 // cool down
121 m_t = m_tNull;
122 m_cF = 2.0;
124
125 // convergence
126 m_avgDisplacement = std::numeric_limits<double>::max();
127 m_maxDisplacement = std::numeric_limits<double>::max();
128 }
129
130 void coolDown() {
132 m_t = m_tNull / std::log2(m_cF);
133
135 }
136
137 double maxForceLength() const { return m_t; }
138
139 double coolingFactor() const { return m_coolingFactor; }
140
141 double idealEdgeLength() const { return m_idealEdgeLength; }
142
143 bool noise() const { return m_spring.noise(); }
144
145 const GraphCopy& getGraph() const { return m_gc; }
146
148
149 const NodeArray<int>& index() const { return m_index; }
150
152
153 Array<DPoint>& disp() { return m_disp; }
154
156
157 const ForceModelBase& forceModel() const { return *m_forceModel; }
158
159 const ForceModelBase& forceModelImprove() const { return *m_forceModelImprove; }
160
161 void syncThreads() {
162 if (m_barrier) {
164 }
165 }
166
167 double scaleFactor() const { return m_scaleFactor; }
168
173
174 double avgDisplacement() const { return m_avgDisplacement; }
175
176 double maxDisplacement() const { return m_maxDisplacement; }
177};
178
179}
180}
Declaration and implementation of Array class and Array algorithms.
Implementation of a thread barrier.
Includes declaration of graph class.
Declaration of graph copy classes.
Declaration and definition of ogdf::SpringEmbedderBase.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
INDEX size() const
Returns the size (number of elements) of the array.
Definition Array.h:302
Representation of a barrier.
Definition Barrier.h:48
void threadSync()
Synchronizes the threads in the group.
Definition Barrier.h:68
Stores additional attributes of a graph (like layout information).
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:390
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
Base class for ogdf::SpringEmbedderGridVariant::Master.
Definition MasterBase.h:51
const ForceModelBase & forceModelImprove() const
Definition MasterBase.h:159
GraphAttributes & getAttributes()
Definition MasterBase.h:147
const ForceModelBase & forceModel() const
Definition MasterBase.h:157
const GraphCopy & getGraph() const
Definition MasterBase.h:145
const SpringEmbedderBase & m_spring
Definition MasterBase.h:53
ForceModelBase * m_forceModelImprove
Definition MasterBase.h:64
const NodeArray< int > & index() const
Definition MasterBase.h:149
MasterBase(const SpringEmbedderBase &spring, const GraphCopy &gc, GraphAttributes &ga, DPoint &boundingBox)
Definition MasterBase.h:80
Array< NodeInfo > & vInfo()
Definition MasterBase.h:151
Common base class for ogdf::SpringEmbedderBase and ogdf::SpringEmbedderGridVariant.
double maxConvergenceFactor() const
Returns the currently used maximum convergence factor.
bool noise() const
Returns the current setting of noise.
int iterationsImprove() const
Returns the current setting of iterations for the improvement phase.
int iterations() const
Returns the current setting of iterations.
double avgConvergenceFactor() const
Returns the currently used average convergence factor.
The namespace for all OGDF objects.
Definition GML.h:111