Open
Graph Drawing
Framework
v. 2023.09 (Elderberry)
Overview
Class Hierarchy
Class Index
Class List
Members
Namespaces
Source Files
common.h
Go to the documentation of this file.
1
32
#pragma once
33
34
#include <
ogdf/basic/Array.h
>
35
#include <
ogdf/basic/geometry.h
>
36
37
#include <cmath>
38
39
namespace
ogdf
{
40
namespace
spring_embedder {
41
42
template
<
typename
NodeInfo>
43
class
CommonForceModelBase
{
44
public
:
45
CommonForceModelBase
(
const
Array<NodeInfo>
& vInfo,
const
Array<int>
& adjLists,
46
double
idealEdgeLength)
47
:
m_vInfo
(vInfo),
m_adjLists
(adjLists),
m_idealEdgeLength
(idealEdgeLength) { }
48
49
double
eps
()
const
{
return
0.01 *
m_idealEdgeLength
; }
50
51
protected
:
52
const
Array<NodeInfo>
&
m_vInfo
;
53
const
Array<int>
&
m_adjLists
;
54
55
double
m_idealEdgeLength
;
56
57
double
normByIdealEdgeLength
(
double
norm)
const
{
58
return
(norm +
eps
()) / (
m_idealEdgeLength
+
eps
());
59
}
60
61
DPoint
computeFruchtermanReingoldAttractiveForce
(
int
j,
int
idealExponent)
const
{
62
const
NodeInfo& vj =
m_vInfo
[j];
63
64
// attractive forces on j: F_attr(d) = -d^2 / iel
65
DPoint
force(0, 0);
66
for
(
int
i = vj.m_adjBegin; i != vj.m_adjStop; ++i) {
67
int
u =
m_adjLists
[i];
68
69
DPoint
dist = vj.m_pos -
m_vInfo
[u].m_pos;
70
double
d = dist.
norm
();
71
72
dist *= d;
73
force -= dist;
74
}
75
76
force /= std::pow(
m_idealEdgeLength
, idealExponent);
77
78
return
force;
79
}
80
};
81
82
}
83
}
ogdf
The namespace for all OGDF objects.
Definition:
multilevelmixer.cpp:39
ogdf::spring_embedder::CommonForceModelBase::eps
double eps() const
Definition:
common.h:49
ogdf::GenericPoint< double >
ogdf::spring_embedder::CommonForceModelBase::m_adjLists
const Array< int > & m_adjLists
Definition:
common.h:53
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::spring_embedder::CommonForceModelBase
Definition:
common.h:43
ogdf::spring_embedder::CommonForceModelBase::computeFruchtermanReingoldAttractiveForce
DPoint computeFruchtermanReingoldAttractiveForce(int j, int idealExponent) const
Definition:
common.h:61
ogdf::spring_embedder::CommonForceModelBase::normByIdealEdgeLength
double normByIdealEdgeLength(double norm) const
Definition:
common.h:57
ogdf::Array< NodeInfo >
ogdf::GenericPoint::norm
double norm() const
Returns the norm of the point.
Definition:
geometry.h:165
ogdf::spring_embedder::CommonForceModelBase::m_vInfo
const Array< NodeInfo > & m_vInfo
Definition:
common.h:52
Array.h
Declaration and implementation of Array class and Array algorithms.
ogdf::spring_embedder::CommonForceModelBase::m_idealEdgeLength
double m_idealEdgeLength
Definition:
common.h:55
ogdf::spring_embedder::CommonForceModelBase::CommonForceModelBase
CommonForceModelBase(const Array< NodeInfo > &vInfo, const Array< int > &adjLists, double idealEdgeLength)
Definition:
common.h:45
include
ogdf
energybased
spring_embedder
common.h
This site is powered by Netlify.
© 1999–2024
The OGDF Team