A Simple Algorithm for the Graph Minor Decomposition – Logic meets Structural

Martin Grohe∗ Ken-ichi Kawarabayashi†‡ Bruce Reed§

Abstract which says that in any infinite collection of finite graphs A key result of Robertson and Seymour’s graph minor there is one that is a minor of another. As with other theory is a structure theorem stating that all graphs deep results in mathematics, the body of theory devel- excluding some fixed graph as a minor have a oped for the proof of the graph minor theorem has also decomposition into pieces that are almost embeddable found applications elsewhere, both within graph theory in a fixed surface. Most algorithmic applications of and computer science. Most of these applications rely graph minor theory rely on an algorithmic version of this not only on the general techniques developed by Robert- result. However, the known algorithms for computing son and Seymour to handle graph minors, but also on such graph minor decompositions heavily rely on the one particular structural result (proved in [29]), which is very long and complicated proofs of the existence of such central to the whole theory. It describes the structure of decompositions, essentially they retrace these proofs all graphs G which do not contain some fixed graph H and show that all steps are algorithmic. as a minor. At a high level, the theorem says that ev- In this paper, we give a simple quadratic time algo- ery such a graph can be decomposed into a collection rithm for computing graph minor decompositions. The of graphs each of which can be “nearly” embedded into best previously known algorithm due to Kawarabayashi a bounded- surface; the pieces can be assembled and Wollan runs in cubic time and is far more compli- in a tree structure to obtain the original graph. In the cated. following, we refer to such a decomposition as a graph Our algorithm combines techniques from logic and minor decomposition. structural graph theory, or more precisely, a variant of Starting with Robertson and Seymour’s cubic time Courcelle’s Theorem stating that monadic second-order algorithm for the disjoint path problem [28], a substan- logic formulas can be evaluated in linear time on graphs tial body of work on “algorithmic graph minor theory” of bounded tree width and Robertson and Seymour’s so emerged (e.g. [7, 8, 9, 14, 15, 17]). Most of the re- called Weak Structure Theorem. sults give efficient (exact or approximation) algorithms for various hard problems on classes of graphs with ex- 1 Introduction cluded minors, but some go beyond such classes [28, 15]. Almost all of these results rely, either directly or indi- A graph H is a minor of a graph G if H can be obtained rectly through other results, on the existence of graph from a subgraph of G by contracting edges. The theory minor decompositions (i.e., Robertson and Seymour’s of graph minors was developed by Robertson and Sey- structure theorem) and on efficient algorithms for com- mour in a series of 23 papers published over more than puting these decompositions. twenty-five years. The aim of that series of papers was Several such algorithms are known. The third au- the proof of a single result: the graph minor theorem, thor of this paper was maybe the first to point out that Robertson-Seymour’s original proof of the structure the- ∗RWTH Aachen University, Germany. Email address: [email protected] orem (which requires almost 400 pages) gives rise to a †National Institute of Informatics and JST ERATO polynomial time algorithm to construct the decompo- Kawarabayashi Project, Tokyo, Japan. sitions. Demaine, Hajiaghayi, and Kawarabayashi [9] Email address: k [email protected] give a lengthy proof for constructing it, which builds ‡Research partly supported by Japan Society for the Promo- tion of Science, Grant-in-Aid for Scientific Research, , by C & on many structural graph minor results. The run- k C Foundation, by Kayamori Foundation and by Inoue Research ning time of this algorithm is O(n ) for a k that de- Award for Young Scientists. pends on the size of the excluded minor. Dawar, §Canada Research Chair in Graph Theory, McGill University, Grohe, and Kreutzer [6] give an fixed-parameter algo- Montreal Canada and Project Mascotte, INRIA, Laboratoire I3S, rithm that, however, computes a “weaker” decompo- CNRS, Sophia-Antipolis, France. sition into pieces that have bounded local tree width Email address: [email protected] after removing a bounded number of vertices. Recently, graph minor decomposition of the bounded-tree-width Kawarabayashi and Wollan [18] found a dramatically graph G0 in quadratic time. Then, in the third step, our shorter proof for the graph minor decomposition theo- algorithm re-inserts the vertices deleted in the first step rem (cutting off around 300 pages of the original graph and extends the decomposition from G0 to G. minor papers), which yields a cubic time algorithm for The paper is organised as follows: After general pre- computing graph minor decompositions. However, all liminaries in Section 2, we formally define graph minor these algorithms are deeply entrenched in rather heavy decompositions in Section 3 and state the structure the- structural graph theory. Essentially, they are algorith- orem. We prove claim (A) from above in Section 4 and mic proofs of the structure theorem. claim (B) in Section 5. We put everything together in In this paper, we give a simple quadratic time al- Section 6. gorithm to construct a graph minor decomposition. We take a completely different approach than the previous 2 Preliminaries algorithms. We take the existence of a decomposition For all integers m, n, we denote the set m, m + for granted and just try to find one. We reduce struc- 1, . . . , n , which is empty if m > n, by [m, n],{ and we tural graph theory to a minimum, but combine it with let [n] :=} [1, n]. We use a standard graph theoretic ter- tools from logic. The correctness proof of our algorithm minology and notation. The set of all neighbours of a 1 essentially fits within this conference paper, which is vertex w or a set W of vertices in a graph G is denoted quite remarkable when compared with previous algo- by N G(w) and N G(W ), respectively, and for a subgraph rithms. H of G we let N G(H) = N G(V (H)). Our main technical contributions are the following. A tree decomposition of a graph G is a pair (T,Y ), (A) We prove one graph theoretic result, which roughly where T is a tree and Y is a family Yt t V (T ) of vertex sets Y V (G), such that the{ following| ∈ two} says that if there is a vertex v deep inside a grid t ⊆ in a graph G, then no matter how we obtain a properties hold: graph minor decomposition of G v, we can put − (1) t V (T ) Yt = V (G), and every edge of G has both v back into this decomposition and thus obtain a ∈ ends in some Yt. decomposition of G. S (2) If t, t0, t00 V (T ) and t0 lies on the path in T from (B) We prove that “near embeddings” (in the sense ∈ t to t00, then Y Y 00 Y 0 . required for graph minor decompositions) of graphs t ∩ t ⊆ t in a bounded genus surface are definable in monadic For every node t V (T ), we call Y the bag at t. The ∈ t second logic. torso at t is the graph Ht obtained from the induced Using these two results, our algorithm proceeds as subgraph G[Yt] by adding edges between all vertices v, w such that v, w Y Y for some neighbour u N T (t). follows. Repeatedly applying (A), it deletes vertices ∈ t ∩ u ∈ from the input graph G until it arrives at a graph G0 It is sometimes convenient to view the tree in a tree that no longer has a large grid. By the Excluded Grid decomposition as rooted, and will freely do so. Theorem [25], G0 has bounded tree width. Applying The adhesion of a tree decomposition (T,Y ) is max Y Y tu E(T ) if E(T ) = , and 0 if an extension of Courcelle’s well known theorem [2, 4], {| t ∩ u| | ∈ } 6 ∅ stating that monadic second-order formulas can be E(T ) = . The width of (T,Y ) is max Yt t V (T ) 1,∅ and the tree width tw(G) of G is{| defined| | as∈ evaluated in linear time, to the formulas obtained in } − (B), we obtain a linear time algorithm for constructing the minimum width taken over all tree decompositions near embeddings of bounded tree width graphs. We of G. By a well-known result due to Bodlaender [3], can even construct such near embeddings “locally” there is an algorithm that, given a graph G and an with respect to a tangle. (A tangle [27] may be integer w, decides if the tree width of G is at most w and viewed as a structure describing a highly connected computes a tree decomposition of G of width at most w O(w3) region in a graph, and a near embedding is local if it is. The running time of the algorithm is 2 n, where n = G . with respect to the tangle if the part of the graph | | properly embedded falls within this region.) Now we can use a (fairly simple and by now standard) generic 3 Structure Theorems construction going back to [27] for computing a “global” 3.1 Tangles Let G be a graph. A separation of G is tree decomposition respecting the local structure, in our a pair (A, B) of subgraphs such that G = A B (hence case near embeddability. This enables us to compute a there are no edges between A B and B ∪ A). The order of the separation (A, B)− is A B .A− tangle of | ∩ | 1Some proofs in this conference paper are only sketched. order k of G is a set T of separations of G of order < k satisfying the following there conditions. Lemma 3.2. For all nonnegative integers α, k there is (1) For all separations (A, B) of G of order < k, either a linear time algorithm that, given a an α-vortex (G, Ω) (A, B) T or (B,A) T. such that tw(G) k, computes a linear decomposition ∈ ∈ of (G, Ω) of depth≤ at most 2α + 2. (2) If (A1,B1), (A2,B2), (A3,B3) T then A1 A2 ∈ ∪ ∪ Proof. Let (G, Ω) be an α-vortex such that tw(G) k. A3 = G. ≤ 6 We choose an arbitrary w0 V (Ω) and let wi = (3) If (A, B) T then V (A) = V (G). Ωi(w ) for all i 1. Observe∈ that (G, Ω) has a linear ∈ 6 0 ≥ Note that if (A, B) T then (B,A) / T; we think of decomposition (Xi)0 i<` of depth at most 2α such that ∈ ∈ ≤ B as the ‘big side’ of the separation (A, B), with respect wi Xi for all i [0, ` 1]. To see this, take a linear ∈ ∈ − to this tangle. decomposition (Xi0)i [0,` 1] of (G, Ω) of depth at most ∈ − A separation (A, B) of G breaks a set U V (G) α. Such a decomposition exists by the result of [26]. ⊆ if (V (A) U) V (A B) < U and (V (B) U) Then for some j [0, ` 1] we have wi+j Xi0 for all | ∩ ∪ ∩ | | | | ∩ ∪ ∈ − ∈ V (A B) < U . The set U is k-unbreakable if there is i [0, ` 1]. If j = 0, we simply let Xi = Xi0 for all i. If ∩ | | | ∈ − no separation (A, B) of G of order < k that breaks U. j > 0 we let Z = X` j 1 X` j and Xi = Xi0+` j Z − − ∩ − − ∪ For a k-unbreakable set U of size U 3k 2 we for all i, where the indices are taken modulo `. It is | | ≥ − define T to be the set of all separations of (A, B) of G of easy to verify that (Xi)0 i<` is a linear decomposition U ≤ order at most k such that (V (B) U) V (A B) U . of (G, Ω) with the desired properties. | ∩ ∪ ∩ | ≥ | | Then TU is a tangle of order k of G [12, 15, 27]. Now we let q = k + 2α + 1. We let H be the graph We close this short introduction to tangles with a obtained from G by adding characterisation of tangles in terms of separators and fresh vertices w for i [0, ` 1], j [q 1], components rather than separations. • ij ∈ − ∈ − edges w w for i [0, ` 1], j [q 1], Lemma 3.1. ([24]) Let T be a tangle of order k in a • i ij ∈ − ∈ − graph G. Then for every S V (G) with S < k there ⊆ | | edges wijwij0 for i [0, ` 1], j = j0 [q 1], is a unique connected component CT of G S such that • ∈ − 6 ∈ − ,S \ for all separations (A, B) of G with V (A B) = S we edges wiwi+1 for i [0, ` 1] if they are not present ∩ • ∈ − have (A, B) T CT B. in G, ∈ ⇐⇒ ,S ⊆ edges w w 0 for i [0, ` 1], j, j0 [q 1]. 3.2 Societies and Vortices A society is a pair • ij (i+1)j ∈ − ∈ − (G, Ω), where G is a graph and Ω a cyclic permutation Then for all i, the set W = w w 1 j q 1 i { i} ∪ { ij | ≤ ≤ − } of a subset V (Ω) of V (G). The vertices in V (Ω) are is a q- in G, and for i [0, ` 2] the set Wi Wi+1 sometimes called society vertices. Note that for every is a 2q-clique. ∈ − ∪ w V (Ω) we have V (Ω) = Ωj(w) j [0, V (Ω) 1] . We claim that the tree width of H is at most ∈ { | ∈ | |− } The length of a society (G, Ω) is V (Ω) . 2q + 2α 1. To prove this claim, we construct a tree | | A society (G, Ω) of length ` is a α-vortex if for all decomposition− (T,Y ) of H of that width. We start w V (Ω) and k [`] there do not exist (α+1) mutually with the linear decomposition (Xi)i [0,` 1]. To simplify ∈ ∈ j ∈ − disjoint paths of G between Ω (w) j [0, k 1] and the notation, let X 1 = . For i [0, ` 1], we let j { | ∈ − } − ∅ ∈ − Ω (w) j [k, ` 1] . Y2i = (Xi 1 Xi) (Xi Xi+1) Wi, and if i < ` 1 { | ∈ − } − A linear decomposition of a society (G, Ω) of length we let Y ∩= (X∪ X∩ ) W∪ W . Note that− 2i+1 i ∩ i+1 ∪ i ∪ i+1 ` is a sequence (Xi)i [0,` 1] of subsets of V (G) such that for all i [0, 2` 2] we have Yi 2q + 2α, because ∈ − ∈ − | | ≤ ` 1 Xi 1 Xi 2α and q 2α. Let P be the path with (1) − X = V (G) − i=0 i |vertices∩ 0,...,| ≤ 2` 2 and≥ edges i(i+1) for i [0, 2` 3]. − i i ∈ − (2) SXi Xk Xj for all i, j, k [0, ` 1] with i j k. For i [0, ` 1], let (T ,Y ) be a tree decomposition of ∩ ⊆ ∈ − ≤ ≤ ∈ − i the graph G[Xi] of width 2q + 2α 1 such that the set (3) There is a x0 V (Ω) such that Ω (x0) Xi for all − ∈ ∈ (Xi 1 Xi) (Xi Xi+1) wi is contained in the bag i [0, ` 1]. i − ∩ ∪ i ∩ i ∪ { } ∈ − Yri of the root r of T . Such a tree decomposition exists The width of the linear decomposition (Xi)i [0,` 1] is because we can take a tree decomposition of G[Xi] of ∈ − max Xi i [0, ` 1] , and the depth of (Xi)i [0,` 1] width k and add the set (Xi 1 Xi) (Xi Xi+1) wi {| | | ∈ − } ∈ − − ∩ ∪ ∩ ∪{ } is max Xi Xi+1 i [0, ` 1] . Sometimes Xi is to every bag. As k + 1 + 4α + 1 2q + 2α, we have {| ∩ | | ∈ − } i i ≤ called a bag of the linear decomposition. Yt 2q+2α for all bags Yt of this tree decomposition. It is proved in [26] that if a society (G, Ω) is a α- Without| | ≤ loss of generality we may assume that the trees vortex then it has a linear decomposition of depth at T i are mutually disjoint and disjoint from the path P . most α. We form a tree T by taking the union of the P and the trees T i and for i [0, ` 1] adding an edge from node this tree decomposition it computes the desired linear ∈ i − i 2i of P to the root r of T . For i V (P ), we define decomposition (Xi)i [` 1] of (G, Ω) following the con- i ∈ i ∈ − Yi as above, and for t V (T ), we let Yt = Yt . Then struction described above.  (T,Y ) is a tree decomposition∈ of H of width at most 2q + 2α 1. 3.3 Near Embeddings For nonnegative integers The− crucial point is that we can revert the construc- α , α , α , a graph G is (α , α , α )-nearly embeddable tion: from every tree decomposition of H of width at 1 2 3 1 2 3 in a surface Σ if there is a subset Z V (G) with most 2q + 2α 1 we can construct a linear decomposi- ⊆ − Z α , two sets = (G , Ω ),..., (G , Ω ) and tion of (G, Ω) of depth at most 2α + 1. Let (T,Y ) be a 1 1 1 α2 α2 | |= ≤ (G , Ω V),...,{ (G , Ω ) of societies,} and a tree decomposition of H of width at most 2q + 2α 1. α2+1 α2+1 n n graphW {G such that the following conditions} are satis- For i [0, ` 2], let U be the set of all nodes− 0 i fied. u V (T )∈ such that− W W Y . Then U = , ∈ i ∪ i+1 ⊆ u i 6 ∅ because Wi Wi+1 is a clique in H, and Ui is connected (1) G Z = G0 G1 ... Gn. in T . For ∪i = j we have U U = , because if \ ∪ ∪ ∪ 6 i ∩ j ∅ u U U then Y contains at least three of the sets (2) For all i [n] we have E(G0) E(Gi) = and ∈ i ∩ j u ∈ ∩ ∅ W , which means Y 3q > 2q + 2α. This contradicts V (G0) V (Gi) V (Ωi). k | u| ≥ ∩ ⊆ the width of (T,Y ) being at most 2q + 2α 1. We For all distinct i, j [n] we have E(G ) E(G ) = − i j construct a path P T and nodes t(0), t(1), . . . , t(` 2) and V (G ) V (G )∈ V (Ω ) V (Ω ). Furthermore,∩ ∅ ⊆ − i ∩ j ⊆ i ∩ j appearing on P in the right order such that t(i) Ui if i, j α then V (G ) V (G ) = . ∈ ≤ 2 i ∩ j ∅ for all i. We let t(0) U0 be arbitrary. Suppose that ∈ (3) Each (G , Ω) is an α -vortex. (By a result of for some i < ` 2 we have defined t(0), . . . , t(i) and i ∈ V 3 − [26], (Gi, Ωi) has a linear decomposition of depth the segment Pi of P from t(0) to t(i). Let t(i + 1) at most α3.) be the vertex in Ui+1 closest to t(i), and let Q be the path from t(i) to t(i + 1) in T . We claim that Q and (4) Each (Gi, Ωi) has length at most 3. Pi are internally disjoint. If not, t(i) has the same ∈ W neighbour, say t, on P and Q. We have W Y , (5) There are closed disks ∆1,..., ∆n Σ with dis- i i ⊆ t ⊆ because Wi Yt(i 1) Yt(i) and Wi+1 Yt, because joint interiors and an embedding σ : G0 , Σ such ⊆ − ∩ ⊆ → W Y Y . Thus t U , and t is closer to that for all i [n] we have σ(G0) int(∆i) = and i+1 ⊆ t(i) ∩ t(i+1) ∈ i ∈ ∩ ∅ t(i 1) than t(i). This contradicts our construction. σ(V (G0)) bd(∆i) = σ(V (Ωi)), and the cyclic or- − ∩ Hence Pi and Q must be internally disjoint, and we let dering of the vertices in σ(V (Ωi)) induced by Ωi is P = P Q. compatible with the natural cyclic ordering of the i+1 i ∪ Now we are ready to construct the desired linear vertices on the simple closed curve bd(∆i). We say decomposition of G. For i [` 2], we let that the disk ∆i is accommodating (Gi, Ωi). ∈ − We call (σ, G ,Z, , ) an (α , α , α )-near embedding Zi = (Yt(i) (Wi Wi+1)) wi, wi+1 . 0 1 2 3 \ ∪ ∪ { } of G in Σ or just near-embeddingV W if the parameters are Note that Z Y 2q + 2 2α + 2. We let X be clear from the context. For a nonnegative integer α, | i| ≤ | t(i)| − ≤ 0 the union of Z0 with all sets Yt V (G) such that t is in an α-near embedding is an (α1, α2, α3)-near embedding a connected component of T t∩(1) that has an empty where α , α , α α. \{ } 1 2 3 ≤ intersection with P . For 2 i ` 2, we let X be the Let G0 be the graph resulting from G by joining ≤ ≤ − i 0 0 union of Zi 1 Zi with all sets Yt V (G) such that t is any two nonadjacent vertices u, v G0 such that u, v in the connected− ∪ component of T ∩ t(i 1), t(i) that Ω for some society (J, Ω) ;∈ the new edge uv of∈ \{ − } ∈ W contains the segment of P from t(i 1) to t(i). We let G0 will be called a virtual edge. By embedding these − 0 X` 1 be the union of Z` 2 with all sets Yt V (G) such virtual edges disjointly in the disks ∆ accommodating that− t is in a connected component− of T t∩(` 2) that their societies, we extend our embedding σ : G , Σ \{ − } 0 → has an empty intersection with P . It is easy to see that to an embedding σ0 : G0 , Σ. We shall not normally 0 → (Xi)0 i<` is a linear decomposition of (G, Ω), and as distinguish G0 from its image in Σ under σ0. Observe X X≤ = Z for all i, the depth of this decomposition that if C G is a cycle with C G = for all i [α ] i ∩ i+1 i ⊆ ∩ i ∅ ∈ 2 is at most 2α + 2. there is a unique cycle C0 G0 obtained from C by ⊆ 0 Our algorithm for computing such a linear decom- replacing segments in graph Gi for i > α2 by virtual position proceeds as follows: On input (G, Ω), it first edges. We call C0 the shortcut for C in G0. constructs the graph H. Then it uses Bodlaender’s lin- A near-embedding (σ, G ,Z, , ) is nice if for all 0 V W ear time algorithm to compute a tree decomposition (J, Ω) there is a cycle C G0 such that C is the (T,Y ) of H of width at most 2q + 2α 1, and from boundary∈ V of the disk ∆ accommodating⊆ (J, Ω). − A near-embedding (σ, G0,Z, , ) is T-central, for D(J, Ω). a tangle T of G, if for all (J, Ω)V W there is no (A, B) T with Z V (A B) and∈B V ∪Z W J. Furthermore, if t is not the root of T , then for the parent ∈ ⊆ ∩ \ ⊆ s of t we have Y Y Z . The following theorem may be viewed as the main s ∩ t ⊆ t structural result of graph minor theory. We state mild Note that if α1 4β 3, we need no small nodes, because for a graph ≥H of− order H 4β 3 we have a a strengthening of Robertson and Seymour’s original | | ≤ − theorem ([29], Theorem (3.1)) due to [12] in that we trivial near embedding where all vertices are in the set require the near embedding to be nice. (Note that Z. working with this strengthening makes our algorithmic Theorem 3.2. (Global Structure Theorem) results stronger as well, because we will obtain nice near For every graph R there are nonnegative α , α , α , β, γ embeddings for the pieces of the decomposition we shall 1 2 3 such that every graph G that excludes R as a minor has compute.) an (α1, α2, α3, β, γ)-decomposition. Theorem 3.1. (Local Structure Theorem) For every graph R there are nonnegative α, β, γ such that Our main algorithm for constructing a global de- the following holds. Let G be a graph that excludes R composition of a locally decomposable graph can ac- as a minor and T a tangle of G of order at least β. tually be used to prove the Global Structure Theorem Then G has a T-central nice α-near embedding in a from the local one (see Remark 6.1). surface of Euler genus at most γ. Proviso 3.1. To simplify the presentation, let us This theorem follows easily from Theorem 2 of [12], agree that whenever we are given an (α1, α2, α3, β, γ)- noting that (3, 3)-rich near embeddings are nice and that decomposition of a graph in an algorithmic context, we if we choose β sufficiently large, every graph of small tree are also given near embeddings of all nearly embeddable width does not have a tangle of order at least β. nodes of the decomposition, and whenever we have an al- Let us call a graph G locally (α1, α2, α3, β, γ)- gorithm computing an (α1, α2, α3, β, γ)-decomposition, decomposable if for every β-unbreakable set U V (G) the algorithm will also compute appropriate near em- of size U = 3β 2 the graph has a T -central⊆ nice beddings. | | − U (α1, α20 , α3)-near embedding in a surface of Euler genus at most γ, for some α0 α . It follows from the Local 4 Location of a wall of large height 2 ≤ 2 Structure Theorem that for every graph H there are An elementary wall of height h 1 is a graph defined as ≥ parameters α1, α2, α3, β, γ such that for all β0 β, in Figure 1. A wall of height h (or an h-wall) is obtained ≥ all H-minor-free graphs are locally (α1, α2, α3, β0, γ)- from an elementary wall of height h by subdividing some decomposable. of the edges, i.e., replacing the edges with internally The following theorem, which is a strengthening of vertex disjoint paths with the same endpoints. Robertson and Seymour’s structure theorem from [29], The nails of a wall are the vertices of degree three follows from Theorem 3.1 by standard techniques; see within it. Any wall of height h 3 has a unique ≥ [12] for a proof. An (α1, α2, α3, β, γ)-decomposition of planar embedding where the external face is not a G is a tree decomposition (T,Y ) of G, where we view “brick”. The boundary cycle of this external face is T as a rooted tree, such that for all nodes t, either the perimeter of the wall. (The perimeter the unique Yt 4β 3 or for some α20 α2 the torso Ht has facial cycle that contains more than 6 nails.) For | | ≤ − ≤ a nice (α1, α20 , α3)-near embedding (σt,Ht0,Zt, t, ) in any wall W in a given graph H, there is a unique V ∅ a surface Σt of Euler genus at most γ where all vortices component U of H per(W ) containing W per(W ). (J, Ω) have a linear decomposition D(J, Ω) of depth The compass of W ,− denoted comp (W ), consists− of the ∈ V G at most α3 and width at most 2α3 + 1. If Yt 4β 3, graph with vertex set V (U) V (per(W )) and edge set | | ≤ − we call t small; otherwise, we call t a nearly embeddable. E(U) E(per(W )) xy x∪ V (U), y V (per(W )) . All nearly embeddable nodes t satisfy the following A subwall∪ of a wall ∪W { is a| wall∈ which is∈ a subgraph of} additional conditions. For all children u of t in T , W . A subwall of W of height h is proper if it consists of h consecutive bricks from each of h consecutive rows either Yu Yt V (Ht0) Zt and (Yu Yt) Zt 3 • ∩ ⊆ ∪ | ∩ − | ≤ of W . and there is a closed disk ∆ Σt such that ⊆ A flat wall decomposition in a graph G is a tu- σt(Ht0) int(∆) = and σt(Ht0) bd(∆) = ∩ ∅ ∩ ple (ρ, W, K0,...,Kn), where W G is a wall and σt((Yu Yt) Zt), ⊆ ∩ − K0,K1,...,Kn G are pairwise edge-disjoint sub- or there is a vortex (J, Ω) such that (Y Y ) graphs, and ρ is⊆ an embedding of K in the plane such • ∈ Vt u ∩ t − 0 Zt is contained in a bag of the linear decomposition that the following conditions are satisfied. study ways to compute the excluded minors for derived wall W in G) is a family (C,D1,...,Dm) of connected classes of graphs given the excluded minors for the base subgraphs of K such that: classes. 1. K = C D . . . D ; ∪ 1 ∪ ∪ m 5.1 Apices For any given class of graphs we can construct the class of graphs G suchC that there is a 2. W C, and there is no separation (X, Y ) of C of ⊆ vertex v V (G) for which G v . We call this order 3 with V (W ) X and Y X = ∅; ≤ ⊆ \ 6 vertex an∈apex of G with respect\ to∈. C We denote the C G class of graphs having an apex with respect to by 3. ∂ Di V (C) for all i 1,...,m ; apex. The aim of this section is to show the followingC ⊆ ∈{ } C theorem. 4. ∂GD 3 for all i 1,...,m ; | i|≤ ∈{ } Theorem 5.1. If is a minor ideal whose set of G G C 5. ∂ Di = ∂ Dj for all i = j 1,...,m . excluded minors is given, then we can compute the 6 6 ∈{ } excluded minors of apex. C We let C be the graph obtained from C by adding new By iterating this construction, we can compute for vertices d1,...,dm and, for 1 i m, edges between di G ≤ ≤ any k the set of excluded minors for the class of graphs to the vertices in ∂ Di and edges between all vertices G G for which there are k vertices v ,...,v such that in ∂ Di. Hence, for each i 1,...,m the vertex di 1 k ∈ { } G together with the (at most 3) vertices in ∂ Di form a G v1,...,vk . \{We now prove}∈C Theorem 5.1. Let be a minor clique. We call C the core of the layout and D1,...,Dm ideal. As before, we aim at applying LemmaC 3.1. Using its extensions. The layout (C,D1,...,Dm) is flat if its core C is planar. Note that this implies that the core has Example 2.2, it is easily seen that for each k N, apex ∈ an embedding in the plane that extends the “standard k is MSO-definable over TreeExp( k). Hence, itC remains∩ T to show that apex has effectivelyT bounded planar embedding” of the wall W (as shown in Figure 1), width. We first need someC preparations. because the wall W has a unique embedding into the sphere. We call the wall W flat (in G) if the compass 5.1.1 Walls, Layouts, and Linkages An elemen- of W has a flat layout. tary wall of height h 1 is a graph defined as in Fig- The following lemma is (essentially) Lemma (9.8) ure 1(a). A wall of height≥ h is a subdivision of an el- of [21]. Concerning the uniformity, see the remarks at ementary wall of height h. The perimeter of a wall is the end of [21] (on page 109). the boundary cycle. A wall in a graph G is a wall W Trinity Lemma (Robertson and Seymour [21]). that is a subgraph of G. Note that, up to homeomor- There are computable functions f,g : N2 N and phisms, walls have unique embeddings in the sphere. an algorithm A that, given a graph G and nonnegative→ For walls of height 1, this is obvious, and for walls of integers k,h, computes either height h 2 this follows from a well known theorem due ≥ to Tutte stating that 3-connected graphs have unique 1. a tree decomposition of G of width f(k,h), or embeddings, because walls of height 2 are subdivi- sons of 3-connected graphs. ≥ 2. a Kk-minor of G, or

b b b b b b b bb

b b b b b b b b b b b b b b b b b 3. a subset X V (G) with X < k , a wall W of b b b b b b b b b b b b b b b b b b b b b b b ⊆ | | 2 b b b b b b b b b b b b b b b b b b b b b b b b height h in G X, and a flat layout (C,D ,...,D )  1 m b b b b b b b b b b b b b b b b b b b b b of the compass\ of W in G X such that the tree \ width of each of the extensions D1,...,Dm is at Figure 1: Elementary walls of heights 2–4 Figure 1: Elementary walls of height 2–4 most f(k,h).

(1) compG(W ) = K0 ..., Kn. to (ρ, W, K0,...,Kn)) isG a family C1,...,C` W of For∪ a∪ subgraph D of a graphdisjointG flat, cycles we let such∂ thatD be the ⊆ (2) For all distinct i, j [n] we have V (K ) V (K ) Furthermore, the running time of the algorithm is set of∈ all vertices ofi ∩D thatj ⊆ are incident with an edge in 2 V (K0), and for all i [n] we have V (Ki) Γ(C ) Γ(C ) ... Γ(C ). bounded by g(k,h) V (G) . ∈ | ∩ 1 ⊆ 2 ⊆ ⊆ ` V (K0) E3. (G) E(D). · | | | ≤ \ A generic way of constructing an `-nest for ` h/2 is (3) All nails of W are in V (K ).2 ≤ d e In the0 following, let W beto let aC wall` be the of perimeter height of W at, C least` 1 the perimeterA oflinkage L in a graph G is a subgraph whose − (4) There is a2 closed in a disk graph Γ in theG, plane and such let thatP bethe the subwall perimeter that remains after of W deleting. LetC`, et cetera.components We are paths. For a set Z V (G), the effect call the `-nest constructed this way the generic `-nest ρ(K0) Γ and ρ maps the perimeter cycle of W ⊆ onto the⊆ boundaryK′ be ofthe Γ. unique Furthermore, connected there are in componentW . of G P that of L on Z is defined as the partition of Z V (L) where Robertson and Seymour’s\ Excluded Grid Theorem ∩ closed diskscontains Γ1,..., Γn WΓ withP mutually. The disjoint graph K = K′ P is called the two vertices belong to the same class if they belong to ⊆ [25] states that every graph of sufficiently large tree interiors such that for 1 i\ n we have ρ(K0) ∪ compass of≤ W≤ in G. A layout∩ width of (dependingK (with on respecth) contains to a the wall ofthe height sameh component of L. int(Γi) = and ρ(K0) bd(Γi) = V (K0) V (Ki). ∅ ∩ ∩ as a subgraph. The following theorem, also due to Let K0 be the graph obtained from K0 by joining any Robertson and Seymour [28], is a strengthening of the two nonadjacent vertices u, v V (K ) V (K ), for ∈ 0 ∩ i Excluded Grid Theorem. The linear time algorithm is 1 i n. We refer to the edges in E(K0 ) E(K ) ≤ ≤ 0 \ 0 from [17], which combines Robertson and Seymour’s as virtual edges. We extend the embedding ρ to an original quadratic time algorithm with Perkovic and embedding ρ0 of K0 in Γ by embedding the new edges Reed’s [22] linear time algorithm for computing grids in in the disks Γi. We usually do not distinguish K0 from graphs of large tree width, and an algorithm to compute its image ρ0(K0 ) in Γ. a flat embedding in linear time. The height of a flat wall decomposition is the height of its wall. A wall W is flat in a graph G if there is a Theorem 4.1. (Weak Structure Theorem) For flat wall decomposition (ρ, W, K0,...,Kn) in G. Note all positive integers m, h there is a positive integers k that every subwall of a flat wall is flat as well. such that for every graph G of tree width at least k that Let (ρ, W, K0,...,Kn) be a flat wall decomposition excludes Km as a minor, there is a subset X V (G) m ⊆ in a graph G and K := comp (W ) = n K .A of size X and a flat wall of height h in G X. G i=0 i | | ≤ 2 \ cycle C K is flat if C Ki for any i 1. In Furthermore, there is a linear time algorithm that, ⊆ 6⊆ S ≥  particular, every cycle C W except possibly a brick given a graph of tree width at least k that excludes Km as in the corner is flat, because⊆ it contains at least four a minor, computes a subset X V (G) of size X m ⊆ | | ≤ 2 nails of W and every K for i 1 contains at most 3 and a flat wall decomposition of height h in G X. i \  nails. Observe that for every flat≥ cycle C K there is ⊆ Let W be a wall in graph a G. We view W as a unique cycle C0 K0 obtained from C by replacing ⊆ embedded in the plane in the natural way. A curve segments in Ki for i 1 by virtual edges. We call ≥ γ in the plane is W -normal if it only meets W in C0 the shortcut for C in K0 . There is a unique disk 0 vertices. The face distance (with respect to W ) between Γ(C) Γ such that ρ0(C0) = bd(Γ(C)); we call Γ(C) the ⊆ two vertices v1, v2 V (W ) is defined to be the minimal disk bounded by C (or by C0). An `-nest (with respect value V (W ) γ ∈ 1 taken over all curves γ in the | ∩ | − 2In the literature, this condition is usually replaced by the plane that link v1 and v2. The face distance (with respect to W in G) between two vertices v , v V (G) following weaker condition. 1 2 ∈ is 0 if v1, v2 belong to the same connected component (3’) For all i ∈ [n] there is at most one nail of W in V (Ki)\V (K). of G V (W ), and the minimum of the face distances However, it is easy to construct a decomposition satisfying (1)– \ between all v0 , v0 V (W ) such that there is a path (4) from one that only satisfies (1), (2), (3’) and (4): we locally 1 2 ∈ redefine W by moving the nails from the K to K ∩ K and from Pi G from vi to v0 with all vertices except v0 in i 0 i ⊆ i i possibly splitting Ki into several components. V (G) V (W ). \ A set X V (G) is (c, d)-wide over a wall W Lemma 4.2. Let W be a wall of height h in a graph G X if every⊆ x X has neighbours v , . . . , v ⊆ G. Then for every separator S V (G) of order − ∈ 1 c ∈ ⊆ compG X (W ) of mutual face distance at least d with q := S < h there is exactly one connected component respect− to W in G X. We need the following corollary H such| | that V (H) S contains more than q2 nails of of the Weak Structure− Theorem. W . ∪

Corollary 4.1. For all positive integers c, d, m, h We use this to prove the following lemma, which will there is a positive integers k such that for every graph allow us to focus on a single node of a decomposition. G of tree width at least k that excludes Km as a minor, there is a subset X V (G) of size X m and a flat Lemma 4.3. Let G be a graph and (T,Y ) an ⊆ | | ≤ 2 wall of height h in G X over which X is (c, d)-wide (α1, α2, α3, β, γ)-decomposition of G. Furthermore, let  Furthermore, there\ is a linear time algorithm that, W be a wall of height h > 4α in G. Then there is a unique node t V (T ) with the following two properties. given a graph of tree width at least k that excludes Km ∈ as a minor, computes a subset X V (G) of size X (1) For each connected component T of T t the set m ⊆ | | ≤ 0 and a flat wall decomposition (ρ, W, K0,...,Kn) of 2 − 2 t0 V (T 0) Yt0 contains at most 16α nails of W . height h in G X such that X is (c, d)-wide over W . ∈  \ (2) tSis a nearly embeddable node. Let W be a wall in a graph G. A vertex v ∈ compG(W ) is `-central in W it its face distance from Proof. It follows easily from the definition of the perimeter of W is at least `. Observe that if (α1, α2, α3, β, γ)-decompositions that the adhesion of (ρ, W, K0,...,Kn) is a flat wall decomposition in G and (T,Y ) is at most q := max α +2α +1, 3, 4β 3 4α. { 1 3 − } ≤ v is `-central in W then there is an `-nest C1,...,C` For every edge tu of T , let Ttu be the component of 3 such that ρ(v) int(Γ(C )). Indeed, we can take 0 0 1 T tu containing u, and let Vtu = t V (Ttu) Yt . Note ∈ − ∈ C1,...,C` to be the generic `-nest in W . that Vtu Vut = V (G) and Vtu Vut q. Then by ∪ | ∩S | ≤ 2 The following lemma is the main result of this Lemma 4.2, either Vtu or Vut contains at most q nails section (and the main graph theoretic result of the of W . Note that it cannot happen that both Vtu and 2 paper). Vut contain most q nails, because a wall of height h > q has 2(h 1)(h + 1) > 2q2 nails. Lemma 4.1. (Extension Lemma) For all nonnega- Let− us fix an arbitrary root r for T and then choose tive integers α , α , α , β, γ, ξ there are nonnegative in- 1 2 3 a node t such that tegers c, d, h, ` such that for every graph G the fol- lowing holds. Suppose that there is a subset X for all directed edges s0t0 on the path from r to t ⊆ • 2 V (G) of size X ξ and a flat wall decomposition the set V 0 0 contains more than q nails of W ; | | ≤ s t (ρ, W, K0,K1,...,Kn) in G X of height at least h such \ for all children u of t the set Vtu contains at most that X is (c, d)-wide over W . Let w V (K0) be `- • 2 central in W . Then if G w has an (α∈, α , α , β, γ)- q nails of W . − 1 2 3 decomposition, so does G. Note that if t is not the root and s is its parent, then 2 Furthermore, there is a linear time algorithm that, Vts contains at most q nails of W , because Vst contains given G and X and (ρ, W, K0,K1,...,Kn) and w and more than q2 nails. As each connected component of an (α1, α2, α3, β, γ)-decomposition of G w, computes T t is of the form T for some neighbour u of t, this − − tu an (α1, α2, α3, β, γ)-decomposition of G. proves (1). Furthermore, t is unique, because there is no edge tu such that both V and V contain at most The proof of the extension lemma requires some tu ut q2 nails of W . preparation. Let α , α , α , β, γ, ξ be nonnegative in- 1 2 3 It remains to prove that t is a nearly embeddable tegers and node. Suppose for contradiction that it is a small node,

α = max 1, α1, α2, α3, β . that is, Yt 4β 3 q < h. By Lemma 4.2 { } and because| |W ≤ has− more≤ than q2 + q nails, there is a We start with a simple and well-known lemma, connected component of G Yt that contains more than 2 \ whose straightforward proof we omit (cf. [16]). q nails. This contradicts (1). 

3 The converse of this claim is “almost” true; the only thing In the following, we let c, d, h, ` be a sufficiently that may happen is that v belongs to a connected component A large integers (to be determined later). of G−V (W ) such that ρ(A) ⊆ int(Γ(C1)), but N(A) ⊆ C1, which means that the face distance of v to the perimeter of W may only Let G be a graph and X V (G) with X ξ ⊆ | | ≤ be ` − 1. and (ρ, W, K0,K1,...,Kn) a flat wall decomposition in G X of height h 2` such that X is (c, d)- disk under σ. To prove this, it will be convenient to \ ≥ wide over W and K = compG(W ). Let w V (K0) extend the near embedding (σ, H0,Z, , ) from H to be `-central in W , and let C ,...,C W∈ be the G. For each vortex (J, Ω) , we defineV ∅ a new vortex 1 ` ⊆ ∈ V generic`-nest in W . Then ρ(w) int(Γ(C )). We (J 0, Ω) by letting J 0 be the union of J with the induced ∈ 1 let W 0 be a subwall of W of height h 1 such that subgraph G[ Y ] Z, where the union ranges over all − u u − w V (W 0). (To obtain W 0, we delete the row and nodes u of T that are contained in a component of T t 6∈ S − column of W that contains W ; if there is no such row attached to the vortex J. We let 0 be the resulting set V and/or column, we just take the row and column closest of vortices. For each child u of t attached to G0 we define to w.) Then (ρ, W 0,K w, K ,...,K ) is a flat (h 1)- a society (J, Ω) with J = G[ 0 Y 0 ] Z, where the 0 − 1 n − u u − wall decomposition in G (X w ). union ranges over all u0 in the subtree rooted at u, and \ ∪ { } S Let (T,Y ) an (α1, α2, α3, β, γ)-decomposition of G with V (Ω) = (Yt Yu) Z. Then V (Ω) 3. We let 0 w. We choose the node t V (T ) according to− be the set of all∩ societies\ defined| this way.| ≤ This yieldsW ∈ Lemma 4.3 (applied to W 0, so as a first condition on an (α1, α2, α3)-near embedding of G in Σ. Observe that ` we need to make sure that h 1 > 4α). We let the wall W has the following two properties with respect − H = Ht be the torso of (T,Y ) at t and (σ, H0,Z, , ) a to this near embedding: nice (α , α , α )-near embedding of H in a surfaceV Σ∅ of 1 20 3 (1) For every (J, Ω) there is a linear decompo- Euler genus γ γ satisfying all the conditions stated 0 0 sition (X ) ∈of V depth α such that for every in the definition≤ of (α , α , α , β, γ)-decompositions in i i [m 1] 3 1 2 3 i [m] at most∈ − 16α2 nails of W are contained in Section 3.3. X∈. Now the idea of the proof of the Extension Lemma i is to prove that one of the cycles C = Ci of the `-nest not (2) For every (J, Ω) , at most 16α2 nails of W are only bounds the disk Γ(C) Γ under the embedding contained in J. ∈ W ρ of K, but also a disk ∆ ⊆ Σ under the embedding σ of H. This will be the content⊆ of Lemma 4.4 below. Condition (2) follows immediately from our choice of t Once we have proved this, we can identify the disk Γ(C) according to Lemma 4.3. To see (1), let (J 0, Ω0) 0, and let (J, Ω) be the corresponding vortex in .∈ Then V with the disk ∆ and modify the embedding σ so that it V (J, Ω) has a linear decomposition (Xi)i [m 1] of depth coincides with ρ on ∆ = Γ(C) and remains unchanged ∈ − on Σ ∆. We can easily extend this new embedding to at most α3 and width at most 2α3 + 1. We obtain a \ linear decomposition (Xi0)i [m 1] of depth α3 of J 0 by H + w, because ρ is defined on K and not just K w. ∈ − − attaching to each Xi the bags of the subtrees attached Thus we can insert w in the bag Yt and this way extend the decomposition from G w to G. Moreover, we can to Xi. Then the set Xi separates Xi0 from the rest of G. − do this extension algorithmically in linear time if we are Thus by Lemma 4.2, either Xi0 or G (Xi0 Xi) contains 2 \ \ given the flat wall decomposition and the embedding σ at most (2α3 + 1) nails of W . By the choice of t, it must be X0. of H0 in Σ. i A technical difficulty with this approach is that so If W is a wall that satisfies conditions (1) and (2) for a near embedding (σ, G ,Z, 0, ), we say that the far we ignored the set X. If vertices of X are mapped 0 V W into the disk ∆ by σ, then we cannot modify σ in the near embedding is W -central. way described, because ρ is not defined on X. This is Thus the Extension Lemma 4.1 follows from the where we use the wideness condition on X. Suppose for following lemma. Recall the definition of the graph G0 contradiction that σ(x) ∆ for some x X. Then if (for a near embedding (σ, G0,Z, , )) and the shortcut ∈ ∈ V W c α + 2, there is a set of at least α + 2 neighbours of C0 for a cycle C G0 (J,Ω) J in G0. We say that 1 1 ⊆ ∪ ∈W ≥ C bounds a disk ∆ Σ if bd(∆) = σ0(C0). x in compG X (W ) that are mutually far apart, and at ⊆ S least two of− these neighbours, say, y , y , are not in Z, 1 2 Lemma 4.4. For all nonnegative integers because Z α . Now both y and y must be mapped 1 1 2 α , α , α , γ, ξ there are nonnegative integers c, d, `, h into ∆ as| well,| ≤ because σ(x) ∆ σ(C) = int(∆). But 1 2 3 such that the following holds. Let X V (G) of size y and y are far apart with∈ respect\ to W . Hence the 1 2 X ξ, and let (ρ, W, K ,...,K )⊆be a flat wall subgraph of K in the interior of the disk Γ(C) together 0 n 0 |decomposition| ≤ of height h in G X such that X with x is not planar, because it contains a relatively is (c, d)-wide over W . Let C ,...,C− W be the large subwall and edges spanning several bricks of this 1 ` generic `-nest in W . Let (σ, G ,Z, , ⊆) be a nice subwall. However, σ embeds the subwall in the disk ∆. 0 (α , α , α )-near embedding of a graphV GWin a surface This is a contradiction. 1 2 3 Σ of Euler genus at most γ that is W -central. Then Thus what remains to prove is that indeed there there is some i [`] such that Ci G0 (J,Ω) J is such a cycle C = Ci of the `-nest that bounds a ∈ ⊆ ∪ ∈W and Ci bounds a disk in Σ. S The rest of this section is devoted to a proof Now we are ready to prove the key claim of this of Lemma 4.4. The proof is by induction on the section, and in a sense of the whole proof of the lexicographical order of pairs (γ, α2) (that is, the genus Extension Lemma. Recall that K = compG X (W ). of the surface and the number of vortices). − We let α1, α2, α3, γ, ξ be nonnegative integers and Claim 4.2. Suppose that the height h of W and ` are α = max α1, α2, α2 . We let c, d, `, h be suffi- sufficiently large (in terms of α and ξ). Then every ciently large{ (to be determined} later). We choose vertex of K that is `-central in W is contained in the graph G, the set X, the flat wall decomposition V (G0) (J,Ω) V (J). ∪ ∈W (ρ, W, K0,...,Kn), the `-nest C1,...,C`, and the near For theS ease of presentation in this conference embedding (σ, G0,Z, , ) in Σ as in the statement of V W version, we make the simplifying assumption that Z = the lemma. We let K = compG X (W ). − . ∅ 4.1 Base Cases If γ = α = 0, then Σ is the sphere 2 Proof. Suppose for contradiction that the claim is false. and G = G Z. We just make sure that ` > α Z , 0 1 Consider a counterexample where G is minimal, and then one of the\ cycles C has an empty intersection≥ with | | i among all such counterexamples, choose| | one where Z. Then C G J , because = , and i 0 (J,Ω) is minimal. |W| C trivially bounds⊆ ∪ a disk in∈W the sphere Σ. V ∅ i Let ∆ = Σ int(∆ ), where ∆ is the disk that The more interestingS base case is γ = 0 and α = 1, 1 1 2 accommodates the\ vortex (G , Ω ). Then ∆ is a closed that is, Σ is a sphere and there is exactly one vortex: 1 1 disk and σ an embedding of G in ∆. = (G , Ω ) . Suppose that V (Ω ) = x , . . . , x 0 1 1 1 0 n We first prove that = . Suppose for contradic- V1 , where{ x =} Ωi (x ), and let (X : 0 { i < n) be− a i 1 0 i tion that (J, Ω) . LetW ∆ ∅ ∆ be the disk that ac- linear} decomposition of (G , Ω ) of depth≤α such that J 1 1 3 commodates (J,∈Ω). W If V (J) V⊆(Ω) 1, we can extend xi Xi. | \ | ≤ ∈ the embedding σ to G0 J, and by letting G− = G0 J ∪ 0 ∪ Claim 4.1. G does not contain a subwall of W of and − = (J, Ω) we obtain a counterexample 1 W W\{ } height 4α. with the same G and smaller , which contradicts the minimality. So V (J) V (Ω) W 2. Now V (J) V (Ω) Proof. Let W 0 G1 be a subwall of W . For every | \ | ≥ \ ⊆ i > m 1 contains at most one nail of W , because Z = and i [0, m 1], let Y ≤ = Xj and Y = − Xj. ∅ ∈ − i j=0 i j=i+1 therefore V (G0) V (J) 3. We can replace J by > > | ∩ | ≤ Then Y ≤ Y = Xi Xi+1 and thus Y ≤ Y α3 a smaller graph J that in addition to the vertices in i ∩ i ∩ S | i ∩ Si | ≤ ≤ ∗ α. Then V (Ω) has just one vertex v∗ which is connected to all vertices in V (Ω). If there is a nail of W in J, we can (1) for every row Q of W 0 there is no i such that both > replace this nail by v∗. This way we obtain a smaller Y ≤ and Y contain more than α nails of Q. i i counterexample to the claim. This proves that = W ∅ To see this, let Q≤ be the set of nails of Q in Yi≤ and and thus G = G0 G1. > > ∪ Q be the set of nails of Q in Yi . Observe that if By an argument given above, each vertex in X is > Q≤ α + 1 and Q α + 1 then there are α + 1 contained in G1, because otherwise it would destroy the | | ≥ | | ≥ > mutually disjoint paths from Q≤ to Q in W 0 G1: planarity of G0. We may furtgher assume assume that > ⊆ just take the columns of the nails in Q≤ Q in W 0 G X is not planar, because if ` is sufficiently large we ∪ − and connect them appropriately by rows of W 0. But cannot have ` nested cycle in a planar vortex of depth this leads to a contradiction, because the set Xi Xi+1 α3. > ∩ > of size at most α separates Q≤ Y ≤ from Q Y . Let us consider a graph G0 that is obtained from G ⊆ i ⊆ i This proves (1). by deleting V (K) and X. Then G0 is not planar with It follows from (1) that for every row Q of W 0 there the outer face boundary per(W ) (i.e, the perimeter of is an i = i(Q) such that X contains all but at most W ), because otherwise G X would be planar as well. i(Q) − 2α + 1 nails of row Q. Furthermore, for rows Q, Q0 (1) G1 contains a vertex in G X V (K). we have i(Q) = i(Q0), because there are more than α − − disjoint paths the nails of Q in Xi(Q) and the nails of Recall that our near embedding is nice, and let Q0 in X 0 . Hence if the height of W 0 is h0, there is an C0 G be a cycle with bd(∆ ) = σ(C0), where ∆ i(Q ) ⊆ 0 1 1 i = i(Q) such that Xi contains all but (h0 + 1)(2α + 1) is the disk that accomodates the vortex (G1, Ω1). nails of W 0. Overall, W 0 contains 2(h0 1)(h0 +1) nails. Let us first consider the case when X = . Suppose − ∅ Thus Xi contains at least (2h0 + 2α 1)(h0 + 1) nails. that there is a vertex v in G1 K that is at least 4α+1- As our near embedding is W -central,− it follows that central in W . Since X = ,∩ by Claim 4.1, this implies 2 ∅ (2h0 + 2α 1)(h0 + 1) 16α , which implies h0 < 4α that − ≤  (2) There is a path P that is a subpath of C0 such holds for all (γ0, α20 ) lexicographically smaller than that P is contained in K, the two endvertices of P are (γ, α2). on per(W ), and moreover, the Q G1 Arguing similarly as in the proof of Claim 4.2, we containing v that is bounded by P together with⊆ a may assume that = . Suppose that the vortices in W ∅ segment per(W ) does not contain a subwall of W of are (Gi, Ωi) for i [α2]. The cycle Ci of the `-nest height 4α. dividesV the graph G ∈X into two parts Y and G X Y − i − − i such that Yi contains all the cycles C1,...,Ci 1. We By (2) and since v is 4α + 1-central, P contains a − may assume that G and G are connected. Assuming vertex u that is 2α + 1-central. Let P ,P be P u. 0 0 00 that ` is even, we let H = G Y and H = G Y . Then both P and P hit the same 2α + 1 rows of−W , `/2 0 0 `/2 0 00 If ` is sufficiently large, may− assume that H and H\ are R ,R ,...,R , and hence there are 2α + 1 disjoint 0 0 1 2α connected. paths from P and P . Since both P and P are 0 00 0 00 If α 2, then we can find a path P H whose segments of C , this contradicts G being a vortex of 2 0 1 with endvertices≥ in two different vortices ⊆G ,G and depth α α. i j 3 all internal vertices in H . We can delete the path Finally,≤ assume X = . By the same argument as 0 P and merge the two vortices into one vortex. Then above, it follows that a6 path∅ P as in (2) does not exist. we apply the inductive hypothesis to the resulting near We claim the following. embedding and the subwall of W with perimeter C`/2+1. (3) Let x X. Then there is no connected subgraph If γ 1 and α 1, we either find a noncontractible ∈ ≥ 2 ≤ R G1 containing two neighbors x1, x2 of x that are cycle in H or a path with both endpoints in the vortex of⊆ face-distance in W at least (2ξ + 8)α2 such that R (as α 1, we have at most one vortex) that can be 2 ≤ contains a path P connecting x1 and x2 in K. completed to a noncontractible simple closed curve by connecting its two endpoints by an arc through the disk Suppose such a connected subgraph R exists. We accommodating the vortex. If we find a noncontractible may assume that R has a nonempty intersection with at cycle, we delete it and apply the induction hypothesis. least (2ξ + 8)α2 rows of W . If at least 8α + 1 rows of W If we find a path we delete it and split the vortex in can go to per(W ) from R without hitting any vertex in two. This gives us a near embedding of smaller genus C , then 4α + 1 of these paths would hit at least 4α + 1 0 and with one more vortex. Again we can apply the columns in G , a contradiction to Claim 4.1. 1 induction hypothesis. Thus at least 2ξα paths cannot go to per(W ) from This completes our proof (sketch) of Lemma 4.4 and R without hitting any vertex in C0. Let C00 = C0 X. − the Extension Lemma 4.1.  Since X ξ, thus C00 consists of at most l ξ paths | | ≤ ≤ P1,...,Pl. Since K is planar, if a subpath of Pj in K hits two columns L1,L2, it must hit all the columns 5 Defining the local structure in MSO between L1 and L2 in W . This implies that either there is a path Pi and a vertex u0 of Pi such that both Monadic second-order logic MSO is the extension of components of P u0 hit the same 2α + 1 columns or first-order predicate logic that admits quantification not i − rows (for some i), or there are two paths Pj,Pj0 such only over the individual elements of a structure, but that both Pj and Pj0 hit the same 2α + 1 columns or also over sets of elements. We only introduce a specific rows. In both cases, G1 cannot be a vortex of depth α, version of MSO for graphs; in the literature this version a contradiction. is known as MSO2 or GSO. Our logic uses four types of variables: individual variables ranging over vertices and Now if each vertex in X is (ξ + 1, (2ξ + 8)α2)-wide edges, respectively, and set variables ranging over sets of (that is, if c ξ +1 and d 2ξ +8)α2), (3) implies that vertices and sets of edges, respectively. Atomic formulas there is a subpath≥ P of C≥satisfying (2), which is also 0 are of the form x = x , where x and x are either both a contradiction. This completes the proof of Claim 4.2 0 0 vertex variables or both edge variables, I(x, y), where  x is a vertex variables and y an edge variable, X(x), where either x is a vertex variable and X a vertex- Observe that Claim 4.2 implies the base case γ = 0, set variable or x is an edge variable and X an edge- α2 = 1 of Lemma 4.4, because for sufficiently large ` it set variable. The formula x = x0 expresses equality, implies that the innermost cycle C1 of the `-nest is in the formula I(x, y) incidence, and the formula X(x) G0 and hence bounds a disk in the sphere. set membership (“the element x is contained in the set X”). MSO-formulas are built from atomic formulas 4.2 Inductive step Suppose that γ 1 or γ = 0 and using the usual Boolean connectives (conjunction), α 2, and suppose that the assertion≥ of Lemma 4.4 (disjunction), (implication), and∧ (negation) and∨ 2 ≥ → ¬ both existential and universal quantification over all The main difficulty here is to find such a format and four types of variables. not so much to write down the actual MSO-definitions, We write φ(X1,...,Xk) to indicate that the free which is merely a tedious exercise (much like coding in variables (that is, the variables that have an occurrence assembler). The main technical result of this section is not bound by a quantifier) are among X1,...,Xk. For a the Definability Lemma 5.7. G G graph G and interpretations X1 ,...,Xk of appropriate G G types for the variables, we write G = φ(X1 ,...,Xk ) 5.1 Vortices We say that a cyclic permutation Ω of | G to denote that G satisfies φ if Xi is interpreted by Xi . a set V (Ω) is compatible with a cycle C if V (Ω) = V (C) and vΩ(v) E(C) for all v V (C). A nice α-vortex in Example 5.1. The following formula cycle(Y ) with a a graph G ∈is a pair (H,C) such∈ that free edge-set variable Y says that Y is the edge set of a (1) H G; cycle. ⊆ (2) C G is a cycle in G with V (C) V (H) and cycle(Y ) := E(C⊆) E(H) = ; ⊆ ∩ ∅ x y Y (y) I(x, y) ∀ ∀ ∧ → (3) there is a cyclic permutation Ω of V (C) that is  compatible with C such that (H, Ω) is a α-vortex. y0Y (y0) y0 = y I(x, y0) ∃ ∧ 6 ∧ We say that a triple (XG,Y G,ZG), where XG V (G)  ⊆ y00 Y (y00) y00 = y y00 = y0 I(x, y00) and Y G,ZG E(G), represents a nice α-vortex (H,C) ∧ ¬∃ ∧ 6 ∧ 6 ∧ ⊆  in G if V (H) = XG, E(H) = Y G, and E(C) = ZG. X x X(x) y(Y (y) I(x, y))  G G G ∧ ∀ ∀ → ∃ ∧ Clearly, if (X ,Y ,Z ) represents (H,C) then we can G G G  xX(x) x y Y (y) I(x, y) X(x) reconstruct (H,C) from (X ,Y ,Z ), because V (C) ∧ ∃ ∧ ∃ ∃ ∧ ∧ ¬ → is determined by E(C). y x x0 Y (y) I(x, y) I(x0, y) X(x) X(x0) . For an edge set F E(G) in a graph G, it will be ∃ ∃ ∃ ∧ ∧ ∧ ∧ ¬ ⊆  convenient to denote the set of all vertices incident with The subformula in the first three lines says that the sub- an edge in F by V (F ). graph with edge set Y is 2-regular, and the subformula in the last three lines says that the subgraph with edge Lemma 5.1. For every nonnegative integer α there is set Y is connected. an MSO-formula vortexα(X,Y,Z) with a free vertex-set We can use the formula cycle(Y ) to express that a variable X and free edge-set variables Y,Z such that for G G G graph is Hamiltonian: we let all graphs G and sets X V (G), Y ,Z E(G) we have ⊆ ⊆ G G G hamiltonian := Y (cycle(Y ) x y(Y (y) I(x, y))). G = vortexα(X ,Y ,Z ) ∃ ∧ ∀ ∃ ∧ | if and only if (XG,Y G,ZG) represents a nice α-vortex To exploit MSO-definability algorithmically, we in G. need the following theorem, which is a slight extension of a well-known result due to Courcelle [4] from decision Proof. It is easy to construct MSO-formulas to evaluation problems [2] (also see [13]). society(X,Y,Z), path(X, Y, Z, x, y), sep(Z, x, y, z1, z2), and disjoint(Z1,...,Zα+1) such that for all graphs G, Theorem 5.1. ([4, 2]) For all nonnegative integers all XG V (G), and all Y G,ZG,ZG,...,ZG E(G), ⊆ 1 α+1 ⊆ `, w there is a linear time algorithm that, given a and all u, v, w1, w2 V (G), graph G of tree width at most w and an MSO-formula ∈ G G G φ(X ,...,X ) of length at most `, decides if there are G = society(X ,Y ,Z ) if and only if H := 1 k • G| G G interpretations XG,...,XG for the variables X in G (X ,Y ) is a subgraph of G (that is, V (Y ) 1 k i G G ⊆ G G X ) and Z is the edge set of a cycle C such that such that G = φ(X1 ,...,X ) and computes such in- | k V (C) V (H) and E(C) E(H) = . terpretations if they exist. ⊆ ∩ ∅ If H := (XG,Y G) is a subgraph of G, then G = MSO Our goal in this section will be to construct an - • path(XG,Y G,ZG, u, v) if and only if ZG is the edge| T formula defining near embeddings that are U -central set of a path in H with endvertices u and v. for some tangle defined by an unbreakable set U. But what does it mean to “define” a near embedding in If ZG is the edge set of a cycle C, then G = • G | MSO? For this, we need to find a way to represent near sep(Z , u, v, w1, w2) if and only if u, v, w1, w2 are embeddings in a format that is accessible in MSO, that mutually distinct vertices of C and w1, w2 sepa- is, as tuple of vertices, edges, vertex sets, and edge sets. rates u from v in C. { } G G G = disjoint(Z1 ,...,Zα+1) if and only if for 1 Lemma 5.3. For all nonnegative integers α, γ there is • i <| j α + 1 we have V (ZG) V (ZG) = . ≤ an MSO-formula disks (Z ...,Z ) with a free edge- ≤ i ∩ j ∅ α,γ 1 γ set variables Z1,...,Zα such that for all graphs G and Then we let all ZG,...,ZG E(G) we have 1 α ⊆ vortexα(X,Y,Z) := society(X,Y,Z) G = disks (Z ,...,Z ) ∧ | α,γ 1 α Z1 ... Zα+1 x1 ... xα+1 y1 ... yα+1 z1 z2 ¬∃ ∃ ∃ ∃ ∃ ∃ ∃ ∃ if and only if the following conditions are satisfied. disjoint(Z1,...,Zα+1) (1) ZG,...,ZG are the edge sets of mutually disjoint  α+1 1 α cycles C1,...,Cα G. path(X,Y,Zi, xi, yi) ⊆ ∧ i=1 (2) There is an embedding σ of G in a surface Σ of ^ Euler genus at most γ and mutually disjoint closed sep(Z, xi, yi, z1, z2) . ∧ disks ∆ ,..., ∆ Σ such that σ(G) int(∆ ) =  1 α i  and σ(C ) = bd(∆⊆) for all i [α]. ∩ ∅ This formula says that Z is the edge set of cycle with i i ∈ vertices in the subgraph (X,Y ) and edge set disjoint Proof. There are different ways of proving this lemma; from the subgraph and that there is no separator all require some background on graph embeddings. The z , z of the cycle Z and disjoint paths Z ,...,Z 1 2 1 α+1 one we choose is probably not the simplest, but it nicely in{ (X,Y} ) from one side of the separation to the other builds on the techniques we already used in Section 4. side. This expresses precisely that X,Y,Z represents It follows from Lemma 4.4 that for every γ there is an a nice α-vortex.   h such that for all graphs G embedded in a surface of Euler genus γ, if W is a wall of height h in G such that 5.2 Near Embeddings compG(W ) is planar, then (each of) the central brick(s) of W must bound a disk. Lemma 5.2. ([1]) For every nonnegative integer γ We exploit this as follows. Suppose we have a graph there is an MSO-sentence emb satisfied by a graph G if γ G and cycles C1,...,Cα G, and we want to test if G and only if G is embeddable in a surface of Euler genus has an embedding in a surface⊆ of Euler genus at most at most γ. γ where the cycles bound disks that are faces of the Proof sketch. The proof is by induction on γ. The embedding. We proceed as follows: for each cycle Ci we add a wall Wi of height h. We draw disjoint edges from sentence emb0 just says that neither K5 nor K3,3 is a the vertices of Ci to the perimeter of Wi, preserving minor. The sentence embγ+1 guesses the edge set of a noncontractible cycle, and a partition of the edges the cyclic order. If there are not enough vertices on the incident to a vertex of the cycle that says which edges perimeter, we subdivide some of the edges. Let G0 be go on which side of the cycle (one part of the partition the resulting graph. We claim that for every surface Σ may be empty). From the cycle and the partition, we of Euler genus at most γ, the graph G has an embedding can construct the graph obtained by cutting along the where the cycles Ci bound disks ∆i that are faces of the embedding if and only if G0 has an embedding in Σ. The cycle, and we say that this graph satisfies embγ 1 (in the − forward direction of this claim is obvious. To prove the orientable case) or embγ (in the nonorientable case).  backward direction, consider an embedding σ0 of G0 in Σ. For every i, take a disk ∆i0 bounded by a central Remark 5.1. Note that the proof of the lemma just brick of Wi. We modify the embedding by drawing the emb sketched not only gives us a sentence γ , but also whole wall Wi in the disk ∆i, with the perimeter on the an algorithm that, given γ computes such a sentence. boundary of the disk, and routing the edges from Ci to If we were only interested in the existence of a the perimeter in close neighbourhoods of the σ-images sentence, we could also use the fact that the class of all of paths from the perimeter to the central brick in Wi. graphs embeddable in a surface of Euler genus at most γ Let σ0 be the resulting embedding. Now we let ∆i be the is characterised by finitely many forbidden minors and union of ∆i0 with small neighbourhoods of the σ0-images emb let γ just state that these input graphs contains non all the edges from Ci to the perimeter of Wi. (So the of these forbidden minors. (This approach can also be disk ∆i has the shape of an octopus with a body in the made effective by using a result due to Seymour [31], disk ∆i0 and arms reaching out to the vertices of Ci.) We which says that there is a computable function that can redraw the cycle Ci by keeping the vertices where associates with each γ a set of forbidden minors for the they are and drawing the edges along the boundary of corresponding class.) the disk ∆i. This proves the claim. Thus to test if G has an embedding of the desired form, we can test if G0 Lemma 5.4. For all nonnegative integers α1, α2, α3, γ has an embedding in a surface of Euler genus γ. there is an MSO-formula To formalise this test in MSO, we define the graph ¯ ¯ ¯ G0 within the graph G, given the (edge sets of the) cycles near-embα1,α2,α3,γ (¯z, X, Y, Z) C1,...,Cα. We can do this by an MSO-transduction such that for all graphs G and all z¯G V (G)α1 , X¯ G (see, e.g., [5]). This is straightforward, though tedious. ∈ ∈ (2V (G))α2+1, Y¯ G (2E(G))α2+1, Z¯G (2E(G))α2 , Once we have defined G0, we can use Lemma 5.2 to test ∈ ∈ (in MSO) if it can be embedded in a surface of Euler G ¯ G ¯ G ¯G G = near-embα1,α2,α3,γ (¯z , X , Y , Z ) genus at most γ.  | if and only if the following conditions are satisfied.

