Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

NodePairEnergy.h
Go to the documentation of this file.
1 
34 #pragma once
35 
36 #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 }}
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
virtual double computeCoordEnergy(node, node, const DPoint &, const DPoint &) const =0
Computes the energy stored by a pair of vertices at the given positions.
NodePairEnergy(const string energyname, GraphAttributes &AG)
Declares class EnergyFunction...
const DIntersectableRect & shape(const node v) const
Returns the shape of a vertex v as a DIntersectableRect.
Declaration of ogdf::AdjacencyOracle class.
Rectangles with real coordinates.
Definition: geometry.h:953
The interface for energy functions for the Davidson Harel graph drawing method.
Stores additional attributes of a graph (like layout information).
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
Class for the representation of nodes.
Definition: Graph_d.h:169
void internalCandidateTaken() override
changes the data of a specific energy function if the candidate was taken
int nodeNum(node v) const
Returns the internal number given to each vertex.
void computeEnergy() override
computes energy for the layout at the beginning of the optimization process
Tells you in constant time if two nodes are adjacent.
NodeArray< DIntersectableRect > m_shape
const AdjacencyOracle m_adjacentOracle
The namespace for all OGDF objects.
void compCandEnergy() override
computes the energy if m_testNode changes position to m_testX and m_testY, sets the value of m_candid...
bool adjacent(node v, node w) const
Returns true iff vertices v and w are adjacent.
Declaration and implementation of class Array2D which implements dynamic two dimensional arrays...