A more accurate view of the Flat Wall Theorem

We introduce a supporting combinatorial framework for the Flat Wall Theorem. In particular, we suggest two variants of the theorem and we introduce a new, more versatile, concept of wall homogeneity as well as the notion of regularity in flat walls. All proposed concepts and results aim at facilitating the use of the irrelevant vertex technique in future algorithmic applications.


Introduction
One of the cornerstone achievements of the Graph Minors series by Robertson and Seymour was the celebrated Flat Wall Theorem, proved in the 13th paper of the series [36].It is a powerful graph structural result, revealing the local structure of H-minor-free graphs.The Flat Wall Theorem has important consequences and applications in structural graph theory and in graph algorithm design.It served as the combinatorial base for the design of an algorithm for the following two problems: • Minor Testing: Given a graph G and a k-vertex graph H, decide whether G contains H as a minor.
• Disjoint Paths: Given a graph G with k pairs of terminals (s i , t i ), . . ., (s k , t k ), decide whether G contains k vertex-disjoint paths joining s i and t i for every i ∈ {1, . . ., k}.
These algorithms run in time f (k) • n 3 on n-vertex graphs, for some function f : N → N (see [27] for quadratic-time improvements).This, using the terminology of parameterized complexity, implies that both above problems, when parameterized by k, belong to the parameterized class FPT or, alternatively, admit FPT-algorithms.In order to obtain these algorithms, Robertson and Seymour introduced a powerful technique, called the irrelevant vertex technique, which has now become a standard technique in the design of parameterized algorithms (see e.g., Section 7 of the textbook [8]).Further algorithmic applications combining the Flat Wall Theorem and the irrelevant vertex technique appeared later in [2,9,12,17,25], while generalizations to directed graphs have recently appeared in [13,20].

The Flat Wall Theorem and its variants
The original statement of the Flat Wall Theorem, as appeared in [36], is the following.
Proposition 1.There exist functions f : N 2 → N and f : N 2 → N such that if G is a graph and h and k are integers, then one of the following holds: 1. G contains K h as a minor 1 .

G has treewidth at most f (k, h).
3. G has a vertex set A with |A| ≤ f (h), such that G \ A contains a flat wall W of height k.
We postpone the formal definitions of "treewidth", the related concept of "tree decomposition", and "flat wall" to Section 2. One can get a quick idea of a wall by looking at Figure 1 and of flat wall by looking at Figure 3 and Figure 5. Intuitively, a flat wall W is contained in a larger graph, its compass, that is separated from the rest of the graph via a separator S that is a "suitably chosen" part of the perimeter of W. This compass is "flat" in the sense that it does not contain two disjoint paths whose endpoints are in S and are "crossing" with respect to the cyclic ordering induced in S by the perimeter of W. As proved by Kawarabayashi, Thomas, and Wollan [31], this flatness property can be certified by a concept called rendition (corresponding to the concept of rural division in [36]) that can be seen as a plane embedding inside a disk of a hypergraph with hyperedges of arity at most three (see Figure 2 for a visualization of a rendition).Then the compass is "embedded" inside the rendition so that it can be seen as the union of graphs called flaps bijectively mapped to the hyperedges of the rendition.
In its original version in [36], Proposition 1 was proved for f (h) = h 2 with the additional assertion that f (k, h) is a bound on the treewidth of the "internal flaps", i.e., those that are not incident to the perimeter of W . Later, in [14], the same result was proved (without an algorithm) for f (h) = h−5 and f (k, h) = O h (k). 2 The original result of Robertson and Seymour was accompanied with an O(n•m)-time algorithm3 that outputs a certifying structure for each possible outcome.This algorithm was further improved to a linear one by Kawarabayashi, Kobayashi, and Reed in [27].
A recent wave of improvements of Proposition 1 appeared in the following form [7,31].
Proposition 2. There exist functions f : N 2 → N and f : N 2 → N such that if G is a graph and h and k are integers, and G contains a wall W of height f (k, h) as a subgraph, then one of the following holds: 1. G contains K h as a minor.
2. G has a vertex set A with |A| ≤ f (h), such that G \ A contains a flat wall W of height k.
Notice that Proposition 2 can indeed be seen as an extension of Proposition 1 because the exclusion of a wall of height k in a K h -minor-free graph implies that its treewidth is bounded by O h (k) [10,26].Moreover, according to [31, Theorem 1.9], Proposition 2 holds for f (h) = O(h 24 ) and f (k, h) = O(h 24 (h 2 + r)), and it enjoys the following additional features: (A) In the first case, the graph K h is a minor of G in a way that is "grasped by the wall W '.' 4(B) In the second case, the flat wall W is a subwall of W.
(C) Proposition 2 comes with an algorithm that certifies one of the two outcomes in linear time, in particular, in O(h 24 • m + n) time.
Moreover, the same result with Features (A) and (B) is proved in [31,Theorem 1.7] with the optimal function f (h) = h − 5 at the cost of a worst bound for f (k, h).Also [31,Theorem 1.8] corresponds to Proposition 2 with the additional feature that the compass of the flat wall W contains no wall of height f (k, h) + 1, again at the cost of a worst bound for f (k, h).Later, Chuzhoy [7] drastically improved the bounds of Proposition 2 with the extra Features (A) and (B) to f (h) = h − 5 and f (k, h) = O(h • (h + k)).Moreover, Chuzhoy gives a polynomial-time algorithm for her improved variant, however she does not specify whether this algorithm can run in linear time, as the one in [31,Theorem 1.9].

