Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / src / energybased / EnergyFunction.cpp
blob604c5dcc1ede7b2b5b4f606e3c10cffc183f9c09
1 /*
2 * $Revision: 2552 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-05 16:45:20 +0200 (Do, 05. Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Implements class EnergyFunction.
12 * \author Rene Weiskircher
14 * \par License:
15 * This file is part of the Open Graph Drawing Framework (OGDF).
17 * \par
18 * Copyright (C)<br>
19 * See README.txt in the root directory of the OGDF installation for details.
21 * \par
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * Version 2 or 3 as published by the Free Software Foundation;
25 * see the file LICENSE.txt included in the packaging of this file
26 * for details.
28 * \par
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * \par
35 * You should have received a copy of the GNU General Public
36 * License along with this program; if not, write to the Free
37 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38 * Boston, MA 02110-1301, USA.
40 * \see http://www.gnu.org/copyleft/gpl.html
41 ***************************************************************/
44 #include <ogdf/internal/energybased/EnergyFunction.h>
46 namespace ogdf {
48 EnergyFunction::EnergyFunction(const String &funcname, GraphAttributes &AG) :
49 m_G(AG.constGraph()),
50 m_name(funcname),
51 m_candidateEnergy(0),
52 m_energy(0),
53 m_AG(AG),
54 m_testNode(NULL),
55 m_testPos(0.0,0.0) { }
58 void EnergyFunction::candidateTaken()
60 m_energy=m_candidateEnergy;
61 m_candidateEnergy = 0.0;
62 m_AG.x(m_testNode)=m_testPos.m_x;
63 m_AG.y(m_testNode)=m_testPos.m_y;
64 m_testPos = DPoint(0.0,0.0);
65 internalCandidateTaken();
66 m_testNode=NULL;
70 double EnergyFunction::computeCandidateEnergy(const node v, const DPoint &testPos)
72 m_testPos = testPos;
73 m_testNode = v;
74 compCandEnergy();
75 OGDF_ASSERT(m_candidateEnergy >= 0.0);
76 return m_candidateEnergy;
80 #ifdef OGDF_DEBUG
81 void EnergyFunction::printStatus() const{
82 cout << "\nEnergy function name: " << m_name;
83 cout << "\nCurrent energy: " << m_energy;
84 node v;
85 cout << "\nPosition of nodes in current solution:";
86 NodeArray<int> num(m_G);
87 int count = 1;
88 forall_nodes(v,m_G) num[v] = count ++;
89 forall_nodes(v,m_G) {
90 cout << "\nNode: " << num[v] << " Position: " << currentPos(v);
92 cout << "\nTest Node: " << m_testNode << " New coordinates: " << m_testPos;
93 cout << "\nCandidate energy: " << m_candidateEnergy;
94 printInternalData();
96 #endif
98 } //namespace