Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / ogdf / planarity / EmbedderMinDepth.h
blob56494ebb60e9e987424bcd400c3028230058202c
1 /*
2 * $Revision: 2589 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-12 23:31:45 +0200 (Do, 12. Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Computes an embedding of a graph with minimum depth.
12 * \author Thorsten Kerkhof
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 #ifdef _MSC_VER
44 #pragma once
45 #endif
47 #ifndef OGDF_EMBEDDER_MIN_DEPTH_H
48 #define OGDF_EMBEDDER_MIN_DEPTH_H
50 #include <ogdf/module/EmbedderModule.h>
51 #include <ogdf/decomposition/BCTree.h>
52 #include <ogdf/decomposition/StaticSPQRTree.h>
54 namespace ogdf {
56 //! Planar graph embedding with minimum block-nesting depth.
57 /**
58 * See paper "Graph Embedding with Minimum Depth and Maximum External
59 * Face" by C. Gutwenger and P. Mutzel (2004) for details.
61 class OGDF_EXPORT EmbedderMinDepth : public EmbedderModule
63 public:
64 //constructor
65 EmbedderMinDepth() { }
67 /**
68 * \brief Computes an embedding of \a G with minimum depth.
70 * \param G is the original graph.
71 * \param adjExternal is assigned an adjacency entry in the external face.
73 void call(Graph& G, adjEntry& adjExternal);
75 private:
76 /**
77 * \brief Computes recursively the block graph for every block.
79 * \param bT is a block node in the BC-tree.
80 * \param cH is a node of bT in the block graph.
82 void computeBlockGraphs(const node& bT, const node& cH);
84 /**
85 * \brief Bottom-up-traversal of bcTree computing the values \a m_{cT, bT}
86 * for all edges \a (cT, bT) in the BC-tree. The length of each vertex
87 * \f$v \neq c in \a bT\f$ is set to 1 if \f$v \in M_{bT}\f$ and to 0 otherwise.
89 * \param bT is a block vertex in the BC-tree.
90 * \param cH is a vertex in the original graph \a G.
91 * \return Minimum depth of an embedding of \a bT with \a cH on the external
92 * face.
94 int bottomUpTraversal(const node& bT, const node& cH);
96 /**
97 * \brief Top-down-traversal of BC-tree. The minimum depth of the BC-tree-node
98 * bT is calculated and before calling the function recursively for all
99 * children of bT in the BC-tree, the nodeLength of the cut-vertex which bT
100 * and the child have in common is computed. The length of each node is set to
101 * 1 if it is in M_B and 0 otherwise, except for |M_B| = 1, than it is set to
102 * 1 if it is in M2 with m2 = \f$\max_{v \in V_B, v != c} m_B(v)\f$ and
103 * M2 = \f${c \in V_B \ {v} | m_B(c) = m2}\f$.
105 * \param bT is a block vertex in the BC-tree.
107 void topDownTraversal(const node& bT);
110 * \brief Computes the adjacency list for all nodes in a block and calls
111 * recursively the function for all blocks incident to nodes in bT.
113 * \param bT is the tree node treated in this function call.
115 void embedBlock(const node& bT);
118 * \brief Computes the adjacency list for all nodes in a block and calls
119 * recursively the function for all blocks incident to nodes in bT.
121 * \param bT is the tree node treated in this function call.
122 * \param cT is the parent cut vertex node of bT in the BC-tree. cT is 0 if bT
123 * is the root block.
124 * \param after is the adjacency entry of the cut vertex, after which bT has to
125 * be inserted.
127 void embedBlock(const node& bT, const node& cT, ListIterator<adjEntry>& after);
129 private:
130 /** BC-tree of the original graph */
131 BCTree* pBCTree;
133 /** an adjacency entry on the external face */
134 adjEntry* pAdjExternal;
136 /** all blocks */
137 NodeArray<Graph> blockG;
139 /** a mapping of nodes in the auxiliaryGraph of the BC-tree to blockG */
140 NodeArray< NodeArray<node> > nH_to_nBlockEmbedding;
142 /** a mapping of edges in the auxiliaryGraph of the BC-tree to blockG */
143 NodeArray< EdgeArray<edge> > eH_to_eBlockEmbedding;
145 /** a mapping of nodes in blockG to the auxiliaryGraph of the BC-tree */
146 NodeArray< NodeArray<node> > nBlockEmbedding_to_nH;
148 /** a mapping of edges in blockG to the auxiliaryGraph of the BC-tree */
149 NodeArray< EdgeArray<edge> > eBlockEmbedding_to_eH;
151 /** saving for each node in the block graphs its length */
152 NodeArray< NodeArray<int> > nodeLength;
154 /** an array containing the minimum depth of each block */
155 NodeArray<int> minDepth;
157 /** an array saving the length for each edge in the BC-tree */
158 EdgeArray<int> m_cB;
161 * M_B = \f${cH \in B | m_B(cH) = m_B}\f$ with m_B = \f$\max_{c \in B} m_B(c)\f$
162 * and m_B(c) = \f$\max {0} \cup {m_{c, B'} | c \in B', B' \neq B}\f$.
164 NodeArray< List<node> > M_B;
167 * M2 is empty, if |M_B| != 1, otherwise M_B = {cH}
168 * M2 = \f${cH' \in V_B \ {v} | m_B(cH') = m2}\f$ with
169 * m2 = \f$\max_{vH \in V_B, vH != cH} m_B(vH)\f$.
171 NodeArray< List<node> > M2;
173 /** saves for every node of G the new adjacency list */
174 NodeArray< List<adjEntry> > newOrder;
176 /** treeNodeTreated saves for all block nodes in the
177 * BC-tree if it has already been treated or not. */
178 NodeArray<bool> treeNodeTreated;
180 /** The SPQR-trees of the blocks */
181 NodeArray<StaticSPQRTree*> spqrTrees;
184 } // end namespace ogdf
186 #endif