6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
10 * \brief Declares class Attraction.
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 ***************************************************************/
48 #ifndef OGDF_ATTRACTION_H
49 #define OGDF_ATTRACTION_H
52 #include <ogdf/internal/energybased/NodePairEnergy.h>
57 //! Energy function for attraction between two adjacent vertices.
59 * Implements an energy function that simulates
60 * attraction between two adjacent vertices. There is an optimum
61 * distance where the energy is zero. The energy grows quadratic
62 * with the difference to the optimum distance. The optimum
63 * distance between two adjacent vertices depends on the size of
66 class Attraction
: public NodePairEnergy
{
68 //Initializes data structures to speed up later computations
69 Attraction(GraphAttributes
&AG
);
71 //! set the preferred edge length to the absolute value l
72 void setPreferredEdgelength(double l
) {m_preferredEdgeLength
= l
;}
73 //! set multiplier for the edge length with repspect to node size to multi
74 void reinitializeEdgeLength(double multi
);
76 void printInternalData() const;
79 //! Average length and height of nodes is multiplied by this factor to get preferred edge length
80 static const double MULTIPLIER
;
81 //! the length that that all edges should ideally have
82 double m_preferredEdgeLength
;
83 //! computes the energy contributed by the two nodes if they are placed at the two given positions
84 double computeCoordEnergy(node
,node
, const DPoint
&, const DPoint
&) const;