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>
39 
40 namespace ogdf {
41 namespace davidson_harel {
42 
44 public:
45  //Initializes data dtructures to speed up later computations
46  NodePairEnergy(const string energyname, GraphAttributes& AG);
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 
56 protected:
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 
73 private:
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 }
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: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
ogdf::davidson_harel::NodePairEnergy::NodePairEnergy
NodePairEnergy(const string energyname, GraphAttributes &AG)
ogdf::GenericPoint< double >
ogdf::davidson_harel::NodePairEnergy::nodeNum
int nodeNum(node v) const
Returns the internal number given to each vertex.
Definition: NodePairEnergy.h:61
AdjacencyOracle.h
Declaration of ogdf::AdjacencyOracle class.
ogdf::davidson_harel::NodePairEnergy::~NodePairEnergy
virtual ~NodePairEnergy()
Definition: NodePairEnergy.h:48
ogdf::davidson_harel::NodePairEnergy::m_pairEnergy
Array2D< double > * m_pairEnergy
Definition: NodePairEnergy.h:75
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:915
ogdf::davidson_harel::NodePairEnergy::m_candPairEnergy
NodeArray< double > m_candPairEnergy
Definition: NodePairEnergy.h:76
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:43
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::davidson_harel::NodePairEnergy::m_shape
NodeArray< DIntersectableRect > m_shape
Definition: NodePairEnergy.h:78
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:67
ogdf::davidson_harel::NodePairEnergy::m_nodeNums
NodeArray< int > * m_nodeNums
Definition: NodePairEnergy.h:74
ogdf::davidson_harel::EnergyFunction
The interface for energy functions for the Davidson Harel graph drawing method.
Definition: EnergyFunction.h:47
ogdf::davidson_harel::NodePairEnergy::m_nonIsolated
List< node > m_nonIsolated
Definition: NodePairEnergy.h:80
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:45
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:64
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:233
ogdf::davidson_harel::NodePairEnergy::m_adjacentOracle
const AdjacencyOracle m_adjacentOracle
Definition: NodePairEnergy.h:81