Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / src / energybased / multilevelmixer / MMMExampleNiceLayout.cpp
blob611462324000767a1e132c37329a083812b97f84
1 /*
2 * $Revision: 2523 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief useable example of the Modular Multilevel Mixer
12 * \author Gereon Bartel
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 ***************************************************************/
43 #include <ogdf/energybased/multilevelmixer/MMMExampleNiceLayout.h>
44 #include <ogdf/basic/PreprocessorLayout.h>
45 #include <ogdf/packing/ComponentSplitterLayout.h>
46 #include <ogdf/energybased/multilevelmixer/ModularMultilevelMixer.h>
47 #include <ogdf/energybased/multilevelmixer/ScalingLayout.h>
48 #include <ogdf/energybased/FastMultipoleEmbedder.h>
50 #include <ogdf/energybased/multilevelmixer/EdgeCoverMerger.h>
51 #include <ogdf/energybased/multilevelmixer/BarycenterPlacer.h>
53 namespace ogdf {
55 MMMExampleNiceLayout::MMMExampleNiceLayout()
60 void MMMExampleNiceLayout::call(GraphAttributes &GA)
62 MultilevelGraph MLG(GA);
63 call(MLG);
64 MLG.exportAttributes(GA);
68 void MMMExampleNiceLayout::call(MultilevelGraph &MLG)
70 // Fast Multipole Embedder
71 FastMultipoleEmbedder * FME = new FastMultipoleEmbedder();
72 FME->setNumIterations(1000);
73 FME->setRandomize(false);
75 // Fast Edges Only Embedder
76 FastMultipoleEmbedder * FEOE = new FastMultipoleEmbedder();
77 FEOE->setNumIterations(0);
78 FEOE->setRandomize(false);
80 // Edge Cover Merger
81 EdgeCoverMerger * ECM = new EdgeCoverMerger();
82 ECM->setFactor(2.0);
83 ECM->setEdgeLengthAdjustment(0); // BEFORE (but arg is int!): ECM->setEdgeLengthAdjustment(0.1);
85 // Barycenter Placer with weighted Positions
86 BarycenterPlacer * BP = new BarycenterPlacer();
87 BP->weightedPositionPriority(true);
89 // No Scaling
90 ScalingLayout * SL = new ScalingLayout();
91 SL->setExtraScalingSteps(0);
92 SL->setScaling(1.0, 1.0);
93 SL->setScalingType(ScalingLayout::st_relativeToDrawing);
94 SL->setSecondaryLayout(FME);
95 SL->setLayoutRepeats(1);
97 ModularMultilevelMixer *MMM = new ModularMultilevelMixer;
98 MMM->setLayoutRepeats(1);
99 // MMM->setAllEdgeLenghts(5.0);
100 // MMM->setAllNodeSizes(1.0);
101 MMM->setLevelLayoutModule(SL);
102 MMM->setInitialPlacer(BP);
103 MMM->setMultilevelBuilder(ECM);
105 ComponentSplitterLayout *CS = new ComponentSplitterLayout;
106 CS->setLayoutModule(MMM);
107 PreprocessorLayout PPL;
108 PPL.setLayoutModule(CS);
109 PPL.setRandomizePositions(true);
111 PPL.call(MLG);
114 } // namespace ogdf