Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
EnergyFunction.h
Go to the documentation of this file.
1
36#pragma once
37
38#include <ogdf/basic/Graph.h>
40#include <ogdf/basic/basic.h>
41#include <ogdf/basic/geometry.h>
42
43#include <string>
44
45namespace ogdf {
46namespace davidson_harel {
47
49
53public:
55 EnergyFunction(const string& funcname, GraphAttributes& AG);
56
57 virtual ~EnergyFunction() { }
58
60 virtual void computeEnergy() = 0;
61
63 double computeCandidateEnergy(const node v, const DPoint& newPos);
64
66 string getName() const { return m_name; }
67
72
73#ifdef OGDF_DEBUG
75 void printStatus() const;
76#endif
77
78 double energy() const { return m_energy; }
79
80protected:
81 const Graph& m_G;
82 const string m_name;
84 double m_energy;
85
87 DPoint testPos() { return m_testPos; }
88
90 DPoint currentPos(const node v) const { return m_AG.point(v); }
91
93 node testNode() const { return m_testNode; }
94
96 virtual void internalCandidateTaken() = 0;
97
99 virtual void compCandEnergy() = 0;
100
101#ifdef OGDF_DEBUG
102 virtual void printInternalData() const = 0;
103#endif
104
105private:
108
111
115};
116
117}
118}
Includes declaration of graph class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
Basic declarations, included by all source files.
Stores additional attributes of a graph (like layout information).
DPoint point(node v) const
Returns a DPoint corresponding to the x- and y-coordinates of v.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Class for the representation of nodes.
Definition Graph_d.h:241
The interface for energy functions for the Davidson Harel graph drawing method.
const string m_name
name of the energy function
EnergyFunction & operator=(const EnergyFunction &e)
the assignment operator is fake and can not be used.
const Graph & m_G
the graph that should be drawn
virtual void internalCandidateTaken()=0
changes the data of a specific energy function if the candidate was taken
DPoint currentPos(const node v) const
returns the current position of vertex v
node m_testNode
The node that changed position in the candidate.
void printStatus() const
prints status information for debugging
string getName() const
prints the name of the energy function
node testNode() const
returns the vertex that is under consideration in the current step
GraphAttributes & m_AG
This stores the graph with its graphical attributes and the current positions for the vertices.
DPoint m_testPos
New candidate positions for m_testNode.
EnergyFunction(const string &funcname, GraphAttributes &AG)
Initializes data dtructures to speed up later computations.
double m_candidateEnergy
the energy of the layout if the candidate layout is chosen
DPoint testPos()
returns candidate position for the node to be moved
virtual void computeEnergy()=0
computes energy for the layout at the beginning of the optimization process
virtual void printInternalData() const =0
double computeCandidateEnergy(const node v, const DPoint &newPos)
sets m_testNode, m_testX and m_testY and computes the energy for the new configuration (vertex v move...
void candidateTaken()
Changes m_currentX and m_currentY by setting the position of m_testNode to m_testX and m_testY....
double m_energy
energy of the current layout
EnergyFunction(const EnergyFunction &e)
the copy constructor is fake and can not be used.
virtual void compCandEnergy()=0
computes the energy if m_testNode changes position to m_testX and m_testY, sets the value of m_candid...
The namespace for all OGDF objects.