6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
10 * \brief Abstract MultilevelBuilder builds all Levels
12 * \author Gereon Bartel
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 ***************************************************************/
47 #ifndef OGDF_MULTILEVEL_BUILDER_H
48 #define OGDF_MULTILEVEL_BUILDER_H
50 #include <ogdf/basic/Graph.h>
51 #include <ogdf/internal/energybased/MultilevelGraph.h>
55 class OGDF_EXPORT MultilevelBuilder
59 * \brief This method constructs one more level on top of an existing MultilevelGraph.
60 * It must be implemented in any MultilevelBuilder. A level is built by
61 * adding node-merges to the MultilevelGraph and updating the graph accordingly.
62 * This is achieved by calling MLG.
64 * @param MLG is the MultilevelGraph for which a new gevel will be built.
66 * @return true if the Graph was changed or false if no Level can be built.
68 virtual bool buildOneLevel(MultilevelGraph
&MLG
) = 0;
71 // if set to true the length of the edge between two merged nodes will be added to
72 // all edges that are moved to the other node in this merge.
73 int m_adjustEdgeLengths
;
74 int m_numLevels
; //!< stores number of levels for statistics purposes
77 virtual ~MultilevelBuilder() { }
78 MultilevelBuilder():m_adjustEdgeLengths(0),m_numLevels(1) { }
80 virtual void buildAllLevels(MultilevelGraph
&MLG
)
83 MLG
.updateReverseIndizes();
84 MLG
.updateMergeWeights();
85 while (buildOneLevel(MLG
))
89 MLG
.updateReverseIndizes();
92 void setEdgeLengthAdjustment(int factor
) { m_adjustEdgeLengths
= factor
; }
93 int getNumLevels() {return m_numLevels
;}