Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
NodePairEnergy.h
Go to the documentation of this file.
1
34#pragma once
35
37#include <ogdf/basic/Array2D.h>
39
40namespace ogdf {
41namespace davidson_harel {
42
44public:
45 //Initializes data dtructures to speed up later computations
47
48 virtual ~NodePairEnergy() {
49 delete m_nodeNums;
50 delete m_pairEnergy;
51 }
52
53 //computes the energy of the initial layout
54 void computeEnergy() override;
55
56protected:
58 virtual double computeCoordEnergy(node, node, const DPoint&, const DPoint&) const = 0;
59
61 int nodeNum(node v) const { return (*m_nodeNums)[v]; }
62
64 bool adjacent(const node v, const node w) const { return m_adjacentOracle.adjacent(v, w); }
65
67 const DIntersectableRect& shape(const node v) const { return m_shape[v]; }
68
69#ifdef OGDF_DEBUG
70 virtual void printInternalData() const override;
71#endif
72
73private:
74 NodeArray<int>* m_nodeNums; //stores internal number of each vertex
75 Array2D<double>* m_pairEnergy; //stores for each pair of vertices its energy
76 NodeArray<double> m_candPairEnergy; //stores for each vertex its pair energy with
77 //respect to the vertex to be moved if its new position is chosen
78 NodeArray<DIntersectableRect> m_shape; //stores the shape of each vertex as
79 //a DIntersectableRect
80 List<node> m_nonIsolated; //list of vertices with degree greater zero
81 const AdjacencyOracle m_adjacentOracle; //structure for constant time adjacency queries
82
83 //function computes energy stored in a certain pair of vertices
84 double computePairEnergy(const node v, const node w) const;
85
86 //computes energy of whole layout if new position of the candidate vertex is chosen
87 void compCandEnergy() override;
88
89 //If a candidate change is chosen as the new position, this function sets the
90 //internal data accordingly
91 void internalCandidateTaken() override;
92};
93
94}
95}
Declaration of ogdf::AdjacencyOracle class.
Declaration and implementation of class Array2D which implements dynamic two dimensional arrays.
Declares class EnergyFunction...
Tells you in constant time if two nodes are adjacent.
bool adjacent(node v, node w) const
Returns true iff vertices v and w are adjacent.
The parameterized class Array2D implements dynamic two-dimensional arrays.
Definition Array2D.h:47
Rectangles with real coordinates.
Definition geometry.h:914
Stores additional attributes of a graph (like layout information).
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
The interface for energy functions for the Davidson Harel graph drawing method.
int nodeNum(node v) const
Returns the internal number given to each vertex.
virtual double computeCoordEnergy(node, node, const DPoint &, const DPoint &) const =0
Computes the energy stored by a pair of vertices at the given positions.
void compCandEnergy() override
computes the energy if m_testNode changes position to m_testX and m_testY, sets the value of m_candid...
NodePairEnergy(const string energyname, GraphAttributes &AG)
const DIntersectableRect & shape(const node v) const
Returns the shape of a vertex v as a DIntersectableRect.
void internalCandidateTaken() override
changes the data of a specific energy function if the candidate was taken
const AdjacencyOracle m_adjacentOracle
bool adjacent(const node v, const node w) const
returns true in constant time if two vertices are adjacent.
double computePairEnergy(const node v, const node w) const
NodeArray< DIntersectableRect > m_shape
void computeEnergy() override
computes energy for the layout at the beginning of the optimization process
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.