Our contribution
In this paper we provide a series of enhanced algorithmic versions of the Flat Wall Theorem as well as a series of combinatorial tools related to the applicability of the irrelevant vertex technique.In our presentation we adopt the framework and the terminology of [31].Our aim is to introduce a "more accurate" view of the Flat Wall Theorem that, we hope, will be useful for future algorithmic applications.Our contribution consists in the following.
(α) Subwalls of flat walls are not always flat.Our initial motivation comes from the fact5 that the claimed Feature (B) in Proposition 2, as stated in [31], needs some slight (but not neglectable) revision.This feature is based on [31,Lemma 6.1], asserting that if W is a flat wall and W is a subwall of W that is disjoint from the perimeter of W, then W is also a flat wall of G.As we observe in Subsection 2.3, there are some very marginal cases where a subwall of a flat wall is not flat anymore.This phenomenon is illustrated in the flat wall of Figure 3 (in Subsection 2.3).
(β) A reparation framework.Fortunately, the issue raised in (α) is just a minor formal mismatch that harms neither the spirit of the proofs of [31] nor the "essential" correctness of subsequent results that are based on [31].The first contribution of our paper is to propose an extension of the framework of [31] that supports a formally correct statement of Feature (B) in Proposition 2. What we show (Theorem 5) is that if a wall W is a flat wall, whose flatness is certified by some rendition R, and W is a subwall of W, then there is another, slightly different, subwall W of W, which we call a W -tilt, that is indeed flat 6 .By the term "slightly different" we mean that W and its W -tilt W may differ only perimetrically.Moreover, the rendition certifying the flatness of W maintains all the "internal" structure of the rendition R, relatively to W .This implies that all the arguments based on Proposition 2 of [31] are essentially correct, and can become formally correct under the suggested framework.In our definitions and proofs we pay attention to all the necessary formalism so to facilitate dealing with future results that may use those of [31] (or [7]).We conclude with Proposition 7 that is a version of Proposition 2 translated into our framework.
(γ) A Flat Wall Theorem with compasses of bounded treewidth.Our next result, Theorem 8 in Subsection 3.2, is an improved version of Proposition 1 with the following additional features: (1) (2) in the third case, the compass of the wall W comes with a tree decomposition of width at most f (k, h), and (3) the result is accompanied by a 2 O h (r 2 ) • n time algorithm.Notice that a non-algorithmic version of this result could be indirectly derived, with worst functions, combining [31,Theorem 1.8] and the main result of Kawarabayashi and Kobayashi in [26].We present this result in this paper for the following reasons: first because it is new, second because it is in a form suitable for future applications where it is important that the compass has bounded treewidth, and third because its proof provides an indicative sample of the potential of the formalism of W -tilts that we suggest in (β).
(δ) An alternative concept of wall homogeneity.As mentioned before, the Flat Wall Theorem has been the combinatorial base for the FPT-algorithms of [36] for Minor Testing and Disjoint Paths.One of the cornerstone ideas of [36] was to prove that the existence of a "big enough" flat wall W in the input graph G implies that a minor-model of H or a collection of k disjoint paths in G can be safely rerouted so to avoid the central vertices of this wall (see Figure 1 for a visualization of the central vertices of a wall).This permits us to declare parts of the wall "irrelevant" and find an equivalent instance of the problem with fewer vertices.In fact, avoiding the central vertices is not so straightforward when dealing with a flat wall W. This is because the rerouting has to be done inside the compass K of W where the paths should be rerouted through different, however "equivalent", flaps of the compass.To deal with this, Robertson and Seymour defined in [36] the concept of wall homogeneity.Roughly speaking, when a wall is homogenous then the variety of the ways that paths may be routed through the flaps that are inside some "brick" of the wall is the same for all bricks.In [36] it was proved that every big enough flat wall contains a still big homogeneous subwall where the claimed rerouting is possible, with the help of later results of the Graph Minors series [37,38].
The definition of wall homogeneity in [36] was based on the concept of the vision of a flap and was quite particular to the problems it was dealing with.To our knowledge, after [36], no much use of homogeneity, as defined in [36], was done for algorithmic purposes.Most of the results where the irrelevant vertex technique was applied concerned questions on surface-embeddable graphs where the wall is "already" disk-embedded and there is no need of homogeneity (see e.g.[16,21-24,28-30, 33, 34]).An indicative exception to this rule is the celebrated algorithm in [17,18] for the problem of checking whether H is a topological minor of a graph G where some notion of homogeneity, tailor-made for this problem, was introduced (see [18,Theorem 5.8] and also [12]).
In this paper we introduce an alternative notion of wall homogeneity that is simpler and more versatile to use.This is done in Subsection 3.3 and is based on the framework introduced in (β).Our definition may help dealing with the wide variety of the problems as it permits any version of finite index flap equivalency (for instance, flap equivalency based on MSOL-expressibility). We accompany the definition with an FPT-algorithm that finds a homogeneous subwall.This, together with the main result of (γ), can permit us to find "big-enough" homogeneous walls with compasses of bounded treewidth.This, in turn, will permit the answer of MSOL-queries in parts of the compass and will allow more elaborated applications of the irrelevant vertex technique (such as those used for problems on surface-embeddable graphs in [11,15]).
(ε) Regular flatness pairs and plane representations.We call a pair (W, R) flatness pair if W is a flat wall whose flatness is certified by the rendition R. Based on the framework of (β), in Subsection 3.4 we introduce a notion of regularity for flatness pairs, which roughly demands that the branching vertices of the wall are "internal" with respect to the flaps of the compass of W. Regular flatness pairs permit the representation of the compass of a flat wall by a graph embedded in a disk and a "well-arranged" wall inside it.This "plane" representation of flat walls will appear handy in other applications.For instance, it has been a useful tool for the proofs of the main combinatorial results of [5,39] as it makes it possible to translate routing questions inside compasses to analogous questions on planar embeddings and deal with them in a more easy way (using the new homogeneity concept of (δ)).

Organization of the paper
In Section 2 we provide some definitions and preliminary results and we state the two main results of this paper (Theorem 5 and Theorem 6), that assert the existence of an algorithm computing a tilt of a subwall of a flat wall and of an algorithm, that given a flatness pair outputs a regular flatness pair, respectively.We prove Theorem 5 and Theorem 6 in Section 4. In Section 3, we develop the tools to address the topics (β), (γ), (δ), and (ε) listed above.

Preliminaries
Sets and integers.We denote by N the set of non-negative integers.Given two integers p, q, where p ≤ q, we denote by [p, q] the set {p, . . ., q}.For an integer p ≥ 1, we set [p] = [1, p] and . For a set S, we denote by 2 S the set of all subsets of S and by S 2 the set of all subsets of S of size 2. If S is a collection of objects where the operation ∪ is defined, then we denote S = X∈S X.
Basic concepts on graphs.As a graph G we denote any pair (V, E) where V is a finite set and E ⊆ V 2 , that is, all graphs of this paper are undirected, finite, and without loops or multiple edges.We also define Given an edge e = {u, v} ∈ E(G), we define the subdivision of e to be the operation of deleting e, adding a new vertex w, and making it adjacent to u and v.Given two graphs H, G, we say that H is a subdivision of G if H can be obtained from G by subdividing edges.The contraction of an edge e = {u, v} of a simple graph G results in a simple graph G obtained from G \ {u, v} by adding a new vertex uv adjacent to all the vertices in the set (N G (u) ∪ N G (v)) \ {u, v}.A graph G is a minor of a graph G if G can be obtained from a subgraph of G after a series of edge contractions.

Disk-embedded graphs
Let ∆ be a closed disk.We use bd(∆) to denote the boundary of ∆ and int(∆) to denote the open disk ∆ \ bd(∆).When we embed a graph G in the plane or in a disk, we treat G as a set of points.This permits us to make set operations operations between graphs and sets of points.We say that a graph G is ∆-embedded if G is embedded in ∆ without crossings such that the intersection of bd(∆) and G (seen as a set of points of ∆) is a subset of V (G).
A circle of ∆ is any set homeomorphic to {(x, y) ∈ R 2 | x 2 + y 2 = 1}.Given two distinct points x, y ∈ D, an (x, y)-arc of D is any subset of D that is homeomorphic to the closed interval [0, 1].

Walls.
Let k, r ∈ N. The (k × r)-grid is the graph whose vertex set is [k] × [r] and two vertices (i, j) and (i , j ) are adjacent if |i − i | + |j − j | = 1.An elementary r-wall, for some odd integer r ≥ 3, is the graph obtained from a (2r × r)-grid with vertices (x, y) ∈ [2r] × [r], after the removal of the "vertical" edges {(x, y), (x, y + 1)} for odd x + y, and then the removal of all vertices of degree one.Notice that, as r ≥ 3, an elementary r-wall is a planar graph that has a unique (up to topological isomorphism) embedding in the plane R 2 such that all its finite faces are incident to exactly six edges.The perimeter of an elementary r-wall is the cycle bounding its infinite face, while the cycles bounding its finite faces are called bricks.Also, the vertices in the perimeter of an elementary r-wall that have degree two are called pegs, while the vertices (1, 1), (2, r), (2r − 1, 1), and (2r, r) are called corners (notice that the corners are also pegs).An r-wall is any graph W obtained from an elementary r-wall W after subdividing edges (see Figure 1).A graph W is a wall if it is an r-wall for some odd r ≥ 3 and we refer to r as the height of W. Given a graph G, a wall of G is a subgraph of G that is a wall.We insist that, for every r-wall, the number r is always odd.
A vertical (resp.horizontal) path of W is one that is a subdivision of a vertical (resp.horizontal) path of W . Notice that the perimeter of an r-wall W is uniquely defined regardless of the choice of the elementary r-wall W .A subwall of W is any subgraph W of W that is an r -wall, with r ≤ r, and such the vertical (resp.horizontal) paths of W are subpaths of the vertical (resp.horizontal) paths of W.
Tilts.The interior of a wall W is the graph obtained from W if we remove from it all edges of D(W ) and all vertices of D(W ) that have degree two in W. Given two walls W and W of a graph G, we say that W is a tilt of W if W and W have identical interiors.

