# OpenGraph DrawingFramework

v.2012.07

NodePairEnergy.h
Go to the documentation of this file.
1 /*
2  * $Revision: 2523$
3  *
4  * last checkin:
5  * $Author: gutwenger$
6  * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012)$
7  ***************************************************************/
8
46 #ifdef _MSC_VER
47 #pragma once
48 #endif
49
50 #ifndef OGDF_NODE_PAIR_ENERGY_H
51 #define OGDF_NODE_PAIR_ENERGY_H
52
53
56
57
58
59 namespace ogdf {
60
62 public:
63  //Initializes data dtructures to speed up later computations
64  NodePairEnergy(const String energyname, GraphAttributes &AG);
65  virtual ~NodePairEnergy() {delete m_nodeNums; delete m_pairEnergy;}
66  //computes the energy of the initial layout
67  void computeEnergy();
68 protected:
69  //computes the energy stored by a pair of vertices at the given positions
70  virtual double computeCoordEnergy(node, node, const DPoint&, const DPoint&) const = 0;
71  //returns the internal number given to each vertex
72  int nodeNum(node v) const { return (*m_nodeNums)[v]; }
73  //returns true in constant time if two vertices are adjacent
75  //returns the shape of a vertex as an IntersectionRectangle
76  const IntersectionRectangle& shape(const node v) const {return m_shape[v];}
77
78 #ifdef OGDF_DEBUG
79  virtual void printInternalData() const;
80 #endif
81
82 private:
83  NodeArray<int> *m_nodeNums;//stores internal number of each vertex
84  Array2D<double> *m_pairEnergy;//stores for each pair of vertices its energy
85  NodeArray<double> m_candPairEnergy;//stores for each vertex its pair energy with
86  //respect to the vertex to be moved if its new position is chosen
87  NodeArray<IntersectionRectangle> m_shape;//stores the shape of each vertex as
88  //an IntersectionRectangle
89  List<node> m_nonIsolated;//list of vertices with degree greater zero