Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
46 namespace ogdf {
47 class GraphAttributes;
48 
49 namespace davidson_harel {
50 
52 public:
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 
64 protected:
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 
81 private:
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 }
ogdf::davidson_harel::NodePairEnergy::computeCoordEnergy
virtual double computeCoordEnergy(node, node, const DPoint &, const DPoint &) const =0
Computes the energy stored by a pair of vertices at the given positions.
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
ogdf::davidson_harel::NodePairEnergy::NodePairEnergy
NodePairEnergy(const string energyname, GraphAttributes &AG)
Graph.h
Includes declaration of graph class.
ogdf::GenericPoint< double >
ogdf::davidson_harel::NodePairEnergy::nodeNum
int nodeNum(node v) const
Returns the internal number given to each vertex.
Definition: NodePairEnergy.h:69
AdjacencyOracle.h
Declaration of ogdf::AdjacencyOracle class.
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::davidson_harel::NodePairEnergy::~NodePairEnergy
virtual ~NodePairEnergy()
Definition: NodePairEnergy.h:56
ogdf::davidson_harel::NodePairEnergy::m_pairEnergy
Array2D< double > * m_pairEnergy
Definition: NodePairEnergy.h:83
ogdf::Array2D< double >
ogdf::davidson_harel::NodePairEnergy::internalCandidateTaken
void internalCandidateTaken() override
changes the data of a specific energy function if the candidate was taken
ogdf::DIntersectableRect
Rectangles with real coordinates.
Definition: geometry.h:922
ogdf::davidson_harel::NodePairEnergy::m_candPairEnergy
NodeArray< double > m_candPairEnergy
Definition: NodePairEnergy.h:84
ogdf::davidson_harel::NodePairEnergy::printInternalData
virtual void printInternalData() const override
ogdf::davidson_harel::NodePairEnergy::computeEnergy
void computeEnergy() override
computes energy for the layout at the beginning of the optimization process
ogdf::davidson_harel::NodePairEnergy::computePairEnergy
double computePairEnergy(const node v, const node w) const
ogdf::davidson_harel::NodePairEnergy
Definition: NodePairEnergy.h:51
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: DfsMakeBiconnected.h:40
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::davidson_harel::NodePairEnergy::m_shape
NodeArray< DIntersectableRect > m_shape
Definition: NodePairEnergy.h:86
EnergyFunction.h
Declares class EnergyFunction...
ogdf::davidson_harel::NodePairEnergy::compCandEnergy
void compCandEnergy() override
computes the energy if m_testNode changes position to m_testX and m_testY, sets the value of m_candid...
ogdf::davidson_harel::NodePairEnergy::shape
const DIntersectableRect & shape(const node v) const
Returns the shape of a vertex v as a DIntersectableRect.
Definition: NodePairEnergy.h:75
basic.h
Basic declarations, included by all source files.
ogdf::davidson_harel::NodePairEnergy::m_nodeNums
NodeArray< int > * m_nodeNums
Definition: NodePairEnergy.h:82
ogdf::davidson_harel::EnergyFunction
The interface for energy functions for the Davidson Harel graph drawing method.
Definition: EnergyFunction.h:52
ogdf::davidson_harel::NodePairEnergy::m_nonIsolated
List< node > m_nonIsolated
Definition: NodePairEnergy.h:88
List.h
Declaration of doubly linked lists and iterators.
ogdf::AdjacencyOracle::adjacent
bool adjacent(node v, node w) const
Returns true iff vertices v and w are adjacent.
ogdf::AdjacencyOracle
Tells you in constant time if two nodes are adjacent.
Definition: AdjacencyOracle.h:48
ogdf::davidson_harel::NodePairEnergy::adjacent
bool adjacent(const node v, const node w) const
returns true in constant time if two vertices are adjacent.
Definition: NodePairEnergy.h:72
Array2D.h
Declaration and implementation of class Array2D which implements dynamic two dimensional arrays.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::davidson_harel::NodePairEnergy::m_adjacentOracle
const AdjacencyOracle m_adjacentOracle
Definition: NodePairEnergy.h:89