6 * $Date: 2012-07-05 16:45:20 +0200 (Do, 05. Jul 2012) $
7 ***************************************************************/
10 * \brief Implements class EnergyFunction.
12 * \author Rene Weiskircher
15 * This file is part of the Open Graph Drawing Framework (OGDF).
19 * See README.txt in the root directory of the OGDF installation for details.
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
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.
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>
48 EnergyFunction::EnergyFunction(const String
&funcname
, GraphAttributes
&AG
) :
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();
70 double EnergyFunction::computeCandidateEnergy(const node v
, const DPoint
&testPos
)
75 OGDF_ASSERT(m_candidateEnergy
>= 0.0);
76 return m_candidateEnergy
;
81 void EnergyFunction::printStatus() const{
82 cout
<< "\nEnergy function name: " << m_name
;
83 cout
<< "\nCurrent energy: " << m_energy
;
85 cout
<< "\nPosition of nodes in current solution:";
86 NodeArray
<int> num(m_G
);
88 forall_nodes(v
,m_G
) num
[v
] = count
++;
90 cout
<< "\nNode: " << num
[v
] << " Position: " << currentPos(v
);
92 cout
<< "\nTest Node: " << m_testNode
<< " New coordinates: " << m_testPos
;
93 cout
<< "\nCandidate energy: " << m_candidateEnergy
;