Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / ogdf / planarity / EmbedderMinDepthMaxFaceLayers.h
blob54da9277d004f0e51e47b61187297f7220bcedf2
1 /*
2 * $Revision: 2584 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-12 02:38:07 +0200 (Do, 12. Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Computes an embedding of a graph with minimum depth and
11 * maximum external face (plus layers approach).
13 * \author Thorsten Kerkhof
15 * \par License:
16 * This file is part of the Open Graph Drawing Framework (OGDF).
18 * \par
19 * Copyright (C)<br>
20 * See README.txt in the root directory of the OGDF installation for details.
22 * \par
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
27 * for details.
29 * \par
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.
35 * \par
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 ***************************************************************/
44 #ifdef _MSC_VER
45 #pragma once
46 #endif
48 #ifndef OGDF_EMBEDDER_MIN_DEPTH_MAX_FACE_Layers_H
49 #define OGDF_EMBEDDER_MIN_DEPTH_MAX_FACE_Layers_H
51 #include <ogdf/module/EmbedderModule.h>
52 #include <ogdf/decomposition/BCTree.h>
53 #include <ogdf/internal/planarity/MDMFLengthAttribute.h>
55 namespace ogdf {
57 //! Planar graph embedding with minimum block-nesting depth and maximum external face (plus layers approach).
58 /**
59 * See paper "Graph Embedding with Minimum Depth and Maximum External Face"
60 * by C. Gutwenger and P. Mutzel (2004) for details.
61 * The algorithm for minimum depth and maximum external face is combined with the
62 * algorithm for maximum external layers which defines how to embed
63 * blocks into inner faces. See diploma thesis "Algorithmen zur
64 * Bestimmung von guten Graph-Einbettungen f&uuml;r orthogonale
65 * Zeichnungen" (in german) by Thorsten Kerkhof (2007) for details.
67 class OGDF_EXPORT EmbedderMinDepthMaxFaceLayers : public EmbedderModule
69 public:
70 //constructor:
71 EmbedderMinDepthMaxFaceLayers() { }
73 /**
74 * \brief Call embedder algorithm.
75 * \param G is the original graph. Its adjacency list has to be changed by the embedder.
76 * \param adjExternal is an adjacency entry on the external face and has to be set by the embedder.
78 void call(Graph& G, adjEntry& adjExternal);
80 private:
81 /**
82 * \brief Bottom-up-traversal of bcTree computing the values \a m_{cT, bT}
83 * for all edges (\a cT, \a bT) in the BC-tree. The length of each vertex
84 * \f$ v \neq c \f$ in \a bT is set to 1 if \f$ v \in M_{bT}\f$ and to 0 otherwise.
86 * \param bT is a block vertex in the BC-tree.
87 * \param cH is a vertex in the original graph \a G.
88 * \return Minimum depth of an embedding of \a bT with \a cH on the external
89 * face.
91 int md_bottomUpTraversal(const node& bT, const node& cH);
93 /**
94 * \brief Top-down-traversal of BC-tree. The minimum depth of the BC-tree-node
95 * bT is calculated and before calling the function recursively for all
96 * children of bT in the BC-tree, the nodeLength of the cut-vertex which bT
97 * and the child have in common is computed. The length of each node is set to
98 * 1 if it is in M_B and 0 otherwise, except for |M_B| = 1, than it is set to
99 * 1 if it is in M2 with m2 = \f$\max_{v \in V_B, v != c} m_B(v)\f$ and
100 * M2 = \f${c \in V_B \ {v} | m_B(c) = m2}\f$.
102 * \param bT is a block vertex in the BC-tree.
104 void md_topDownTraversal(const node& bT);
107 * \brief Bottom up traversal of BC-tree.
109 * \param bT is the BC-tree node treated in this function call.
110 * \param cH is the block node which is related to the cut vertex which is
111 * parent of bT in BC-tree.
113 int mf_constraintMaxFace(const node& bT, const node& cH);
116 * \brief Top down traversal of BC-tree.
118 * \param bT is the tree node treated in this function call.
119 * \param bT_opt is assigned a block node in BC-tree which contains a face that
120 * can be expanded to a maximum face.
121 * \param ell_opt is the size of a maximum face.
123 void mf_maximumFaceRec(const node& bT, node& bT_opt, int& ell_opt);
126 * \brief Computes the adjacency list for all nodes in a block and calls
127 * recursively the function for all blocks incident to nodes in bT.
129 * \param bT is the tree node treated in this function call.
131 void embedBlock(const node& bT);
134 * \brief Computes the adjacency list for all nodes in a block and calls
135 * recursively the function for all blocks incident to nodes in bT.
137 * \param bT is the tree node treated in this function call.
138 * \param cT is the parent cut vertex node of bT in the BC-tree. cT is 0 if bT
139 * is the root block.
140 * \param after is the adjacency entry of the cut vertex, after which bT has to
141 * be inserted.
143 void embedBlock(const node& bT, const node& cT, ListIterator<adjEntry>& after);
145 private:
146 /** the BC-tree of G */
147 BCTree* pBCTree;
149 /** an adjacency entry on the external face */
150 adjEntry* pAdjExternal;
152 /** saving for each node in the block graph its length */
153 NodeArray<int> md_nodeLength;
155 /** an array containing the minimum depth of each block */
156 NodeArray<int> md_minDepth;
158 /** an array saving the length for each edge in the BC-tree */
159 EdgeArray<int> md_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$. */
163 NodeArray< List<node> > md_M_B;
165 /** M2 is empty, if |M_B| != 1, otherwise M_B = {cH}
166 * M2 = \f${cH' \in V_B \ {v} | m_B(cH') = m2}\f$ with
167 * m2 = \f$\max_{vH \in V_B, vH != cH} m_B(vH)\f$. */
168 NodeArray< List<node> > md_M2;
170 /** is saving for each node of the block graph its length */
171 NodeArray<int> mf_nodeLength;
173 /** is saving for each node of the block graph its cstrLength */
174 NodeArray<int> mf_cstrLength;
176 /** an array containing the maximum face size of each block */
177 NodeArray<int> mf_maxFaceSize;
179 /** is saving for each node of the block graph its length */
180 NodeArray<MDMFLengthAttribute> mdmf_nodeLength;
182 /** is saving for each edge of the block graph its length */
183 EdgeArray<MDMFLengthAttribute> mdmf_edgeLength;
185 /** saves for every node of G the new adjacency list */
186 NodeArray< List<adjEntry> > newOrder;
188 /** treeNodeTreated saves for all block nodes in the
189 * BC-tree if it has already been treated or not. */
190 NodeArray<bool> treeNodeTreated;
193 } // end namespace ogdf
195 #endif