81 , m_ltolerance(0.0001)
82 , m_computeMaxIt(
true)
84 , m_prevEnergy(startVal)
85 , m_prevLEnergy(startVal)
92 m_maxLocalIt = m_maxGlobalIt = maxVal;
162 void noise(
bool on) {
173 if (m_prevEnergy == startVal)
180 double diff = m_prevEnergy -
maxdelta;
181 if (diff < 0.0) diff = -diff;
183 std::cout <<
"Finished(): maxdelta: " <<
maxdelta <<
" diff/prev: " << diff / m_prevEnergy << std::endl;
190 m_prevLEnergy = startVal;
197 if (m_prevLEnergy == startVal) {
203 std::cout <<
"Local delta: " <<
deltav <<
"\n";
206 double diff = m_prevLEnergy -
deltav;
208 bool done =
deltav == 0.0 || diff / m_prevLEnergy < m_ltolerance;
271 const double threshold = std::numeric_limits<double>::max());
278 double pageRatio() {
return m_pageRatio; }
281 void pageRatio(
double x) { m_pageRatio = x; }
284 Scaling scaling()
const {
289 void scaling(Scaling
sc) {
294 double scaleFunctionFactor()
const {
295 return m_scaleFactor;
299 void scaleFunctionFactor(
double f) {
Declaration and implementation of class Array2D which implements dynamic two dimensional arrays.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declaration of interface for layout algorithms (class LayoutModule)
Dynamic arrays indexed with edges.
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Interface of general layout algorithms.
Dynamic arrays indexed with nodes.
Class for the representation of nodes.
The spring-embedder layout algorithm by Kamada and Kawai.
double m_prevEnergy
Big K constant for strength computation.
void doCall(GraphAttributes &GA, const EdgeArray< double > &eLength, bool simpleBFS)
Does the actual call.
static const double desMinLength
Defines minimum desired edge length.
void initialize(GraphAttributes &GA, NodeArray< dpair > &partialDer, const EdgeArray< double > &eLength, NodeArray< NodeArray< double > > &oLength, NodeArray< NodeArray< double > > &sstrength, bool simpleBFS)
Does the necessary initialization work for the call functions.
bool finishedNode(double deltav)
Checks if inner loop (current node) is finished.
void shufflePositions(GraphAttributes &GA)
Adapts positions to avoid degeneracy (all nodes on a single point)
void setStopTolerance(double s)
Sets the value for the stop tolerance, below which the system is regarded stable (balanced) and the o...
static const double minVal
void scale(GraphAttributes &GA)
Does the scaling if no edge lengths are given but node sizes are respected.
int m_maxLocalIt
Maximum number of local iterations.
bool finished(double maxdelta)
Checks if main loop is finished because local optimum reached.
double m_ltolerance
value for local stop criterion
static const double startVal
void adaptLengths(const Graph &G, const GraphAttributes &GA, const EdgeArray< double > &eLengths, EdgeArray< double > &adaptedLengths)
Changes given edge lengths (interpreted as weight factors) according to additional parameters like no...
double allpairssp(const Graph &G, const EdgeArray< double > &eLengths, NodeArray< NodeArray< double > > &distance, const double threshold=std::numeric_limits< double >::max())
dpair computeParDer(node m, node u, GraphAttributes &GA, NodeArray< NodeArray< double > > &ss, NodeArray< NodeArray< double > > &dist)
Computes contribution of node u to the first partial derivatives (dE/dx_m, dE/dy_m) (for node m) (eq....
int m_gItFactor
factor for global iterations: m_gItBaseVal+m_gItFactor*|V|
double m_prevLEnergy
local energy
double m_zeroLength
Length of a side of the display area, used for edge length computation if > 0.
void setZeroLength(double d)
If set != 0, value zerolength is used to determine the desirable edge length by L = zerolength / max ...
static const int maxVal
defines infinite upper bound for iteration number
dpair computeParDers(node v, GraphAttributes &GA, NodeArray< NodeArray< double > > &ss, NodeArray< NodeArray< double > > &dist)
Compute partial derivative for v.
bool m_computeMaxIt
If true, number of iterations is computed depending on number of nodes.
virtual void call(GraphAttributes &GA) override
Calls the layout algorithm for graph attributes GA. Currently, GA.doubleWeight is NOT used to allow s...
int m_gItBaseVal
minimum number of global iterations
void mainStep(GraphAttributes &GA, NodeArray< dpair > &partialDer, NodeArray< NodeArray< double > > &oLength, NodeArray< NodeArray< double > > &sstrength)
Main computation loop, nodes are moved here.
void setUseLayout(bool b)
If set to true, the given layout is used for the initial positions.
void setMaxGlobalIterations(int i)
Sets the number of global iterations to i.
void setMaxLocalIterations(int i)
Sets the number of local iterations to i.
double m_tolerance
The stop criterion when the forces of all strings are considered to be balanced.
int maxGlobalIterations() const
double m_desLength
Desirable edge length, used instead if > 0.
void setDesLength(double d)
Sets desirable edge length directly.
void setGlobalIterationFactor(int i)
double allpairsspBFS(const Graph &G, NodeArray< NodeArray< double > > &distance)
bool m_useLayout
use positions or allow to shuffle nodes to avoid degeneration
int m_maxGlobalIt
Maximum number of global iterations.
int maxLocalIterations() const
It is possible to limit the number of iterations to a fixed value Returns the current setting of iter...
void computeMaxIterations(bool b)
If set to true, number of iterations is computed depending on G.
void call(GraphAttributes &GA, const EdgeArray< double > &eLength)
Calls the layout algorithm for graph attributes GA using values in eLength for distance computation....
SpringEmbedderKK()
Constructor: Constructs instance of Kamada Kawai Layout.
Tuples of two elements (2-tuples).
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
Declaration and implementation of class Tuple2, Tuple3 and Tuple4.