Renditions
Paintings.Let ∆ be a closed disk.Given a subset X of ∆, we denote its closure by X and its boundary by bd(X).A ∆-painting is a pair Γ = (U, N ) where • N is a finite set of points of ∆, • N ⊆ U ⊆ ∆, and • U \ N has finitely many arcwise-connected components, called cells, where, for every cell c, • the closure c of c is a closed disk and We use the notation U (Γ) := U, N (Γ) := N and denote the set of cells of Γ by C(Γ).For convenience, we may assume that each cell of Γ is an open disk of ∆.
Notice that, given a ∆-painting Γ, the pair (N (Γ), {c | c ∈ C(Γ)}) is a hypergraph whose hyperedges have cardinality at most three and Γ can be seen as a plane embedding of this hypergraph in ∆.

Renditions.
Let G be a graph, and let Ω be a cyclic permutation of a subset of V (G) that we denote by V (Ω).By an Ω-rendition of G we mean a triple (Γ, σ, π), where (a) Γ is a ∆-painting for some closed disk ∆, , such that the points in N (Γ) ∩ bd(∆) appear in bd(∆) in the same ordering as their images, via π, in Ω.
We say that an Ω-rendition (Γ, σ, π) of a graph G is tight if the following conditions are satisfied: (i) If there are two points x, y of N (Γ) such that e = {π(x), π(y)} ∈ E(G), then there is a cell c ∈ C(Γ) such that σ(c) is the two-vertex connected graph (e, {e}), (ii) for every c ∈ C(Γ), every two vertices in π(c) belong to some path of σ(c), (iii) for every c ∈ C(Γ) and every connected component (iv) there are no two distinct non-trivial cells c 1 and c 2 such that π( c1 ) = π( c2 ), and (v) for every c ∈ C(Γ) there are |c| vertex-disjoint paths in G from π(c) to the set V (Ω).For the second property, let c be a cell in C(Γ) and let C be a collection containing every component of the graph σ(c).We say that Notice that each equivalence class of this equivalence relation corresponds to some partition P of π(c).If this equivalence relation has only one class, then (ii) holds, because of condition (c.3) of the definition of rendition.If not, we remove c from the rendition and we replace it with as many cells as the number of equivalence classes, one for each equivalence class and we update σ so that each new cell is mapped to the union of the members of the equivalence class corresponding to it.
For the third property, consider some c ∈ C(Γ), and observe that, because of (i) and (ii), the graph σ(c) \ π(c) contains at least one connected component, say ).Notice that this equivalence relation has at most eight equivalence classes, each corresponding to a subset of π(c).For each subset X of π(c), we define the graph F X as the union of the graphs in the corresponding equivalence class.Let also X * be the non-empty subset of π(c) such that C * is a subgraph of F X * .We enhance F X * := F X * ∪ F ∅ .We now remove the cell c from the rendition and for every non-empty X ∈ 2 π(c) where F X is non-null, we add a new cell c X and we update σ by mapping each c X to the graph F X .
For property (iv), for every two distinct non-trivial cells c 1 and c 2 with π( c1 ) = π( c2 ), we remove c 2 from the rendition and we update σ(c The last property can be achieved as follows: we first construct an auxiliary planar graph G by substituting in G each σ(c) by a clique on π(c) (that is a vertex, an edge, or a triangle) and by adding a new vertex v new adjacent to all the vertices in V (Ω); then the new rendition can be easily constructed starting from the triconnected component C of G that contains v new (to find the triconnected components, one may use the classic algorithm of Hopcroft and Tarjan [19] that runs in O(n + m) time) and then attaching to C, as images of the updated π, the other triconnected components.
In the rest of this paper we use only conditions (i)-(iii) of the tightness definition.However, we adopt the above, more strict, version of tightness as it will be useful in further applications.

Flatness pairs
Let W be an r-wall, for some odd integer r ≥ 3. We say that a pair (P, C) ⊆ D(W ) × D(W ) is a choice of pegs and corners for W if W is the subdivision of an elementary r-wall W where P and C are the pegs and the corners of W , respectively (clearly, C ⊆ P ).To get more intuition, notice that a wall W can occur in several ways from the elementary wall W , depending on the way the vertices in the perimeter of W are subdivided.Each of them gives a different selection (P, C) of pegs and corners of W.
Let an odd integer r ≥ 3 and W be an r-wall of some graph G.We say that W is a flat r-wall of G if there is a separation (X, Y ) of G and a choice (P, C) of pegs and corners for W such that: • if Ω is the cyclic ordering of the vertices X ∩ Y as they appear in D(W ), then there exists an Because of Lemma 3, we can assume (and we also demand) that the Ω-rendition (Γ, σ, π) of G[Y ] in the above definition is always tight.We mention here that Chuzhoy [7] uses a slightly different notion of flatness, where the separation (X, Y ) consists of two edge-disjoint subgraphs, instead of two vertex sets, and where the graph Y may play the role of the compass.Flatness pairs.Given the above, we say that the choice of the 7-tuple R = (X, Y, P, C, Γ, σ, π) certifies that W is a flat wall of G.We call the pair (W, R) a flatness pair of G and define the height of the pair (W, R) to be the height of W. We use the term cell of R in order to refer to the cells of Γ.
We call the graph G[Y ] the R-compass of W in G, denoted by compass R (W ).We define the flaps of the wall and F consists of one edge between the two vertices in ∂F.We call the edges of the trivial flaps short edges of compass R (W ).A cell c of R is untidy if π(c) contains a vertex x of W such that two of the edges of W that are incident to x are edges of σ(c).Notice that if c is untidy then |c| = 3. Figure 3: A flat 7-wall W in a graph G whose flatness is certified by some rendition R where the choice of pegs and corners in R corresponds to the squared vertices.We depict only the Rcompass of W that consists of W and some "black paths" between the vertices of W. The 5-wall W consisting of the fat edges (purple, green, blue) is a flat R-normal wall of compass R (W ).The flatness of W is certified by the rendition R = (X , Y , P , C , Γ , σ , π ), where X contains all the vertices incident to at least one orange edge plus the non-depicted vertices in the grey area, Y contains all vertices that are either in a "fat" black path or incident to at least two fat edges, the pegs are the diamond vertices, and the corners are the fat diamond vertices (that are also pegs).For the (tight) Ω -rendition (Γ , σ , π ) of G[Y ], see Figure 4.
In Figure 3 we depict a flat wall W in a graph G as well as the R-compass of W in G, for some rendition R certifying its flatness.Notice that there is a unique subwall W of W that is disjoint from D(W ) and has height five.Interestingly, the subwall W is not a flat wall of G, however there is a tilt W of W that is a flat wall of G.The wall W is depicted in Figure 3 and the rendition certifying its flatness is depicted in Figure 4.

Cell classification. Given a cycle
contains two points p, q ∈ N (Γ) such that π(p) and π(q) are vertices of C where one, say P in c , of the two (π(p), π(q))-subpaths of C is a subgraph of σ(c) and the other, denoted by P out c , (π(p), π(q))subpath contains at most one internal vertex of σ(c), which should be the (unique) vertex z in ∂σ(c) \ {π(p), π(q)}.We pick a (p, q)-arc A c in ĉ := c ∪ c such that π −1 (z) ∈ A c if and only if P in c contains the vertex z as an internal vertex.
We consider the circle Notice that every wall of W (and hence every subwall of W ) is an R-normal wall of compass R (W ).We denote by S R (W ) the set of all R-normal walls of compass R (W ).Given a W ∈ S R (W ) and a cell c of R we say that c is W -perimetric/internal/external/marginal if c is D(W )-perimetric/internal/external/marginal.We also use Regular pairs.Let (W, R) be a flatness pair of a graph G.We call a flatness pair (W, R) of a graph G regular if none of its cells is W -external, W -marginal, or untidy.Tilts of flatness pairs.Let (W, R) and ( W , R ) be two flatness pairs of a graph G and let W ∈ S R (W ).We also assume that R = (X, Y, P, C, Γ, σ, π) and R = (X , Y , P , C , Γ , σ , π ).We • the set of W -internal cells of R is the same as the set of W -internal cells of R and their images via σ and σ are also the same, • compass R ( W ) is a subgraph of influence R (W ), and The next observation follows from the definitions of regular flatness pairs and tilts.
Observation 4. If (W, R) is a regular flatness pair, then for every W ∈ S R (W ) every W -tilt of (W, R) is also regular.
The main results of this paper are the following.

Applications
In this section we apply Theorem 5 and Theorem 6 in order to address the items (β), (γ), (δ), and (ε) discussed in the introduction.

Tilts of subwalls
We present the following result from [31], stated in our new framework.
Proposition 7.There are two functions f 1 : N → N and f 2 : N → N and an algorithm that receives as input a graph G, an odd integer r ≥ 3, a t ∈ N ≥1 , and an f 1 (t) • r-wall W in G, and outputs, in ).
An alternative of the above where f 1 (t) = O(t 2 ) and f 2 (t) = t − 5 = O(t) has been proved by Chuzhoy in [7] with a running time that is polynomial in the input size.However, we prefer the version of Kawarabayashi, Thomas, and Wollan [31] as their algorithm is linear.

