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>
38#include <ogdf/basic/Graph.h>
39#include <ogdf/basic/List.h>
40#include <ogdf/basic/basic.h>
41#include <ogdf/basic/geometry.h>
43
44#include <string>
45
46namespace ogdf {
47class GraphAttributes;
48
49namespace davidson_harel {
50
52public:
53 //Initializes data dtructures to speed up later computations
54 NodePairEnergy(const string energyname, GraphAttributes& AG);
55
56 virtual ~NodePairEnergy() {
57 delete m_nodeNums;
58 delete m_pairEnergy;
59 }
60
61 //computes the energy of the initial layout
62 void computeEnergy() override;
63
64protected:
66 virtual double computeCoordEnergy(node, node, const DPoint&, const DPoint&) const = 0;
67
69 int nodeNum(node v) const { return (*m_nodeNums)[v]; }
70
72 bool adjacent(const node v, const node w) const { return m_adjacentOracle.adjacent(v, w); }
73
75 const DIntersectableRect& shape(const node v) const { return m_shape[v]; }
76
77#ifdef OGDF_DEBUG
78 virtual void printInternalData() const override;
79#endif
80
81private:
82 NodeArray<int>* m_nodeNums; //stores internal number of each vertex
83 Array2D<double>* m_pairEnergy; //stores for each pair of vertices its energy
84 NodeArray<double> m_candPairEnergy; //stores for each vertex its pair energy with
85 //respect to the vertex to be moved if its new position is chosen
86 NodeArray<DIntersectableRect> m_shape; //stores the shape of each vertex as
87 //a DIntersectableRect
88 List<node> m_nonIsolated; //list of vertices with degree greater zero
89 const AdjacencyOracle m_adjacentOracle; //structure for constant time adjacency queries
90
91 //function computes energy stored in a certain pair of vertices
92 double computePairEnergy(const node v, const node w) const;
93
94 //computes energy of whole layout if new position of the candidate vertex is chosen
95 void compCandEnergy() override;
96
97 //If a candidate change is chosen as the new position, this function sets the
98 //internal data accordingly
99 void internalCandidateTaken() override;
100};
101
102}
103}
Declaration of ogdf::AdjacencyOracle class.
Declaration and implementation of class Array2D which implements dynamic two dimensional arrays.
Declares class EnergyFunction...
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
Basic declarations, included by all source files.
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:53
Rectangles with real coordinates.
Definition geometry.h:922
Stores additional attributes of a graph (like layout information).
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Class for the representation of nodes.
Definition Graph_d.h:241
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
virtual void printInternalData() const override
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
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
The namespace for all OGDF objects.