Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

NodePairEnergy.h
Go to the documentation of this file.
1 
34 #pragma once
35 
38 
39 namespace ogdf {
40 namespace davidson_harel {
41 
43 public:
44  //Initializes data dtructures to speed up later computations
45  NodePairEnergy(const string energyname, GraphAttributes &AG);
46 
47  virtual ~NodePairEnergy() {
48  delete m_nodeNums;
49  delete m_pairEnergy;
50  }
51 
52  //computes the energy of the initial layout
53  void computeEnergy() override;
54 
55 protected:
57  virtual double computeCoordEnergy(node, node, const DPoint&, const DPoint&) const = 0;
58 
60  int nodeNum(node v) const { return (*m_nodeNums)[v]; }
61 
63  bool adjacent(const node v, const node w) const { return m_adjacentOracle.adjacent(v,w); }
64 
66  const DIntersectableRect& shape(const node v) const { return m_shape[v]; }
67 
68 #ifdef OGDF_DEBUG
69  virtual void printInternalData() const override;
70 #endif
71 
72 private:
73  NodeArray<int> *m_nodeNums;//stores internal number of each vertex
74  Array2D<double> *m_pairEnergy;//stores for each pair of vertices its energy
75  NodeArray<double> m_candPairEnergy;//stores for each vertex its pair energy with
76  //respect to the vertex to be moved if its new position is chosen
77  NodeArray<DIntersectableRect> m_shape;//stores the shape of each vertex as
78  //a DIntersectableRect
79  List<node> m_nonIsolated;//list of vertices with degree greater zero
80  const AdjacencyOracle m_adjacentOracle;//structure for constant time adjacency queries
81 
82  //function computes energy stored in a certain pair of vertices
83  double computePairEnergy(const node v, const node w) const;
84 
85  //computes energy of whole layout if new position of the candidate vertex is chosen
86  void compCandEnergy() override;
87 
88  //If a candidate change is chosen as the new position, this function sets the
89  //internal data accordingly
90  void internalCandidateTaken() override;
91 };
92 
93 }}
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.
Declares class AdjacencyOracle.
Rectangles with real coordinates.
Definition: geometry.h:657
bool adjacent(const node, const node) const
Returns true iff two vertices are adjacent.
Real points.
Definition: geometry.h:219
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:39
Class for the representation of nodes.
Definition: Graph_d.h:167
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...