Apex-walls with compasses of bounded treewidth
We first define the notion of treewidth.A tree decomposition of a graph G is a pair (T, χ) where T is a tree and χ : 2. for every edge e of G there is a t ∈ V (T ) such that χ(t) contains both endpoints of e, and 3. for every v ∈ V (G), the subgraph of The width of (T, χ) is defined as w(T, χ) This subsection is dedicated to the proof of the following result.
Theorem 8.There is a function f 3 : N → N and an algorithm that receives as input a graph G, an odd integer r ≥ 3, and a t ∈ N ≥1 , and outputs, in 2 Ot(r 2 ) • n time, one of the following: • a tree decomposition of G of width at most f 3 (t) • r, or We will need some additional results in order to prove Theorem 8. First we need the following result that is derived from [35].For a detailed analysis of the results of [35], see [3].Proposition 9.There exists an algorithm with the following specifications: • G * is obtained from G after identifying the vertices of a matching in G.
Moreover, this algorithm runs in 2 O(k) • n time.
The following result of Kawarabayashi and Kobayashi [26], provides a linear relation between the treewidth and the height of a largest wall in a minor-free graph.
Proposition 10.There is a function f 4 : N → N such that, for every t, r ∈ N and every graph G that does not contain K t as a minor, if tw(G) ≥ f 4 (t) • r, then G contains an r-wall.In particular, one may choose f 4 (t) = 2 O(t 2 log t) .
The following is the main result of [6].We will use it to compute a tree decomposition of a graph of bounded treewidth.

Proposition 11.
There is an algorithm that, given a graph G and an integer k, outputs either a report that tw(G) > k, or a tree decomposition of G of width at most 5k + 4.Moreover, this algorithm runs in 2 O(k) • n time.
The following result is derived from [1].We will use it in order to find a wall in a graph of bounded treewidth, given a tree decomposition of it.

Proposition 12. There is an algorithm that, given a graph G, a graph H on h edges without isolated vertices, and a tree decomposition of G of width at most k, outputs, if it exists, a minor of G isomorphic to H. Moreover, this algorithm runs in
We start by proving the following "light version" of Theorem 8.

