Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / ogdf / internal / energybased / NodePairEnergy.h
blob0f9dce3c92fbe634d8aba301547c391491058e12
1 /*
2 * $Revision: 2523 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Declares class NodePairEnergy which implements an energy
11 * function where the energy of a layout depends on the
12 * each pair of nodes.
14 * \author Rene Weiskircher
16 * \par License:
17 * This file is part of the Open Graph Drawing Framework (OGDF).
19 * \par
20 * Copyright (C)<br>
21 * See README.txt in the root directory of the OGDF installation for details.
23 * \par
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * Version 2 or 3 as published by the Free Software Foundation;
27 * see the file LICENSE.txt included in the packaging of this file
28 * for details.
30 * \par
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
36 * \par
37 * You should have received a copy of the GNU General Public
38 * License along with this program; if not, write to the Free
39 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
40 * Boston, MA 02110-1301, USA.
42 * \see http://www.gnu.org/copyleft/gpl.html
43 ***************************************************************/
46 #ifdef _MSC_VER
47 #pragma once
48 #endif
50 #ifndef OGDF_NODE_PAIR_ENERGY_H
51 #define OGDF_NODE_PAIR_ENERGY_H
54 #include <ogdf/internal/energybased/AdjacencyOracle.h>
55 #include <ogdf/internal/energybased/EnergyFunction.h>
56 #include <ogdf/internal/energybased/IntersectionRectangle.h>
59 namespace ogdf {
61 class NodePairEnergy: public EnergyFunction {
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
74 bool adjacent(const node v, const node w) const {return m_adjacentOracle.adjacent(v,w);}
75 //returns the shape of a vertex as an IntersectionRectangle
76 const IntersectionRectangle& shape(const node v) const {return m_shape[v];}
78 #ifdef OGDF_DEBUG
79 virtual void printInternalData() const;
80 #endif
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
90 const AdjacencyOracle m_adjacentOracle;//structure for constant time adjacency queries
91 //function computes energy stored in a certain pair of vertices
92 double computePairEnergy(const node v, const node w) const;
93 //computes energy of whole layout if new position of the candidate vertex is chosen
94 void compCandEnergy();
95 //If a candidate change is chosen as the new position, this function sets the
96 //internal data accordingly
97 void internalCandidateTaken();
101 }// namespace ogdf
103 #endif