Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / src / planarlayout / ShellingOrder.cpp
bloba813656a82102d8446168d4e6aa2d3bb1ec71fd0
1 /*
2 * $Revision: 2554 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-06 11:39:38 +0200 (Fr, 06. Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Implements class ShellingOrder.
12 * \author Carsten Gutwenger
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/planarlayout/ShellingOrder.h>
44 #include <ogdf/basic/BoundedStack.h>
45 #include <ogdf/basic/SList.h>
48 namespace ogdf {
51 void ShellingOrder::init(const Graph &G, const List<ShellingOrderSet> &partition)
53 m_pGraph = &G;
54 m_V.init(1,partition.size());
55 m_rank.init(G);
57 int i = 1;
58 ListConstIterator<ShellingOrderSet> it;
59 for(it = partition.begin(); it.valid(); ++it)
61 const ShellingOrderSet &S = *it;
62 for(int j = 1; j <= S.len(); ++j)
63 m_rank[S[j]] = i;
65 m_V[i++] = *it;
70 void ShellingOrder::initLeftmost(
71 const Graph &G,
72 const List<ShellingOrderSet> &partition)
74 m_pGraph = &G;
75 m_V.init(1,partition.size());
76 m_rank.init(G);
78 NodeArray<SListPure<const ShellingOrderSet *> > crSets(G);
79 BoundedStack<node> outerfaceStack(G.numberOfNodes());
81 int i, j;
83 ListConstIterator<ShellingOrderSet> it;
84 for(it = partition.begin(); it.valid(); ++it) {
85 node cr = (*it).right();
86 if (cr != 0)
87 crSets[cr].pushBack(&(*it));
90 const ShellingOrderSet &V1 = partition.front();
91 for (j = V1.len(); j >= 2; j--)
92 outerfaceStack.push(V1[j]);
94 m_V[1] = V1;
96 i = 2;
97 while (!outerfaceStack.empty()) {
98 node cr = outerfaceStack.top();
99 if (crSets[cr].empty())
100 outerfaceStack.pop();
101 else {
102 m_V[i] = *(crSets[cr].popFrontRet());
103 for (j = len(i); j >= 1; j--)
104 outerfaceStack.push ( (m_V[i])[j] );
105 i++;
110 for (i = 1; i <= length(); i++) {
111 for (j = 1; j <= m_V[i].len(); ++j) {
112 m_rank [(m_V[i])[j]] = i;
118 } // end namespace ogdf