Lemma 13. There exists an algorithm as follows:
Find-Wall(G, t, r) Input: A graph G, an odd r ∈ N ≥3 , and a t ∈ N ≥1 .Output: One of the following: • a report that G has treewidth at most f 4 (t) • r, where f 4 is as in Proposition 10, or Moreover, this algorithm runs in 2 Ot(r 2 ) • n time.To obtain an explicit dependence on t, this algorithm can be modified to run in time 2 2 O(t 2 log t) r log r+O(r 2 ) • n + 2 2 O(t 2 log t) r 3 log r .
Proof.We set c := f 4 (t) • r.Notice that there is a constant c t , depending on t, such that [40].We therefore assume that |E(G)| = O(t √ log t • n), otherwise we can immediately report that K t is a minor of G and stop.We now describe a recursive algorithm as follows.
We first argue for the base case, namely when |V (G)| < 12c 3 .To check whether K t is a minor of G, we use the minor-containment algorithm of Robertson and Seymour [36], which runs in O t (|V (G)| 3 ) = O t (r 3 ) time, and if this is the case, we report the same and stop.If not, then we check whether tw(G) ≤ c, using the algorithm of Arnborg, Corneil, and Proskurowski [4], in time r log r , and if this is the case, we report the same and stop.If not, we deal with the case where G does not contain K t as a minor and tw(G) > c.By Proposition 10 we know that G contains an r-wall.To find such a wall, we first consider an arbitrary ordering (v 1 , . . ., v |V (G)| ) of the vertices of G.For each i ∈ [|V (G)|], we set G i to be the graph induced by the vertices v 1 , . . ., v i .We iteratively run the algorithm of Proposition 11 on G i and c for ascending values of i.This algorithm runs in 2 O(c) • |V (G)| = 2 2 O(t 2 log t) r time.Let j ∈ [|V (G)|] be the smallest integer such that the above algorithm outputs a report that tw(G j ) > c and notice that where for n < 12c 3 , T (n, r, t) = 2 2 O(t 2 log t) •r log r+O(r 2 ) + O t (r 3 ) = 2 Ot(r 2 ) or, in the case we ask for an explicit dependence on t, T (n, r, t) = 2 2 O(t 2 log t) r 3 log r .Therefore, we have that T (n, r, t) = 2 Ot(r 2 ) • n or T (n, r, t) = 2 2 O(t 2 log t) r log r+O(r 2 ) • n + 2 2 O(t 2 log t) r 3 log r , as claimed.
Given a flatness pair (W, R) of a graph G and a set L ⊆ V (G), we say that (W, R) is L-avoiding if L ∩ V (compass R (W )) = ∅.We now proceed to the proof of Theorem 8.
Proof of Theorem 8. Notice that there is a constant c t , depending on t, such that [40].We therefore assume that |E(G)| = O(t √ log t • n), otherwise we can immediately report that K t is a minor of G and stop.We first give an algorithm with the following specifications.This algorithm involves recursion assuming an input with an additional set L that should be avoided by the desired flatness pair.For notational convenience, we define z : Algorithm Find_Low_TW_compass(G, r, t, L).Input: an odd r ∈ N ≥3 , a t ∈ N ≥1 , a graph G where tw(G) > z(r, t), and a set L ⊆ V (G) where |L| ≤ f 2 (t) + 1. Output: either a report that K t is a minor of G or a set A ⊆ V (G), where |A| ≤ f 2 (t), an Lavoiding flatness pair (W, R) of G \ A of height r, and a tree decomposition of the R-compass of W of width at most 5 • z(r, t) + 4.
Step 1.We set as the smallest odd integer that is not smaller than f 2 (t) + 2. Also, let f1 (t) be the smallest odd integer that is not smaller than f 1 (t).These augmentations are necessary in order to guarantee that the considered subwalls will be of odd height.We also set r = 2 • (r + 2) + 1. Run the algorithm of Lemma 13 for G, • f1 (t) • r , and t.This takes time 2 Ot(r 2 ) • n, or, for an explicit dependence on t, it can be modified to take time 2 2 O(t 2 log t) r log r+O(r 2 ) • n + 2 2 O(t 2 log t) r 3 log r .If the output is a report that K t is a minor of G, then return the same.Otherwise, because, tw(G) > z(r, t) ≥ • f 4 (t) • f1 (t) • r , the algorithm returns an • f1 (t) • (2(r + 2) + 1)-wall W of G.
Step 2. Call the algorithm of Proposition 7 on G, • r , t, and W.This takes O(t 25 If the output is a report that K t is a minor of G, then return the same.Otherwise, we have a set A ⊆ V (G), where |A| ≤ f 2 (t), and a flatness pair ( W , R ) of G \ A of height • r .
Step 3. Let W be a subwall of W of height r such that none of the vertices in L belongs to influence R (W ).The subwall W exists because 2 ≥ f 2 (t) + 2 ≥ |L| + 1 and W has height • r .We also consider four pairwise disjoint (r + 2)-subwalls of W , namely W 1 , W 2 , W 3 , and W 4 , and observe that each W i is also a subwall of W .For every i ∈ [4], we call the algorithm of Theorem 5 on G \ A, ( W , R ), and We finally fix i so that W i is a wall among W 1 , W 2 , W 3 , and W 4 where Step 4. We now consider the subwall W of W obtained from W \ D(W ) after repeatedly removing vertices of degree one until no such vertices exist anymore.Notice that W is an r-wall of G \ A. We call the algorithm of Theorem 5 on G \ A, (W, R), and W which outputs, in O(t √ log t • n) time, a W -tilt ( W , R ) of (W, R).Let K be the R -compass of W . Clearly, ( W , R ) is L-avoiding as well.
Step 5. Let G D be the graph obtained from G[V (K) ∪ A] if we contract all the vertices of D(W ) to a single vertex v * .Since ( W , R ) is a W -tilt of (W, R), K = compass R ( W ) is a subgraph of influence R (W ), and therefore the perimeter of W and the graph K do not have any vertex in common.This implies that K is a subgraph of G D .
Step 6.Call the algorithm of Proposition 11 with input G D and z(r, t).This runs in 2 2 O(t 2 log t) •r • n time.If the output is a tree decomposition of G D of width at most 5 • z(r, t) + 4, then, as K is a subgraph of G D , we have that ( W , R ) is an L-avoiding flatness pair of G \ A of height r where the R -compass of W has treewidth at most 5 • z(r, t) + 4. In this case, the algorithm outputs the pair ( W , R ) and the corresponding tree decomposition of the R -compass K of W obtained from the one of G D by removing the vertices in V (G D ) \ V (K ).
Step 7. Suppose now that tw(G D ) > z(r, t).Notice that, by construction, if G D \ A has an {v * }-avoiding flatness pair (W * , R * ) of height r, then (W * , R * ) will also be an L-avoiding flatness pair of G \ A. Moreover, since G D is a minor of G, if G D contains K t as a minor then also G does.Notice also that |A ∪ {v }| ≤ f 2 (t) + 1.Therefore, we can safely return Find_Low_TW_compass(G D , r, t, A ∪ {v }).This completes the description of the algorithm and its correctness.
Notice that the running time of the above algorithm is which implies that T (n, r, t) = 2 Ot(r 2 ) • n, and can be modified in order to obtain T (n, r, t) = 2 2 O(t 2 log t) r log r+O(r 2 ) • n + 2 2 O(t 2 log t) r 3 log r .
We define the function The algorithm claimed by the theorem calls first the algorithm of Proposition 11 with input G and z(r, t).This runs in 2 2 O(t 2 log t) •r • n time.If the output is a tree decomposition of G of width at most 5 • z(r, t) + 4 ≤ f 3 (t) • r, then we report this and we are done.If the output is a report that tw(G) > z(r, t), then we run Algorithm Find_Low_TW_compass(G, r, t, L) for L = ∅.This may provide either a report that K t is a minor of G, or a set A ⊆ V (G), where |A| ≤ f 2 (t), a flatness pair (W, R) of G \ A of height f 2 (t) that can be made regular by Theorem 6, and a tree decomposition of the R-compass of W of width at most 5 • z(r, t) + 4 ≤ f 3 (t) • r, and these are the possible outputs of the claimed algorithm.Finding a homogeneous flatness pair inside a flatness pair has a price which is determined by the following lemma.Lemma 14.There is a function f 5 : N 2 → N, whose images are odd integers, such that for every w ∈ N ≥1 and every odd integer r ≥ 3, if G is a graph, (W, R) is a flatness pair of G of height f 5 (r, w), and ζ is a flap-coloring of (W, R) with w colors, then W contains some subwall W of height r such that every W -tilt of (W, R) is ζ-homogeneous.Moreover, f 5 (r, w) = O(r w ).

Homogeneous walls
Proof.Let w ∈ N and an odd integer r ≥ 3. We define the function f 5 : N 2 → N so that, for every x ∈ N, f 5 (x, 1) = x while, for y ≥ 2, we set f 5 (x, y) = x • (f 5 (x, y − 1) − 1) + 1.Notice that if x is odd, then f 5 (x, y) is also odd for every y ∈ N ≥1 .
Let G be a graph, (W, R) be a flatness pair of G of height f 5 (r, w), and ζ be a flap-coloring of (W, R) with w colors.We prove the lemma by induction on w.Clearly, if w = 1, then the lemma holds trivially as, in this case, for every brick B of W, ζ-palette(B) = {1}, and therefore as W is a subwall of itself, every W -tilt of (W, R) is a flatness pair of G of height f 5 (r, 1) = r that is ζ-homogeneous.
Suppose now that w ≥ 2 and that the lemma holds for smaller values of w.We set q = f 5 (r, w − 1).We define the subwall W of W by taking the union of the i-th horizontal and the i-th vertical paths of W for all i ∈ {j • (q − 1) The third property in the definition of a tilt of a flatness pair implies that for every internal brick B of W there is an internal brick Otherwise, let B be some brick of W such that |ζ-palette( B)| < w.Notice that B is the perimeter of a subwall W of W of height q.From the induction hypothesis applied to W , we have that W has a subwall W (that is a subwall of W as well) such that every W -tilt of (W, R) is a flatness pair of G of height r that is ζ-homogeneous.The lemma follows by observing that f 5 (r, w) = O(r w ).
We now prove the main result of this subsection.

Lemma 15.
There is an algorithm that receives as input w ∈ N ≥1 , an odd integer r ≥ 3, a graph G, a flatness pair (W, R) of G of height f 5 (r, w), and a flap-coloring ζ of (W, R) with w colors, and outputs a ζ-homogeneous flatness pair ( W , Ȓ) of G of height r that is a W -tilt of (W, R) for some subwall W of W. This algorithm runs in time 2 O(wr log r) • (n + m).
Proof.Let W be the collection of all r-subwalls of W. Clearly |W| = f 5 (r,w) r 2 = 2 O(wr log r) .For each W ∈ W, we call the algorithm of Theorem 5 on G, (W, R), and W , which outputs, a W -tilt ( W , R ) of (W, R).This algorithm runs in O(n + m) time.Then, for every W ∈ W, we check whether ( W , R ) is ζ-homogeneous by computing the ζ-palette( B) for every internal brick B of W .This is done in linear time.Lemma 14 guarantees that since the height of (W, R) is f 5 (r, w), W contains a subwall W of height r such that every W -tilt of (W, R) is ζ-homogeneous.Therefore, the above procedure will detect a flatness pair ( W , R ) of G that is ζ-homogeneous and has height r, which we return.

Levelings and well-aligned flatness pairs
Let G be a graph and let (W, R) be a flatness pair of G. Let also R = (X, Y, P, C, Γ, σ, π), where (Γ, σ, π) is an Ω-rendition of G[Y ] and Γ = (U, N ) is a ∆-painting.The ground set of W in R is ground R (W ) := π(N (Γ)) and we refer to the vertices of this set as the ground vertices of the R-compass of W in G. Notice that ground R (W ) may contain vertices of compass R (W ) that are not necessarily vertices of W. For instance, in Figure 3, all the ground vertices of the R -compass of W are vertices of W , while in Figure 5, there are ground vertices of the R-compass of W that are not vertices of W. We define the R-leveling of W in G, denoted by W R , as the bipartite graph where one part is the ground set of W in R, the other part is a set vflaps R (W ) = {v F | F ∈ flaps R (W )} containing one new vertex v F for each flap F of W in R, and, given a pair (x, F ) ∈ ground R (W ) × flaps R (W ), the set {x, v F } is an edge of W R if and only if x ∈ ∂F.We call the vertices of ground R (W ) (resp.vflaps R (W )) ground-vertices (resp.flap-vertices) of W R .Notice that the incidence graph of the plane hypergraph (N (Γ), {c | c ∈ C(Γ)}) is isomorphic to W R via an isomorphism that extends π and, moreover, bijectively corresponds cells to flap-vertices.This permits us to treat W R as a ∆-embedded graph where bd(∆) ∩ W R is the set X ∩ Y.As an example, see Figure 6 for the R -leveling of the flat 5-wall W of Figure 3.
We denote by W • the graph obtained from W if we subdivide once every edge of W that is short in compass R (W ).The graph W • is a "slightly richer variant" of W that is necessary for our definitions and proofs, namely to be able to associate every flap-vertex of an appropriate subgraph of W R (that we will denote by R W ) with a non-empty path of W • , as we proceed to formalize.We say that (W, R) is well-aligned if the following holds: W R contains as a subgraph an r-wall R W where D(R W ) = D(W R ) and W • is isomorphic to some subdivision of R W via an isomorphism that maps each ground vertex to itself.Suppose now that the flatness pair (W, R) is well-aligned.We call the wall R W in the above condition a representation of W in W R .
As an example, notice that the flatness pair ( W , R ) of Figure 3 is well-aligned while the flatness pair (W, R) in Figure 5 is not since, for example, in the uppermost rightmost grey cell, the upper right ground vertex can not be mapped to itself in order to yield a subgraph R W of W R as in the above property.
Lemma 16.If a flatness pair (W, R) is regular, then it is also well-aligned.Moreover, there is an O(n) time algorithm that, given G and such a (W, R), outputs a representation R W of W in W R .
Proof.Let (W, R) be a flatness pair where all cells of R are tidy and with no W -external or W -marginal cells.We claim that none of the cells of R is W -outer-perimetric. Indeed, a W -outerperimetric c should correspond to one of the tree last cases of Figure 9 (this figure appears later in Subsection 4.2 in order to illustrate further definitions): in the fifth case c is untidy and in the sixth and seventh case c is W -marginal.Therefore all cells are either W -internal or W -inner-perimetric and are also all tidy.
We also denote R = (X, Y, P, C, Γ, σ, π).Recall that W • (whose edges are depicted in orange in Figure 7) is the graph obtained from W if we subdivide once every short edge in W. Let ξ be the function mapping every vertex created by a subdivision of a short edge of W • (depicted by a cross in Figure 7) to the corresponding (trivial) flap-vertex of W R (that is depicted as one of the blue vertices of degree two). Consider and F is a non-trivial flap}.
In Figure 7, the vertices in B are depicted in red in Figure 7 while the vertices in F 1 ∪ F 1 are depicted in blue.We define E as follows.For every v F ∈ F 1 we include in E both edges of W R that incident to v F .For every v F ∈ F 2 such that F \ ∂F contains a 3-branch vertex of W we include in E the three edges of W R that incident to v F .Finally, for every v F ∈ F 2 such that F \ ∂F does not contain any 3-branch vertex of W we first consider the non-trivial path P F in W ∩ F and we add in E the edges of W R between the flap-vertex v F and the endpoints of P F .Notice that since σ −1 (F ) is tidy, P F does not contain internal vertices in ∂F.Observe that R W is indeed a wall of W R , where D(W R ) = D(R W ), that can be computed in O(n) time.We now define a mapping ρ : ) and a function τ mapping the edges in E(R W ) (depicted as fat purple edges in Figure 7) to subpaths of W • as follows: • If v F ∈ F 2 and v F is a branch vertex of R W , then assume first that ∂F = {x, y, z}.Because the cell σ −1 (F ) is tidy the graph F \∂F contains a unique 3-branch vertex w of W (or equivalently of W • ) and F ∩ W • consists of three internally disjoint paths P w,x , P w,y , and P w,z in F from w to x, y, and z, respectively.We set ρ(v F ) = w, τ ({x, v F }) = P w,x , τ ({y, v F }) = P w,y , and τ ({z, v F }) = P w,z .
• If v F ∈ F 2 and v F is not a 3-branch vertex of R W , then there exist two vertices x, y of R W such that N R W (v F ) = {x, y}.Pick an internal vertex w of the (x, y)-path P F and set ρ(v F ) = w (recall that, as σ −1 (F ) is tidy, none of the internal vertices of the path P F is a ground vertex).If P w,x is the (w, x)-subpath of P F , and P w,y is the (w, y)-subpath of P F , then set τ ({x, v F }) = P w,x and τ ({y, v F }) = P w,y .
It is now easy to verify that the mappings ρ and τ defined above certify that W • is isomorphic to a subdivision of R W by an isomorphism extending ρ (see Figure 7 for an example).As all members of B = W ∩ ground R (W ) are, by definition, fixed points of ρ, then (W, R) is well-aligned.

