Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
45 namespace ogdf {
46 namespace davidson_harel {
47 
49 
53 public:
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 
71  void candidateTaken();
72 
73 #ifdef OGDF_DEBUG
74  void printStatus() const;
76 #endif
77 
78  double energy() const { return m_energy; }
79 
80 protected:
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 
105 private:
108 
111 
115 };
116 
117 }
118 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::davidson_harel::EnergyFunction::m_name
const string m_name
name of the energy function
Definition: EnergyFunction.h:82
Graph.h
Includes declaration of graph class.
ogdf::davidson_harel::EnergyFunction::testPos
DPoint testPos()
returns candidate position for the node to be moved
Definition: EnergyFunction.h:87
ogdf::GenericPoint< double >
ogdf::davidson_harel::EnergyFunction::EnergyFunction
EnergyFunction(const EnergyFunction &e)
the copy constructor is fake and can not be used.
Definition: EnergyFunction.h:107
ogdf::davidson_harel::EnergyFunction::m_candidateEnergy
double m_candidateEnergy
the energy of the layout if the candidate layout is chosen
Definition: EnergyFunction.h:83
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::davidson_harel::EnergyFunction::currentPos
DPoint currentPos(const node v) const
returns the current position of vertex v
Definition: EnergyFunction.h:90
ogdf::davidson_harel::EnergyFunction::m_AG
GraphAttributes & m_AG
This stores the graph with its graphical attributes and the current positions for the vertices.
Definition: EnergyFunction.h:112
ogdf::davidson_harel::EnergyFunction::m_G
const Graph & m_G
the graph that should be drawn
Definition: EnergyFunction.h:81
ogdf::davidson_harel::EnergyFunction::internalCandidateTaken
virtual void internalCandidateTaken()=0
changes the data of a specific energy function if the candidate was taken
ogdf::davidson_harel::EnergyFunction::EnergyFunction
EnergyFunction(const string &funcname, GraphAttributes &AG)
Initializes data dtructures to speed up later computations.
ogdf::davidson_harel::EnergyFunction::compCandEnergy
virtual void compCandEnergy()=0
computes the energy if m_testNode changes position to m_testX and m_testY, sets the value of m_candid...
ogdf::davidson_harel::EnergyFunction::m_testNode
node m_testNode
The node that changed position in the candidate.
Definition: EnergyFunction.h:113
ogdf::davidson_harel::EnergyFunction::computeCandidateEnergy
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...
ogdf::davidson_harel::EnergyFunction::~EnergyFunction
virtual ~EnergyFunction()
Definition: EnergyFunction.h:57
ogdf::davidson_harel::EnergyFunction::energy
double energy() const
Definition: EnergyFunction.h:78
ogdf::davidson_harel::EnergyFunction::m_energy
double m_energy
energy of the current layout
Definition: EnergyFunction.h:84
ogdf::davidson_harel::EnergyFunction::candidateTaken
void candidateTaken()
Changes m_currentX and m_currentY by setting the position of m_testNode to m_testX and m_testY....
ogdf::GraphAttributes::point
DPoint point(node v) const
Returns a DPoint corresponding to the x- and y-coordinates of v.
Definition: GraphAttributes.h:1050
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::davidson_harel::EnergyFunction::getName
string getName() const
prints the name of the energy function
Definition: EnergyFunction.h:66
ogdf::davidson_harel::EnergyFunction::m_testPos
DPoint m_testPos
New candidate positions for m_testNode.
Definition: EnergyFunction.h:114
ogdf::davidson_harel::EnergyFunction::testNode
node testNode() const
returns the vertex that is under consideration in the current step
Definition: EnergyFunction.h:93
basic.h
Basic declarations, included by all source files.
ogdf::davidson_harel::EnergyFunction
The interface for energy functions for the Davidson Harel graph drawing method.
Definition: EnergyFunction.h:52
ogdf::davidson_harel::EnergyFunction::printInternalData
virtual void printInternalData() const =0
ogdf::davidson_harel::EnergyFunction::operator=
EnergyFunction & operator=(const EnergyFunction &e)
the assignment operator is fake and can not be used.
ogdf::davidson_harel::EnergyFunction::computeEnergy
virtual void computeEnergy()=0
computes energy for the layout at the beginning of the optimization process
ogdf::davidson_harel::EnergyFunction::printStatus
void printStatus() const
prints status information for debugging
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240