Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/basic.h>
35#include <ogdf/basic/geometry.h>
36
37namespace ogdf {
38namespace spring_embedder {
39
40template<typename NodeInfo>
42public:
43 CommonForceModelBase(const Array<NodeInfo>& vInfo, const Array<int>& adjLists,
44 double idealEdgeLength)
45 : m_vInfo(vInfo), m_adjLists(adjLists), m_idealEdgeLength(idealEdgeLength) { }
46
47 double eps() const { return 0.01 * m_idealEdgeLength; }
48
49protected:
52
54
55 double normByIdealEdgeLength(double norm) const {
56 return (norm + eps()) / (m_idealEdgeLength + eps());
57 }
58
60 const NodeInfo& vj = m_vInfo[j];
61
62 // attractive forces on j: F_attr(d) = -d^2 / iel
63 DPoint force(0, 0);
64 for (int i = vj.m_adjBegin; i != vj.m_adjStop; ++i) {
65 int u = m_adjLists[i];
66
67 DPoint dist = vj.m_pos - m_vInfo[u].m_pos;
68 double d = dist.norm();
69
70 dist *= d;
71 force -= dist;
72 }
73
74 force /= std::pow(m_idealEdgeLength, idealExponent);
75
76 return force;
77 }
78};
79
80}
81}
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
Basic declarations, included by all source files.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:214
double normByIdealEdgeLength(double norm) const
Definition common.h:55
CommonForceModelBase(const Array< NodeInfo > &vInfo, const Array< int > &adjLists, double idealEdgeLength)
Definition common.h:43
DPoint computeFruchtermanReingoldAttractiveForce(int j, int idealExponent) const
Definition common.h:59
const Array< NodeInfo > & m_vInfo
Definition common.h:50
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.