Proofs of Theorem 5 and Theorem 6
This section is devoted to the proofs of Theorem 5 and Theorem 6.We first present some definitions in Subsection 4.1 and Subsection 4.2, necessary for the proof of the main technical lemma of this paper, namely Lemma 17, presented in Subsection 4.3.

Stretchings
Let F be a graph and x and y be two distinct vertices belonging to the same connected component of F. We say that a sequence F 1 , . . ., F r of subgraphs of F is a stretching of F along the pair (x, y) if there is a shortest (x, y)-path P F in F such that the sequence F 1 , . . ., F r consists of the (unique) minimum-sized collection of subpaths of P F with the following properties: • each path in F 1 , . . ., F r is a path where all internal vertices have degree two in F, • no two paths in F 1 , . . ., F r have a common edge, • • for every (i, j) ∈ [r]  2 , F i ∩ F j = ∅ if and only if |i − j| = 1, and For an example of a streching of a graph F along a pair (x, y), see Figure 8.

Classifying perimetric cells
Let G be a graph and let (W, R) be a flatness pair of G, where R = (X, Y, P, C, Γ, σ, π).Let W ∈ S R (W ).We now further refine the classification of the cells of R that we gave in Subsection 2.3 with respect to W . See Figure 9 for an illustration of the ways a W -perimetric cell c of Γ may intersect ∆ W .The simplest case if when |c| = 2, depicted in the leftmost configuration of the figure.The remaining configurations correspond to the case where ∂σ(c) = {x, y, z} where A c is a (π −1 (x), π −1 (y))-arc (see Subsection 2.3 for the definition of the paths P in c and P out c , the arc A c , and the vertex z).The second/fifth, third/sixth, and forth/seventh configurations correspond to the case where z is an internal vertex of P in c , P out c , or none of them, respectively.This permits a further classification of the W -perimetric cells of Γ as follows.A cell c of Γ is W -inner-perimetric (resp.W -outer-perimetric) if c ∩ ∆ W is situated in c as indicated in the left (resp.right) part of Figure 9.We denote the set of cells of Γ that are W -inner-perimetric, W -outer-perimetric, W -internal, and W -strictly external by C ip W (Γ), C op W (Γ), C in W (Γ), and C ex W (Γ), respectively.See Figure 10 for an example of this further classification (relatively to Figure 5).Notice that all W -marginal cells of Γ are W -outer-perimetric cells (corresponding to the last two cases of Figure 9).Figure 10: A flat wall W in a graph G, the painting of a rendition R certifying its flatness, a subwall W of W, of height three, which is R-normal, and the R-flaps of W, corresponding to the cells of R that are not W -external.The edges and the non-boundary vertices of the flaps corresponding to the W -external cells of R (depicted in pink) are not depicted (however their boundary vertices that are not in D(W ) are depicted in grey).There are nine W -outer-perimetric cells of R (in blue) and seven W -inner-perimetric cells (in yellow).Also, there are thirteen W -internal cells of R (in green).Among the W -inner-perimetric and W -internal cells of R, those that are untidy are depicted with a dashed boundary.The orange cycle is the circle K W .

