6 * $Date: 2012-07-07 00:03:48 +0200 (Sa, 07. Jul 2012) $
7 ***************************************************************/
10 * \brief Declares class DavidsonHarelLayout, which is a front-end
11 * for the fDavidsonHarel class.
13 * \author Rene Weiskircher
16 * This file is part of the Open Graph Drawing Framework (OGDF).
20 * See README.txt in the root directory of the OGDF installation for details.
23 * This program is free software; you can redistribute it and/or
24 * modify it under the terms of the GNU General Public License
25 * Version 2 or 3 as published by the Free Software Foundation;
26 * see the file LICENSE.txt included in the packaging of this file
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public
37 * License along with this program; if not, write to the Free
38 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
39 * Boston, MA 02110-1301, USA.
41 * \see http://www.gnu.org/copyleft/gpl.html
42 ***************************************************************/
50 #ifndef OGDF_DAVIDSON_HAREL_LAYOUT_H
51 #define OGDF_DAVIDSON_HAREL_LAYOUT_H
54 #include <ogdf/module/LayoutModule.h>
55 #include <ogdf/energybased/DavidsonHarel.h>
61 //! The Davidson-Harel layout algorithm.
63 * The implementation used in DavidsonHarelLayout is based on
64 * the following publication:
66 * Ron Davidson, David Harel: <i>Drawing Graphs Nicely Using Simulated Annealing</i>.
67 * ACM Transactions on Graphics 15(4), pp. 301-331, 1996.
69 class OGDF_EXPORT DavidsonHarelLayout
: public LayoutModule
72 //! Easy way to set fixed costs
73 enum SettingsParameter
{spStandard
, spRepulse
, spPlanar
}; //tuning of costs
75 //! Easy way to set temperature and iterations
76 enum SpeedParameter
{sppFast
, sppMedium
, sppHQ
};
78 //! Creates an instance of Davidson-Harel layout.
79 DavidsonHarelLayout();
81 ~DavidsonHarelLayout(){}
83 //! Calls the layout algorithm for graph attributes \a GA.
84 void call(GraphAttributes
&GA
);
86 //! Fixes the cost values to special configurations.
87 void fixSettings(SettingsParameter sp
);
89 //! More convenient way of setting the speed of the algorithm.
91 * Influences number of iterations per temperature step, starting
92 * temperature, and cooling factor.
94 void setSpeed(SpeedParameter sp
);
96 //! Sets the preferred edge length multiplier for attraction.
98 * This is bad design, cause you dont need to have an attraction function,
99 * DH is purely modular and independent with its cost functions.
101 void setPreferredEdgeLengthMultiplier(double multi
) {m_multiplier
= multi
;}
103 //! Sets the preferred edge length to \a elen
104 void setPreferredEdgeLength(double elen
) {m_prefEdgeLength
= elen
;}
106 //! Sets the weight for the energy function \a Repulsion.
107 void setRepulsionWeight(double w
);
109 //! Returns the weight for the energy function \a Repulsion.
110 double getRepulsionWeight() const {return m_repulsionWeight
;}
112 //! Sets the weight for the energy function \a Attraction.
113 void setAttractionWeight(double);
115 //! Returns the weight for the energy function \a Attraction.
116 double getAttractionWeight() const {return m_attractionWeight
;}
118 //! Sets the weight for the energy function \a NodeOverlap.
119 void setNodeOverlapWeight(double);
121 //! Returns the weight for the energy function \a NodeOverlap.
122 double getNodeOverlapWeight() const {return m_nodeOverlapWeight
;}
124 //! Sets the weight for the energy function \a Planarity.
125 void setPlanarityWeight(double);
127 //! Returns the weight for the energy function \a Planarity.
128 double getPlanarityWeight() const {return m_planarityWeight
;}
130 //! Sets the starting temperature to \a t.
131 void setStartTemperature(int t
);
133 //! Returns the starting temperature.
134 int getStartTemperature() const {return m_startTemperature
;}
136 //! Sets the number of iterations per temperature step to \a steps.
137 void setNumberOfIterations(int steps
);
139 //! Returns the number of iterations per temperature step.
140 int getNumberOfIterations() const {return m_numberOfIterations
;}
142 //! Switch between using iteration number as fixed number or factor
143 //! (*number of nodes of graph)
144 void setIterationNumberAsFactor(bool b
) {m_itAsFactor
= b
;}
147 double m_repulsionWeight
; //!< The weight for repulsion energy.
148 double m_attractionWeight
; //!< The weight for attraction energy.
149 double m_nodeOverlapWeight
; //!< The weight for node overlap energy.
150 double m_planarityWeight
; //!< The weight for edge crossing energy.
151 int m_startTemperature
; //!< The temperature at the start of the optimization.
152 int m_numberOfIterations
; //!< The number of iterations per temperature step.
153 SpeedParameter m_speed
; //!< You can override this by manually setting iter=0.
154 double m_multiplier
; //!< By default, number of iterations per temperature step is number of vertices multiplied by multiplier.
155 double m_prefEdgeLength
; //!< Preferred edge length (abs value), only used if > 0
156 bool m_crossings
; //!< Should crossings be computed?
157 bool m_itAsFactor
; //!< Should m_numberOfIterations be factor (true) or fixed number