Corollary 5.1. For all nonnegative integers α, γ G G (1) For 1 i α1 and 0 j α2, we have zi Xj . there is an MSO-formula nice-embα,γ (X,Y,Z1,...,Zα) ≤ ≤ ≤ ≤ 6∈ Let Z := zG, . . . , zG . with a free vertex-set variable X and free edge-set vari- { 1 α1 } ables Y,Z ,...,Z such that for all graphs G, all XG 1 α (2) For i = 0, . . . , α , the pair G := (XG,Y G) is a V (G) and Y G,ZG,...,ZG E(G) we have ⊆ 2 i i i 1 α ⊆ subgraph of G. G G G G α2 G = nice-emb (X ,Y ,Z ,...,Z ) Let H := Gi. | α,γ 1 α i=0 (3) For 1 iS α , the set ZG is the edge set of a if and only if the following conditions are satisfied. ≤ ≤ 2 i cycle Ci G0, where G0 is the graph obtained from G G ⊆ (1) H := (X ,Y ) is a subgraph of G. G0 by adding an edge between any two nonadjacent G vertices v, w V (G0) such that there is a connected (2) For all i [α] the set Zi is the edge set of a cycle ∈ ∈ components A of G0 (V (H) Z) with v, w Ci H0, where H0 is the graph obtained from H by N G(A). \ ∪ ∈ adding⊆ an edge between any two nonadjacent ver- tices v, w such that there is a connected components (4) For 1 i α2, we have V (Gi) V (G0) = V (Ci) A of G V (H) with v, w N G(A). and E(≤G )≤ E(G ) = . ∩ \ ∈ i ∩ 0 ∅ (3) The cycles C1,...,Cα are mutually disjoint. (5) For 1 i < j α , we have G G = . ≤ ≤ 2 i ∩ j ∅ (4) There is an embedding σ of H0 in a surface Σ of (6) For 1 i α2 the pair (Gi,Ci) is a nice α3-vortex. Euler genus at most γ. ≤ ≤ (7) For all connected components A of G (V (H) Z), \ ∪ (5) There are closed disks ∆ ,..., ∆ Σ, for some let N := N G(A) Z. Then N V (G ) and 1 n A \ A ⊆ 0 n α, with disjoint interiors such⊆ that for all N 3. ≥ | A| ≤ i [n] we have σ(H) int(∆i) = . ∈ ∩ ∅ (8) There is an embedding σ of G0 in a surface Σ of (6) For 1 i α, the simple closed curve σ(C ) is the Euler genus at most γ. ≤ ≤ i boundary of the disk ∆i. (9) There are mutually disjoint closed disks (7) For α + 1 i n there is a connected component ∆ ,..., ∆ Σ, for some n α , such that 1 n ⊆ ≥ 2 A of G V≤(H≤) such that σ(V (G )) bd(∆ ) = for all i [n] we have σ(G ) int(∆ ) = . 0 i ∈ 0 ∩ i ∅ σ(N G(A\)). ∩ (10) For i = 1, . . . , α2, the simple closed curve σ(Ci) is (8) For every connected component A of G V (H) there the boundary of the disk ∆i. is an i, α + 1 i n, such that σ\(N G(A)) (11) For i = α + 1, . . . , n there is a connected compo- bd(∆ ). ≤ ≤ ⊆ 2 i nents A of G (V (H) Z) such that σ(V (G )) \ ∪ 0 ∩ bd(∆i) = σ(NA). In the following lemmas,z ¯ = (z1, . . . , zα1 ) denotes an α -tuple of vertex variables, X¯ = (X ,...,X ) an 1 0 α2 (12) For all connected components A of G (V (H) Z) (α2 + 1)-tuple of vertex-set variables, Y¯ = (Y0,...,Yα ) \ ∪ 2 there is an i, α2 + 1 i n, such that σ(NA) an (α2 + 1)-tuple of edge-set variables, and Z¯ = ≤ ≤ ⊆ bd(∆i). (Z1,...,Zα2 ) an α2-tuple of edge-set variables. We denote tuples of interpretations for these variables in Proof. This follows easily from Lemma 5.1 and Corol- a graph G byz ¯G = (zG, . . . , zG ), X¯ G = (XG,...,XG ) 1 α1 0 α2 lary 5.1.  et cetera. Let G be a graph. We say that a tu- In view of Lemma 3.1, this lemma essentially says ple (¯zG, X¯ G, Y¯ G, Z¯G) V (G)α1 (2V (G))α2+1 that the “big” part of a separation (with respect to ∈ × × (2E(G))α2+1 (2E(G))α2 represents a nice (α , α , α )- T in must not be contained in an element of × 1 2 3 V ∪ W near embedding (σ, G0,Z, , ) of G in a surface Σ if and thus rephrases the definition of the near embedding V W being T-central. We omit the proof, which is surpris- G = near-emb (¯zG, X¯ G, Y¯ G, Z¯G) | α1,α2,α3,γ ingly tedious, though essentially just a straightforward application of the definitions, the tangle axioms, and and Z = zG, . . . , zG and G = (XG,Y G), and with 1 α1 0 0 0 Lemma 3.1. G ,C defined{ as in (2),} (3) we have = (G , Ω ) i i V { i i | 1 i α2 , where Ωi is a cyclic permutation of V (Ci) Corollary 5.2. Let T be a tangle of order > α1 + 3 ≤ ≤ } G G G G compatible with Ci, and (8)–(12) hold for the surface Σ in a graph G. Let (¯z , X¯ , Y¯ , Z¯ ) be a tuple that and the embedding σ. represents a nice (α1, α2, α3)-near embedding of G that G ¯ G ¯ G ¯G For every tuple (¯z , X , Y , Z ) with G = is T-central. Then all nice (α1, α2, α3)-near embeddings G ¯ G ¯ G ¯G | G G G G near-embα1,α2,α3,γ (¯z , X , Y , Z ) there is a nice of G represented by (¯z , X¯ , Y¯ , Z¯ ) are T-central. (α , α , α )-near embedding (σ, G ,Z, , ) of G 1 2 3 0 V W in a surface Σ represented by (¯zG, X¯ G, Y¯ G, Z¯G). In the following two lemmas,x ¯ = (x1, . . . , x3β 2) G− Whereas σ, G ,Z, are immediately given by the tu- denotes a (3β 2)-tuple of vertex variables andx ¯ = 0 G G − G ¯ G ¯ G V¯G (x1 , . . . , x3β 2) its interpretation in a graph G. ple (¯z , X , Y , Z ) and (1)–(12), we need to de- − fine . We let A1,...,Ak be the connected compo- Lemma 5.6. For every positive integer β there is an nentsW of G (V (H) Z). We inductively define sets \ ∪ MSO-sentence unbreakableβ(¯x) such that for every graph , ,..., of societies. We let = . To G 3β 2 W0 W1 Wk W0 ∅ G and x¯ V (G) − , define i+1, we look at the component A = Ai+1. ∈ W G If there is a society (J, Ω) i such that NA = G = unbreakableβ(¯x ) G ∈ W | N (A) Z V (Ω), we let J 0 = J G[V (A) NA] G G \ ⊆ ∪ ∪ if and only if the vertices x1 , . . . , x3β 2 are pairwise and := ( (J, Ω) ) (J , Ω) . Otherwise, we − i+1 i 0 distinct, and the set xG, . . . , xG is β-unbreakable chooseW an arbitraryW \{ cyclic} permutation∪ { } Ω of N and let 1 3β 2 A in G. { − } := (G[V (A) N ], Ω) . We let = . Wi+1 Wi ∪ { ∪ A } W Wk Conversely, it is not hard to see that for every Proof. For all nonnegative integers k, `, m, we let nice near embedding (σ, G ,Z, , ) with Z = 0 sepk,`,m(x1, . . . , xk, y1, . . . , y`, z1, . . . , zm) be an G ¯ G ¯ G ¯GV W 6 ∅ there is a tuple (¯z , X , Y , Z ) representing it. We MSO-formula stating that z1, . . . , zm separates may restrict our attention to near embeddings with x , . . . , x from y , . . . , y {. Using} these for- { 1 k} { 1 `} nonempty Z, because as long as α1 > 0, we can always mulas, for all partitions (I, J, K) of [3β 2] and add an arbitrary element to Z if it is empty. all nonnegative integers m we obtain a− formula Thus the formula near-emb essentially de- α1,α2,α3,γ sep(I,J,K),m(x1, . . . , x3β 2, y1, . . . , ym) saying that − fines near embeddings. Our final task is to define only xk k K y1, . . . , ym separates xi i I from such near embeddings that are T-central, for a tangle {x | j ∈J }. ∪We { let } { | ∈ } { j | ∈ } T = TU coming from an unbreakable set. For the fol- lowing lemma, recall Lemma 3.1. unbreakableβ(x1, . . . , x3β 2) := xi = xj − 6 1 i α1 + 3 in 3β 2 m G ¯ G ¯ G ¯G − a graph G. Let (¯z , X , Y , Z ) be a tuple that repre- y ... y x = y ∧ ¬ ∃ 1 ∃ m i 6 ` sents an (α1, α2, α3)-near embedding (σ, G0,Z, , ) of i=1 V W (I,J,K_),m  ^ `^=1 G in a surface Σ, and let Z,G0,...,Gα2 ,H be defined as above. Then (σ, G ,Z, , ) is T-central if and only sep(I,J,K),m(x1, . . . , x3β 2, y1, . . . , ym) , 0 V W ∧ − if for all S V (G) with S < β and Z S the follow-  ⊆ | | ⊆ where the disjunction ranges over all partitions (I, J, K) ing two conditions are satisfied. Let C = CT,S and let Cˆ of [3β 2] and all nonnegative integers m such that be the graph with vertex set V (Cˆ) = V (C) S and edge − ∪ K +m < β and I + K +m < 3β 2 and J + K +m < set E(Cˆ) = E(C) vw E(G) v V (C), w S . | | | | | | − | | | | ∪ { ∈ | ∈ ∈ } 3β 2.  (1) There is no i α such that Cˆ Z G . − ≤ 2 \ ⊆ i Lemma 5.7. (Definability Lemma) For all nonneg- (2) There is no connected component A of G (Z ative integers α , α , α , β, γ where β > α + 3 there is V (H)) such that Cˆ Aˆ, where Aˆ is the\ graph∪ 1 2 3 2 an MSO-formula with V (Aˆ) = V (A) ⊆ N G(A) Z and E(Aˆ) = E(A) vw E(G) ∪v V (A),∪ w N G(A) Z . tcen-near-emb (¯x, z,¯ X,¯ Y,¯ Z¯) ∪ { ∈ | ∈ ∈ ∪ } α1,α2,α3,β,γ G 3β 2 G such that for all graphs G, all x¯ V (G) − and z¯ Proof. Using Lemma 5.7 and Theorem 5.1, we can ∈ ∈ V (G)α1 and X¯ G (2V (G))α2+1 and Y¯ G (2E(G))α2+1 compute a tuple (¯zG, X¯ G, Y¯ G, Z¯G) that represents a ∈ ∈ and Z¯G (2E(G))α2 , near embedding. To obtain the actual near embedding, ∈ we need to compute an embedding σ of the graph G0 in G = tcen-near-emb (¯xG, z¯GX¯ G, Y¯ G, Z¯G) | α1,α2,α3,γ a surface Σ of Euler genus at most γ with the desired properties. We modify the graph G by adding walls W if and only if the following conditions are satisfied. 0 i of sufficient height and attaching them to the cycle with G G edge set ZG in a similar way as we did in the proof of (1) The vertices x1 , . . . , x3β 2 are pairwise distinct, i G − G Lemma 5.3 and then use Mohar’s linear time algorithm and the set U = x1 , . . . , x3β 2 is β-unbreakable in G. { − } for computing embeddings in a surface [20]. 

G G G G (2) The tuple (¯z , X¯ , Y¯ , Z¯ ) represents a TU - 6 Constructing a tree-decomposition over central nice (α1, α2, α3)-near embedding of G in a surface of Euler genus at most γ. α-near embeddable graphs Lemma 6.1. Let α1, α2, α3, β, γ be nonnegative inte- Proof. It is easy to see that there is a formula gers with β > α1 + max 3, 2α3 + 1 . Then there is a quadratic time algorithm{ that,} given an tanglecomp(x1, . . . , x3β 2, y1, . . . , yβ 1, z) − − (α1, α2, α3, β, γ)-decomposable graph G, computes an (α + 3β 2, α , 2α + 2, β, γ)-decomposition of G. such that such that for all graphs G and 1 − 2 3 G G G G G all x1 , . . . , x3β 2, y1 , . . . , yβ 1, z V (G), if Proof. The proof is a standard construction that goes G G − − ∈ x1 , . . . , x3β 2 are pairwise distinct, and the set back to [27]. An algorithmic version of the construction G − G U = x1 , . . . , x3β 2 is β-unbreakable in G, then has recently been applied in [15]. { − } We describe a recursive algorithm that, given a G G G G G G = tanglecomp(x1 , . . . , x3β 2, y1 , . . . , yβ 1, z ) locally (α1, α2, α3, β, γ)-decomposable graph G and a | − − set U V (G) of size 3β 2, constructs a G ⊆ ≤ − if and only if z is a vertex of the component CT,S for (α1, α2, α3, β, γ)-decomposition (T,Y ) of the graph G G G the tangle T = TU and the set S = y1 , . . . , yβ 1 . obtained from G by adding edges between any two ver- { − } The formula tanglecomp just has to say that for the tices in U. We view T as a rooted tree and assume that G component C of G S that contains z it holds that U Yr for the root r. (As U is a clique in G, there is (V (C) U) S \3β 2. ⊆ | ∩ ∪ | ≥ − some node r such that U Yr, and we may assume r Using the formula tanglecomp, we can define the to be the root.) ⊆ MSO conditions of Lemma 5.5 in , and the lemma follows So let G be a locally (α1, α2, α3, β, γ)-decomposable from Lemmas 5.4, 5.5 and 5.6.  graph and U V (G) with U 3β 2. If G 4β 3, we let T be a⊆ one node tree| only| ≤ consisting− | of| ≤ the root− For the following corollary, recall the definition r, and we let Yr = V (G). In the following, we assume of locally (α , α , α , β, γ)-decomposable graphs from that G > 4β 3. We let U 0 U be a subset of V (G) of 1 2 3 | | − ⊇ Section 3.3. size U 0 = 3β 2. To simplify the notation, we assume | | − that U = 3β 2 and hence U 0 = U. Corollary 5.3. For all nonnegative integers If| U| is not− unbreakable in G, we let (A, B) be a α1, α2, α3, β, γ such that β > α1 + 3 there is an separation of G of order < β that breaks U. Such a O(β) MSO-sentence loc-decα1,α2,α3,β,γ such that for all separation can be computed in time 2 n (see [15]). graphs G, Let S := V (A B). As (A, B) breaks U, we have ∩ G = loc-decα ,α ,α ,β,γ (V (A) U) S < 3β 2. If V (A) (U S) = , | 1 2 3 | ∩ ∪ | − \ ∪ 6 ∅ we let uA be an arbitrary vertex in this set, and we if and only if G is locally (α1, α2, α3, β, γ)-decomposable. let UA = (V (A) U) S uA ; otherwise we let U = (V (A) U)∩ S.∪ We∪ define { } U similarly. We 5.3 Algorithmic Application A ∩ ∪ B recursively decompose (A, UA) and (B,UB), and let Theorem 5.2. Let α1, α2, α3, β, γ be nonnegative inte- (TA,YA) and (TB,YB) be the resulting decompositions. gers such that β > α1 + 3. Then there is a linear time To construct the tree T , we take the disjoint union of algorithm that, given a graph G and a β-unbreakable set the trees TA and TB. We add a new root r and edges U V (G) of size U = 3β 2, computes a T -central from r to the roots of the trees T and T . We let ⊆ | | − U A B nice (α1, α2, α3)-near embedding of G in a surface of Yr = U S. For each node t V (TA) we let Yt = (YA)t Euler genus at most γ if such a near embedding exists. and for∪ each node t V (T )∈ we let Y = (Y ) . ∈ B t B t If U is unbreakable, we use the algorithm of Theo- r. Moreover, (σ, H ,Z U, (H , Ω ) 1 i α0 , ) is 0 ∪ { i i | ≤ ≤ 2} ∅ rem 5.2 to compute a TU -central nice (α1, α20 , α3)-near a nice (α1 + 3β 2, α20 , 2α3 + 2)-near embedding of H embedding (σ, G ,Z, , ) of G in a surface Σ of Eu- in Σ. − 0 V W ler genus at most γ, for some α0 α . Such an em- As it requires linear time to process each node of the 2 ≤ 2 bedding exists because G is locally (α1, α2, α3, β, γ)- tree, the overall running time of an algorithm computing decomposable. We assume that = (G , Ω ) 1 the decomposition is quadratic in G . V { i i | ≤ | |  i α0 and = (G , Ω ) α0 + 1 i m . ≤ 2} W { i i | 2 ≤ ≤ } For 1 i α0 , we use the algorithm of Lemma 3.2 ≤ ≤ 2 Remark 6.1. Note that in the proof of the lemma to compute a linear decomposition (Xij)0 j<`i of ≤ we needed the bound on the tree width of G only (Gi, Ωi) of depth at most 2α3 +2. Let xi0, . . . , xi(` 1) be − to guarantee that the decomposition can be computed an enumeration of V (Ωi) such that xij Xij and xij = j ∈ in quadratic time. If we are not interested in an Ω (x ). Let X0 = (X X ) x , and for 1 j < i i0 i0 i0 ∩ i1 ∪ { i0} ≤ efficient algorithm, the construction shows how to obtain `i, let Xij0 = (Xi(j 1) Xij) (Xij Xi(j+1)) xij . Let − a decomposition for any locally decomposable graph and `i 1 ∩ ∪ ∩ ∪{ } Xi = j=0− Xij0 . Then for every connected component thus yields a proof of the Global Structure Theorem 3.2. Gi A of Gi Xi there is a j such that N (A) X0 . We S \ ⊆ ij We are now ready to prove our main theorem. let Hi be the graph obtained from Gi[Xi] by adding an edge between any two nonadjacent vertices v, w X0 , ∈ ij Theorem 6.1. (Main Theorem) For all graphs R for any j. Then (Xij0 )0 j<`i is a linear decomposition of ≤ there are nonnegative integers α1, α2, α3, β, γ and a the society (Hi, Ωi) of depth at most 2α3 + 2 and width quadratic time algorithm that, given a graph G that at most 4α3 + 5. 0 excludes R as a minor, computes an (α1, α2, α3, β, γ)- α2 Let X0 = V (G0), and let X = i=0 Xi. Then for decomposition of G. every connected component C of G (X Z) we have S\ ∪ C Gi for some i [m]. If i α20 , there is a j < `i such Proof. Let G be a graph that excludes R as a minor. ⊆ G ∈ ≤ G that N (C) Xij0 Z and thus N (C) α1 +2α3 +1. Then G has an (α1, α2, α3, β, γ)-decomposition for a ⊆ G∪ | | ≤ G If i > α20 then N (C) Z 3 and thus N (C) suitable choice of the parameters α1, α2, α3, β, γ. | \G | ≤ | | ≤ α1 +3. In both cases, N (C) < β. Let A be the graph By repeatedly applying Corollary 4.1 (of the Weak with vertex set V (A) =| V (C) |(N G(C) Z) and edge set Structure Theorem) and the Extension Lemma 4.1, ∪ ∪ G E(A) = E(C) vw E(G) v V (C), w N (C) we can find a sequence w1, . . . , wm such that tw(G ∪ { ∈ | ∈ ∈ ∪ \ Z , and let B be the graph with vertex set V (G) V (C) w1, . . . , wm ) k, for some k = k(R), and that G } \ { } ≤ \ and edge set E(G) E(A). Then (A, B) is a separation w1, . . . , wi 1 has an (α1, α2, α3, β, γ)-decomposition if \ { − } of G of order < β and with Z V (A B). Moreover, we any only if G w1, . . . , wi has. Furthermore, we can ⊆ ∩ \{ } have A Z G for some i [n]. As the near embedding compute wi+1 from w1, . . . , wi in linear time, and we can \ ⊆ i ∈ (σ, G0,Z, , ) is TU -central, this implies that (B,A) compute a decomposition of G w1, . . . , wi 1 from a V W 6∈ \{ − } T and thus (V (A) U) V (A B) < 3β 2. Let decomposition of G w1, . . . , wi in linear time. U | ∩ ∪ ∪ | − \{ } U 0 = (V (A) U) V (A B). We recursively decompose Our algorithm first computes w1, . . . , wm, which ∩ ∪ ∩ (A, U 0) and obtain a tree decomposition (TC ,YC ) of the takes quadratic time. Then it uses the algo- graph A obtained from A by turning U 0 into a clique, rithm of Lemma 6.1 to compute an (α1, α2, α3, β, γ)- and we may assume that U U V (A) is contained in decomposition of G w1, . . . , wm , which also takes 0 \{ } the bag of the root of the tree⊇ T ∩. quadratic time. In the third step, for i = m, m 1,..., 1 C − To construct the tree T , we take the disjoint union it extends the decomposition of G w1, . . . , wi to a \{ } of the trees TC for all connected components C of decomposition of G w1, . . . , wi 1 . Eventually, this \{ − } G (X Z). We add a new root r and edges from yields a decomposition of G. Each extension step takes r to\ the∪ roots of the trees T . We let Y = X Z U, linear time, so overall the extension requires quadratic C r ∪ ∪ and for each node t V (TC ) we let Yt = (YC )t. time.  It remains to verify∈ that the torso of the root has a near-embedding of the desired form. We let H = G 0 0 7 Conclusions be the graph obtained from G0 by adding an edge between any two nonadjacent vertices v, w V (Ω) for We give a quadratic time algorithm for computing graph any (J, Ω) , and we let H be the graph∈ obtained minor decompositions. Given a graph G that excludes ∈α0 W some fixed graph R as a minor, it computes a tree de- from H 2 H by adding all vertices in Z U and for 0 i=1 i composition of G into pieces that are either “small” (of each z ∪Z U edges from z to all other vertices.∪ Then size bounded in terms of R ) or “nearly embeddable” in H is a∈ supergraphS∪ of the torso of our decomposition at a bounded genus surface| (where| the bound on the genus and the parameters associated with near embeddability [9] E. D. Demaine, M. Hajiaghayi, and K. Kawarabayashi, depend on R ). In addition, for all nearly embeddable Algorithmic graph minor theory: Decomposition, ap- pieces we can| | actually compute a near embedding, still proximation and coloring, Proc. 46th Annual Sympo- within quadratic time. Our algorithm improves previ- sium on Foundations of Computer Science (FOCS’05), ously known algorithms for computing such decomposi- (2005), 637–646. tions and thus improves many results from algorithmic [10] E. D. Demaine, M. Hajiaghayi, and K. Kawarabayashi, Contraction Decomposition in H-Minor-Free Graphs graph minor theory, which rely on the computation of and Algorithmic Applications, the 43rd ACM Sympo- such a decomposition. Moreover, and maybe even more sium on Theory of Computing (STOC’11), 441–450. importantly, our algorithm is significantly simpler than [11] M. DeVos, G. Ding, B. Oporowski, D. Sanders, B. the previous ones. Reed, P. Seymour, and D. Vertigan, Excluding any Let us make two final remarks regarding easy ex- graph as a minor allows a low tree-width 2-coloring. tensions of our results that we omitted in this confer- J. Combin. Theory Ser. B, 91 (2004), 25–41. ence paper to keep the presentation simpler. First, our [12] R. Diestel, K. Kawarabayashi, T. M¨uller, and algorithm can be made uniform, that is, we can con- P. Wollan, On the structure theorem of the ex- struct a single algorithm that given graphs G and R cluded minor theorem of large tree-width, to ap- computes a decomposition of G provided G excludes R pear in J. Combin. Theory, Ser. B. Available at http://arxiv.org/abs/0910.0946 as a minor. (If G contains R as a minor, the algorithm . [13] J. Flum, M. Frick, and M. Grohe. Query evaluation via may still succeed to compute a decomposition, or it may tree-decompositions. Journal of the ACM, 49(6):716– fail.) The running time of the algorithm is f( R ) G 2 | | | | 752, 2002. for some computable function f. And second, we can [14] M. Grohe, Local tree-width, excluded minors and extend our algorithm such that it can be applied to arbi- approximation algorithms, Combinatorica 23 (2003), trary graphs, and if it fails to compute a decomposition 613–632 (because the input graphs contains R as a minor), then [15] M. Grohe and D. Marx. Structure theorem and it returns an R-minor in G. isomorphism test for graphs with excluded topological subgraphs. In Proceedings of the 44th ACM Symposium on Theory of Computing, 2012. References [16] B. Grussien. Isoperimetric inequalities on the hexago- nal grid. Arxiv preprint arXiv:1201.0697, 2012. [1] I. Adler, M. Grohe and S. Kreutzer, Computing ex- [17] K. Kawarabayashi, Y. Kobayashi and B. Reed, The cluded minors, SODA’08, 641–650. disjoint paths problem in quadratic time, J. Combin. [2] S. Arnborg, J. Lagergren, and D. Seese. Easy problems Theory Ser. B 102 (2012), 424–435. for tree-decomposable graphs. Journal of Algorithms, [18] K. Kawarabayashi and P. Wollan, A simpler algorithm 12:308–340, 1991. and shorter proof for the graph minor decomposition, [3] H. L. Bodlaender, A linear-time algorithm for finding the 43rd ACM Symposium on Theory of Computing tree-decomposition of small , SIAM J. Com- (STOC’11), 451–458. put. 25 (1996), 1305–1317. [19] P. N. Klein, A linear time approximation for TSP in [4] B. Courcelle. Graph rewriting: An algebraic and logic undirected planar graphs with edge-weights, Siam J. approach. In J. van Leeuwen, editor, Handbook of Comput. 37 (2008), 1926–1952 Theoretical Computer Science, volume B, pages 194– [20] B. Mohar. Embedding graphs in an arbitrary surface 242. Elsevier Science Publishers, 1990. in linear time. In Proceedings of the 28th ACM [5] B. Courcelle and J. Engelfriet. Graph Structure and Symposium on Theory of Computing, pages 392–397, Monadic Second-Order Logic — A Language-Theoretic 1996. Approach. Cambridge University Press, 2012. [21] B. Mohar, Combinatorial local planarity and the width [6] A. Dawar, M. Grohe, and S. Kreutzer. Locally exclud- of graph embeddings, Canadian J. Mathematics 44 ing a minor. In Proceedings of the 22nd IEEE Sym- (1992), 1272–1288. posium on Logic in Computer Science, pages 270–279, [22] L. Perkovic and B. Reed, An improved algorithm for 2007. finding tree decompositions of small width, Interna- [7] E. D. Demaine, F. Fomin, M. Hajiaghayi, and D. tional Journal on the Foundations of Computing Sci- Thilikos, Subexponential parameterized algorithms on ence 11 (2000), 81–85. bounded-genus graphs and H-minor-free graphs, J. [23] B. Reed, Finding approximate separators and comput- ACM 52 (2005), 1–29. ing tree width quickly, Proc. 24th ACM Symposium on [8] E. D. Demaine and M. Hajiaghayi, Fast algorithms for Theory of Computing (STOC), 1992, 221–228. hard graph problems: , minors and [24] B. Reed. Tree width and tangles: A new connectiv- local treewidth, Proc. 12th Internat. Symp. on Graph ity measure and some applications. In R.A. Bailey, Drawing, Lecture Notes in Computer Science 3383, editor, Surveys in Combinatorics, volume 241 of LMS Springer, 2004, pp. 517–533. Lecture Note Series, pages 87–162. Cambridge Univer- sity Press, 1997. [25] N. Robertson and P. D. Seymour, Graph minors V. Excluding a planar graph, J. Combin. Theory Ser. B, 41 (1986), 92-114. [26] N. Robertson and P. D. Seymour, Graph minors IX. Disjoint crossed paths, J. Combin. Theory Ser. B, 49 (1990), 40–77. [27] N. Robertson and P. D. Seymour, Graph minors. X. Obstructions to tree-decomposition, J. Combin. Theory Ser. B, 52 (1991), 153–190. [28] N. Robertson and P. D. Seymour, Graph minors. XIII. The disjoint paths problem, J. Combin. Theory Ser. B 63 (1995), 65–110. [29] N. Robertson and P. D. Seymour, Graph minors. XVI. Excluding a non-planar graph, J. Combin. Theory Ser. B, 89 (2003), 43–76. [30] N. Robertson and P. D. Seymour, Graph minors. XX. Wagner’s conjecture, J. Combin. Theory Ser. B, 92 (2004), 325–357. [31] P. Seymour. A bound on the excluded minors for a surface. Unpublished manuscript, 1995.