The main lemma
Lemma 17.There is an algorithm that, given a graph G, a flatness pair (W, R), where R = (X, Y, P, C, Γ, σ, π), and a wall W ∈ S R (W ), outputs, in O(n + m) time, a flatness pair ( W , R ) where R = (X , Y , P , C , Γ , σ , π ) such that 1. all cells of R are W -internal or W -inner-perimetric, 2. W is a tilt of W , , the set of W -internal cells of R is the same as the set of Winternal cells of R and their images via σ and σ are also the same, and Moreover, if all W -internal or W -inner-perimetric cells of R are tidy, then the flatness pair ( W , R ) is regular.
We define a series of ingredients that will permit us to define an alternative 7-tuple R .As a first step, for every W -inner-perimetric cell c ∈ C ip W (Γ) we define an arc Y c of ∆, as in Figure 11 (where Y c is depicted in red), we set F c 1 = σ(c), r c = 1, and mid are depicted in orange in Figure 11).Next, we consider a W -outer-perimetric cell c ∈ C op W (Γ). We assume that π(c) = {x, y, z} and that x and y are the two endpoints of the non-trivial path of D(W ) ∩ σ(c) (by non-trivial we refer to the path that has distinct endpoints).We also define V c W as the set of all internal endpoints of this path that are different from z.Let F c 1 , . . ., F c rc be the stretching of σ(c) along the pair (x, y) and let v i , for i ∈ [r c − 1], be the common endpoint of F c i and F c i+1 .Notice that by tightness property (i), r c ≥ 2. This permits us to set up a special vertex v c = v 1 .We also set • for every (i, j) ∈ [rc]  2 , ci ∩ cj = ∅ if and only if |i − j| = 1.
We define the cell replacement of c as the set c-repl(c) = {c 1 , . . ., c rc }, the point replacement of c as the set p-repl(c) = {p 0 , . . ., p rc }, and we set C c new = c-repl(c) and N c new = p-repl(c).We also define the arc Y c as an arc of c where p i ∈ Y c , i ∈ [0, r c ], such that p 0 , p rc are the extreme points of Y c , and Y c is traversing c as depicted by the red line in Figure 12.Observe that We set We now define the wall W = (W \ V W ) ∪ H, i.e., we extract from W the internal vertices of the subpaths of W that are intersected by images, via σ, of W -outer-perimetric cells and we substitute them by the paths of their stretchings.Clearly this does not affect the interior of W , and therefore W is a tilt of W , yielding Property 2 of the statement of the lemma.Next we define a separation (X , Y ) of G so that In other words, Y consists of the images of the internal cells and the vertices of every path F c i , while X consists of everything else, except from V mid (that is, the set X ∩ Y ).Notice that We define the pair (P , C ) as follows.Let c be a W -outer-perimetric cell and σ(c) ∩ V (D(W )) contain a vertex w such that either w is a 3-branch vertex of W or w ∈ P (resp.w ∈ C).We distinguish two cases.If w ∈ Y , then we include w in P (resp.C ).If w ∈ Y , then we include the special vertex v c in P (resp.C ).
We .In this case we define π (p) to be the unique common vertex of F c * i and F c * i+1 .It is now easy to verify that (Γ , σ , π ) is a tight Ω -rendition of G[Y ] and that the 7-tuple R := (X , Y , P , C , Γ , σ , π ) certifies that W is flat in G (see Figure 13).Moreover K = C(Γ ).Recall now that all the cells in C(Γ ) ∩ C(Γ) are either W -inner-perimetric or W -internal.Moreover, all the cells in C(Γ ) \ C(Γ) are cells as in the left part of Figure 9, therefore they are W -inner-perimetric.This yields Property 1 in the statement of the lemma.Notice also that Property 3 follows directly from the definition of σ , as it concerns the W -internal cells of R, and these cells are the same as the W -internal cells of R .Finally, recall that compass R ( W ) = G[Y ] and Property 4 follows because of (1).
On the other hand, notice that all W -internal cells of R are also W -internal cells of R.Moreover, if a W -inner-perimetric cell c of R is a cell of R, then c is either an W -inner-perimetric or an W -internal cell of R. On the other hand, all W -inner perimetric cells of R that are not cells of R are cells as in the left part of Figure 9, therefore they are W -inner-perimetric and tidy.We conclude that if all W -internal or W -inner-perimetric cells of R are tidy, then all cells of R are tidy as well.As R does not have any W -outer-perimetric cells it also does not have W -marginal cells.These two facts along with the fact that R does not have any W -external cells imply that of W and is incident to only one edge of σ(c) ∩ W, while, in the second case, z is not anymore a vertex of W. This implies that c is not anymore untidy and |C utd W (Γ)| is indeed reduced by one (see Figure 14 for an example).As for each cell c that we modify we need to identify the paths P x , P y , and P z in σ(c), the construction of W takes, in total, O(n + m) time.

Proofs of Theorem 5 and Theorem 6
We finally have all the ingredients to prove our two main results.
Proof of Theorem 5. Let (W, R) be a flatness pair of a graph G, where R = (X, Y, P, C, Γ, σ, π) and W ∈ S R (W ).We call the algorithm of Lemma 17 on G, (W, R), and W , which outputs, in O(n + m) time, a flatness pair ( W , R ) where R = (X , Y , P , C , Γ , σ , π ) such that all cells of R are W -internal or W -inner-perimetric (hence R does not have W -external cells), W is a tilt of W , the set of W -internal cells of R is the same as the set of W -internal cells of R and their images via σ and σ are also the same, and compass R ( W ) is a subgraph of influence R (W ).We observe that ( W , R ) is a W -tilt of (W, R) and thus we return ( W , R ).Notice that in the case where (W, R) is regular, all cells of R are tidy.Thus, by Lemma 17, ( W , R ) is also regular.
Proof of Theorem 6.Given a flatness pair (W, R) of a graph G, we first apply Lemma 18 to (W, R) and obtain in time O(n + m) a flatness pair ( Ŵ , R ) of G with the same height as (W, R), with R = R, and such that all Ŵ -internal or Ŵ -inner-perimetric cells of R are tidy.
We now apply Lemma 17 with input G, ( Ŵ , R ), and Ŵ and obtain, in O(n + m) time, a flatness pair (W , R ) of G such that, if R = ( X, Ŷ , P , Ĉ, Γ, σ, π) and R = (X, Y, P, C, Γ, σ, π), we have that all cells of R are W -internal or W -inner-perimetric (hence R does not have Wexternal cells), W is a tilt of Ŵ , the set of W -internal cells of Ŵ is the same as the set of Ŵ -internal cells of R and their images via σ and σ are also the same, and compass R (W ) is a subgraph of influence R ( Ŵ ).Moreover, since all the Ŵ -internal or Ŵ -inner-perimetric cells of R are tidy, Lemma 17 implies that all (W -internal or W -inner-perimetric) cells of R are tidy.Also, since none of the cells of R is W -outer-perimetric, none of the cells of R is W -marginal.These two facts together with the fact that none of the cells of R is W -external imply that (W , R ) is a regular flatness pair of G with the same height as (W, R), as required.
Finally, the claimed running time follows from Lemma 17 and Lemma 18.

Figure 1 :
Figure 1: A 15-wall.The 3-branch vertices are depicted in cyan except from the corner and the central vertices that are depicted in red and orange respectively.

Figure 2 :Lemma 3 .
Figure 2: A graph G together with an Ω-rendition of G, where all tightness conditions are violated.

Figure 4 :
Figure 4: The painting of the rendition R certifying the flatness of the 5-wall W of Figure 3.The R -compass of W has two types of flaps: those whose base has three vertices (they are images of the blue cells) and those that are trivial (they are images of the purple cells).
Notice that the cells of R are partitioned into C-internal, C-perimetric, and C-external cells.Let c be a tidy C-perimetric cell of R where |c| = 3.Notice that c\A c has two arcwise-connected components and one of them is an open disk D c that is a subset of ∆ C .If the closure D c of D c contains only two points of c then we call the cell c C-marginal.Influence.For every R-normal cycle C of compass R (W ) we define the set influence R (C) = {σ(c) | c is a cell of R that is not C-external}.

Figure 5 :
Figure 5: A flat wall W in a graph G, the painting of a rendition R certifying its flatness, a subwall W of W, of height three, which is R-normal, and the R-flaps of W, that correspond to either W -perimetric (depicted in grey) or W -internal cells (depicted in green).The circle K W is the fat orange cycle.The W -marginal cells are depicted in light grey and the untidy cells are those with dashed boundary.

Theorem 5 .Theorem 6 .
There exists an algorithm that given a graph G, a flatness pair (W, R) of G, and a wall W ∈ S R (W ), outputs a W -tilt of (W, R) in O(n + m) time.There is an algorithm that, given a graph G and a flatness pair (W, R) of G, outputs a regular flatness pair (W , R ) of G, with the same height as (W, R) such that compass R (W ) ⊆ compass R (W ).This algorithm runs in O(n + m) time.
Palettes and homogeneity.Let w ∈ N, let G be a graph, and let (W, R) be a flatness pair of G.A flap-coloring of (W, R) with w colors is any function ζ : flaps R (W ) → [w].For every Rnormal cycle C of compass R (W ), we define ζ-palette(C) = {ζ(F ) | F ∈ influence R (C)}.We say that the flatness pair (W, R) of G is ζ-homogeneous if every internal brick of W (seen as a cycle of compass R (W )) has the same ζ-palette.

Figure 6 :
Figure 6: The R -leveling of the flat 5-wall W of Figure 3.

Figure 7 :
Figure 7: A well-aligned flatness pair (W, R) where W is a 3-wall, the wall W • (whose edges are depicted in red and the new subdivision vertices are depicted by small crosses), the leveling W R of W (whose edges are depicted in purple), and the subgraph R W of W R (depicted by fat purple edges).

Figure 8 :
Figure 8: The stretching of a graph F along the pair (x, y).

Figure 9 :
Figure 9: Seven ways ∆ W may traverse a cell.The arc A c is depicted in orange.

Figure 11 :
Figure 11: The four cases of the definition of the arc Y c (depicted in red), for W -inner-perimetric cells.The boundary of ∆ W is depicted in orange and the boundary of ∆ is depicted in purple.
and create a collection c 1 , . . ., c rc of open disks in c and a set p 1 , . . ., p rc−1 of points in c such that • p 0 ∈ bd(c 1 ) and p rc ∈ bd(c rc ), p 0 = p 1 , and p rc = p rc−1 ,

Figure 12 :
Figure 12: The definition of the replacement sequence c 1 , . . ., c rc and the arc Y c for the three cases of W -external cells of C op W (Γ).
next define an Ω -rendition (Γ , σ , π ) of G[Y ]  where Γ = (U , N ) is a ∆ -painting.For this we set Γ = (U , N ), whereU = U \ C op W (Γ) ∩ ∆ ∪ U new and N = (N ∩ ∆ ) ∪ N new .Let now K be the set of the connected components of U \ N , which will form the cells of the new Ω -rendition (Γ , σ , π ).We define the function σ mapping the cells inC to subgraphs of G[Y ] as follows.Notice that c ∈ K ∩ C(Γ) if and only if c ∈ C in W (Γ) ∩ C ip W (Γ),and in this case we set σ (c) = σ(c).Suppose now that c ∈ K \ C(Γ).Then c should be one of the cells, say c i , of c-repl(c * ) = {c 1 , . . ., c rc } for some c * ∈ C op W (Γ), and in this case we set σ(c) = F c * i .It now remains to define π : N → Y .Similarly to the definition of σ , we consider a p ∈ N and if p ∈ N ∩ N we set π (p) = π(p).Suppose now that p ∈ N \ N. Then p should be one of the points, say p i , of p-repl(c * ) = {p 0 , . . ., p rc } for some c * ∈ C op W (Γ) and such that i ∈ [r c * − 1]

Figure 13 :
Figure 13: The flatness pair ( W , R ) created in the proof of Lemma 17.The wall W is the tilt of W where the updated part of W correspond to the red paths in Figure 10 whose edges are drawn in the orange cells.