# Detecting and Counting Small Patterns in Planar Graphs in Subexponential Parameterized Time

We present an algorithm that takes as input an n-vertex planar graph G and a k-vertex pattern graph P, and computes the number of (induced) copies of P in G in 2^O(k/ k)n^O(1) time. If P is a matching, independent set, or connected bounded maximum degree graph, the runtime reduces to 2^Õ(√(k))n^O(1). While our algorithm counts all copies of P, it also improves the fastest algorithms that only detect copies of P. Before our work, no 2^O(k/ k)n^O(1) time algorithms for detecting unrestricted patterns P were known, and by a result of Bodlaender et al. [ICALP 2016] a 2^o(k/ k)n^O(1) time algorithm would violate the Exponential Time Hypothesis (ETH). Furthermore, it was only known how to detect copies of a fixed connected bounded maximum degree pattern P in 2^Õ(√(k))n^O(1) time probabilistically. For counting problems, it was a repeatedly asked open question whether 2^o(k)n^O(1) time algorithms exist that count even special patterns such as independent sets, matchings and paths in planar graphs. The above results resolve this question in a strong sense by giving algorithms for counting versions of problems with running times equal to the ETH lower bounds for their decision versions. Generally speaking, our algorithm counts copies of P in time proportional to its number of non-isomorphic separations of order Õ(√(k)). The algorithm introduces a new recursive approach to construct families of balanced cycle separators in planar graphs that have limited overlap inspired by methods from Fomin et al. [FOCS 2016], a new `efficient' inclusion-exclusion based argument and uses methods from Bodlaender et al. [ICALP 2016].

## Authors

• 19 publications
10/06/2021

### Tight bounds for counting colorings and connected edge sets parameterized by cutwidth

We study the fine-grained complexity of counting the number of colorings...
01/11/2022

### Partial Vertex Cover on Graphs of Bounded Degeneracy

In the Partial Vertex Cover (PVC) problem, we are given an n-vertex grap...
01/26/2021

### A Tight Lower Bound for Edge-Disjoint Paths on Planar DAGs

(see paper for full abstract) We show that the Edge-Disjoint Paths pro...
05/05/2018

### On exploiting degeneracy to count subgraphs

Motivated by practical applications, we study the complexity of counting...
11/11/2020

### Counting Homomorphic Cycles in Degenerate Graphs

Since computing most variants of the subgraph counting problem in genera...
10/01/2020

### Counting 4-Patterns in Permutations Is Equivalent to Counting 4-Cycles in Graphs

Permutation σ appears in permutation π if there exists a subsequence of ...
11/04/2019

### Counting Small Permutation Patterns

A sample of n generic points in the xy-plane defines a permutation that ...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

The complexity of NP-hard problems on planar graphs has been a popular subject for a at least two decades, and its fruitful study resulted in seminal results such as the planar separator theorem by Lipton and Tarjan [LT79] and efficient approximation schemes by Baker [Bak94]. An area in which planar graphs are especially a popular subject of study is Parameterized Complexity. A cornerstone result of parameterized complexity111Quoting its laudatio for the Myhil-Nerode prize [EGT]. by Fomin et al. [DFHT05] shows that many NP-hard parameterized problems on planar graphs can be solved in subexponential time, i.e. time where is , is some (typically small) problem parameter, and denotes the number of vertices of . Typically is only in this setting. Thanks to the technique of [DFHT05] and a large body of follow-up work (see e.g. [EKMM16]), the fine-grained parameterized complexity of many decision problems on planar graphs is by now well understood.

The technique from [DFHT05], called bidimensionality, is a win-win argument based on the grid minor theorem. The technique exploits that instances of the problem at hand defined by graphs with high treewidth are always YES/NO-instances.222See Section 2 for the definition of treewidth and [CFK15, Section 7.7] for more discussion. For example, one can detect whether a planar graph has a simple path on at least vertices (called -path) in time time in this way: If has treewidth , it has a -grid as a minor that can be used to show has a -path. Otherwise, has treewidth and dynamic programming can be used to detect -paths in time. While the bidimensionality technique is applicable to many problems, it requires that the solution of the instance can be deduced already from the fact that the graph has large treewidth. This is a rather fragile assumption that often can not be made, and indeed for several important problems the approach turned out inadequate.

#### Subgraph Isomorphism

on planar graphs is a basic NP-complete problem where the bidimensionality technique falls short perhaps most pressingly. In the subgraph isomorphism problem we are given an -vertex planar graph and a -vertex planar graph and we need to determine whether there exists an (induced) copy of in . As mentioned above, bidimensionality does solve this problem in if is a path on vertices, but if we slightly alter the pattern to, say, a cycle on vertices or a directed path333The subgraph isomorphism problem can be extended to directed graphs in a natural way. the technique already breaks down.

Detecting such cycles patterns and directed paths turns out more complicated. It was observed by Tazari [Taz12] and Dorn et al. [DFL13] that variants of the layering technique by Baker [Bak94] can be used to design algorithms for detecting such patterns with running time . Recently it was shown how to detect such patterns probabilistically in time by Fomin et al. [FLM16]. The following question suggests itself:

###### Question 1.

Is there a time deterministic algorithm for Subgraph Isomorphism for the special case where the pattern is either a cycle or a directed path on vertices?

The general planar subgraph isomorphism problem with unrestricted patterns also been the subject of several interesting works. Eppstein [Epp99] was the first to show that the problem is Fixed Parameter Tractable by giving an time algorithm, and Dorn [Dor10] improved this to an time algorithm. Afterwards Bodlaender et al. [BNvdZ16] showed the problem can be solved in time, and any time would contradict the exponential time hypothesis.

By combining the techniques of Bodlaender et al. [BNvdZ16] and Fomin et al. [FLM16], one can obtain a time probabilistic algorithm that detects any fixed pattern with at most connected components. However, this still does not settle the complexity of the general problem, and the following question (also mentioned in [FLM16] and [BNvdZ16]) remained open:

###### Question 2.

Is there a time (deterministic) algorithm for general Subgraph Isomorphism with unrestricted pattern?

Note that such an algorithm can not be improved under the ETH by the lower bound lower bound from [BNvdZ16] since in any non-trivial instance.

#### Counting Problems

are perhaps the largest category of problems for which bidimensionality is not applicable. Counting problems on restricted graphs classes are well-motivated from (among others) seemingly distant areas such as statistical physics, and Counting problems on planar graphs are well-studied in terms of polynomial time approximation schemes (see e.g Goldberg [GJM15]), and several works showed that the study of approximation schemes and parameterized complexity of counting problems is intertwined: Both the methods from Yin [YZ13] and Patel and Regts [PR17b] give polynomial time approximation schemes that rely on completely unrelated fixed parameter tractable algorithms.

On the other hand, the number of purely parameterized complexity theoretical works on counting problems can be counted on one hand. For example, Frick [Fri04] gave a fixed parameter tractable algorithm for a general class of fixed order logic problems, and Curticapean [Cur16] showed it is fixed parameter tractable to count matchings with few unmatched vertices in planar graphs.

#### Counting Subgraph Isomorphisms

is a very natural extension of subgraph isomorphism with close connections to partition functions [PR17b] and motif discovery (see e.g. [MSOI02] or the discussion in [CDM17]). The aforementioned algorithm of Dorn [Dor10] also counts the number of copies of the given pattern, so patterns like independent sets, matchings and paths on vertices can be counted in time. Yet, this does not match the typical running time that can be obtained for most decision problems via the bidimensionality technique and cannot be improved under the ETH by standard reductions. Therefore the following natural question was repeatedly asked by several researchers:444For example, it was posed as open problem in a Dagstuhl report by Marx in [CFHW17], and talks by Fomin https://ims.nus.edu.sg/events/2017/asp/files/fedor.pdf and Saurabh https://rapctelaviv.weebly.com/uploads/1/0/5/3/105379375/future.pdf.

###### Question 3.

Is there a time algorithm for counting (induced) copies of a pattern , where is a path, matching, set of disjoint triangles or independent set555Naturally, if is an independent set, only counting induced copies of is interesting.?

We would like to stress that even for the special case of counting independent sets on vertices in subgraphs of grids it is unclear how to obtain an algorithm with running time without using our techniques. Note that this specific counting problems on subgraphs of grids received attention already in the enumerative combinatorics community (see [CW98, Kas61]).

### 1.1 Our Results

We resolve the complexity of the decision and counting variants of Subgraph Isomorphism on planar graphs, and answer the above Questions 1, 2 and 3 affirmatively in a strong sense.

We now state our main result for counting subgraph isomorphisms. Formally, if and are undirected graphs, we denote for the set of injective functions such that for every . Similarly, we denote for the set of injective functions such that if and only if , for every distinct . The running time of our algorithm depends on a pattern-specific parameter that we define below.

###### Theorem 1.1 (Main Theorem).

There is an algorithm that takes as input a -vertex graph and an -vertex planar graph , and outputs and in time.

We can also count the number of vertex subsets inducing the sought copies by dividing or . The parameter is the number of non-isomorphic separations of of order . Formally speaking, a separation of is a pair of vertex subsets such that and there are no edges in between vertices from and , and the order of is . Separations and are isomorphic if there is an isomorphism of such that , and for every .

This factor in our running time is a direct consequence of reverse-engineering the technique of Bodlaender et al [BNvdZ16]. In fact, it follows from the analysis of [BNvdZ16] that is for any pattern (we spell this out in Lemma 2.4). Thus, we obtain the following consequence of Theorem 1.1 that answers Question 2 positively:

###### Corollary 1.2.

There is an algorithm that takes as input an -vertex graph , and an -vertex planar graph and outputs and in time.

Recall that Bodlaender et al. showed that a

time algorithm contradicts ETH, and thus our algorithm can probably not be improved significantly easily.

We continue our discussion with specific choices for the pattern . If is a matching, set of disjoint triangles, independent set or any connected graph with bounded maximum degree on vertices, it can be shown666See Lemma 2.3 that is at most . Thus, Theorem 1.1 resolves Question 3 in the following sense:

###### Corollary 1.3.

Let be a matching, set of disjoint triangles, independent set or any connected graph with bounded maximum degree on vertices. Then there is an algorithm that takes as input an -vertex planar graph and outputs and in time.

It is folklore knowledge that, assuming ETH, there is no time algorithm that decides whether when is a set of triangles or a path, or whether when is a matching, set of disjoint triangles or independent set or path. Thus, our result resolves the running time of the fastest pattern counting algorithm assuming ETH for all listed pattern classes.

The algorithm for detecting a connected pattern with bounded maximum degree from Corollary 1.3 can be combined with a simple gadget777Replace each arc in the host/pattern graph with new vertices and edges . to obtain the following result that resolves Question 1.

###### Corollary 1.4.

There is an time deterministic algorithm that detects (and in fact, even counts) the number of simple directed cycles or paths on vertices in an -vertex directed planar graph.

Finally, we would like to mention that, via standard techniques, our algorithms can also be used to obtain uniform samples from the set and in similar running times. Such questions were also studied for being a path on vertices and being planar by Montanari [MP15].

### 1.2 Previous Related Work

A seminal paper by Alon et al. [AYZ95] gave a time algorithm for subgraph isomorphism in general graphs. For the counting extension, Flum and Grohe showed there is no time algorithm that counts occurrences of in even in the special case that is a path on vertices.

On the other hand Patel and Regts [PR17a] gave an algorithm that counts the number of induced copies of in time . Curticapean et al. [CDM17] gave an algorithm that counts the number of copies of in in time. See also a survey by Curticapean [Cur18] on counting and parameterized complexity.

The special case of (and thus, also ) being planar was studied first by Eppstein [Epp99]. His approach was to follow the layering technique of Baker [Bak94]. Briefly speaking, this is to partition the vertex set into parts such that for every , the graph has treewidth . Then one can try to count all occurrences of by summing over all , and count all occurrences of in using dynamic programming on the treedecomposition. However, this overcounts occurrences of that are disjoint from more than one part. To avoid this overcounting, we use additional table indices to keep track of whether vertices from some part where included, and only count pattern occurrences where some fixed part is disjoint from the pattern occurrence, but where all with intersect with the pattern occurrence. In this way Eppstein obtained an algorithm that counts the number of occurrences of in time. Dorn [Dor10] later sharpened the running time to by exploiting planarity in the dynamic programming subroutine.

Bodlaender et al. [BNvdZ16] settled the complexity of subgraph isomorphism with large patterns in a curious way: They showed that occurrences of can be detected in time, and that any time algorithm would contradict ETH. Their algorithm builds on a natural dynamic programming algorithm that is indexed by separations of order , but exploits that many table entries computed by this algorithm will be equal whenever the associated separations are isomorphic. The curious running time follows from an upper bound on the number of non-isomorphic separations of order .

Fomin et al. [FLM16] provided a new robust tool: given a planar graph888The result of Fomin et al. [FLM16] applies to the more general class of apex-minor free graphs, but we restrict our discussion to planar graphs. and an integer , they sample a subset such that and for every such that has connected components it holds that with probability at least . Their technique to achieve this result is a combination of elements of Baker’s approach, an extension of Menger’s theorem and an intricate divide and conquer scheme.

A combination of the techniques from [BNvdZ16] and [FLM16] gave a time randomized algorithm for detecting occurrences of a given connected pattern.

### 1.3 Our Approach

We now briefly describe the high level intuition behind our approach to obtain our main result, Theorem 1.1. As mentioned above, our approach employs aspects of the relatively new works of Fomin et al. [FLM16] and Bodlaender et al. [BNvdZ16], but also uses more classic techniques such as Baker’s partitioning to reduce the treewidth, as already proposed by Eppstein for subgraph isomorphism [Epp99]. We now give a brief outline of our approach, with an emphasis on our main innovations.

#### Detecting Patterns: Sparsifying Balanced Cycle Separators

We follow the approach from [FLM16] that employs a Menger-like lemma (Lemma 2.11) as a crucial ingredient, but we employ this lemma differently. In Algorithms 2 and 3 we will use the a more involved version to prove Lemma’s 4.2 and 4.3.

We start by preprocessing the graph via a standard argument [Bak94, Epp99] to ensure it is -outerplanar. This implies we can find a small balanced cycle separator (after triangulation).

Then we use that for given any balanced (with respect to an unknown weight function) cycle separator , we can construct a family of balanced cycle separators such that at least one cycle of the output family has small intersection with the (unknown) pattern .

To obtain this family, we partition the cycle in four equally-sized consecutive parts , inspired by a proof of the planar grid-minor theorem (following a version of the proof by Grigoriev [Gri11]). Then we consider which either is the interior or the exterior of (depending on which has higher weight, and we can try both if the weight is unknown). Applying Lemma 2.11 in , we either get a family of mutually disjoint -separators (which are -paths) or nearly-disjoint -separators (which are -paths). In either case, we (non-deterministically) guess a path with little intersection with the pattern (which exists as the paths have limited mutual overlap). Now we form two different cycles from . The cycle with smallest weight in its exterior can be shown to be sufficiently balanced. Repeating the procedure times suffices to prove the lemma.

#### Detecting Patterns: Acquiring Balance

If we would apply the above approach recursively in a direct way to obtain a good tree decomposition-like divide and conquer scheme for running a dynamic programming to detect patterns, we quickly would arrive at running times of the type , for problems like directed longest path or longest cycle on vertices. This is already a very strong indication that a running time is within reach, and indeed the following simple additional new idea allows such running time: When given a balanced cycle separator , we first guess whether has at most or at least vertices from the pattern .

If has at most vertices from , there are only possibilities for the image of the mapping of to , and the associated dynamic programming table will be small enough. Thus can be used to decompose the problem into two subproblems with both only a constant fraction of the vertices of . Otherwise, the assertion that has at least pattern vertices can be used to construct another cycle that has vertices from in both its interior and exterior. Then we use as basis for the procedure outlined above to construct a family of cycles that separate at least pattern vertices. Oversimplifying things, the number of recursive calls of a divide and conquer scheme applying this strategy exhaustively in terms of graphs with vertices and patterns with vertices satisfies the following upper bound:

 T(n,k)≤2T(2n/3,k)+quasipoly(k)⋅T(n,k−Ω(√k))=nO(1)(log(n))~O(√k)≤2~O(√k)nO(1),

whether the latter upper bound can be shown by a case distinction on whether .

#### Counting Patterns: Efficient Inclusion-Exclusion

Note it is even not clear how to make the preprocessing step by Eppstein [Epp99] and Baker [Bak94] to make the graph -outerplanar work in the counting setting as the natural extension (sum over all blocks of the partition, remove the block and count the number of pattern occurrences) will over count pattern occurrences. Moreover, extending the dynamic programming table by keeping track of which blocks of the partition vertices have been selected as done in [Dor10, Epp99] increases the number of table entries to .

Instead, we present a new approach based on inclusion-exclusion. Indeed, to avoid over count it is natural to compensate by summing over all subsets of the blocks in the partition and count the number of pattern occurrences exactly using inclusion-exclusion. To avoid summing over all sums in the inclusion-exclusion formula, we make the crucial observation that it’s summands are algebraically dependent in a strong sense. We show that we only need to compute pattern occurrences in subgraphs that are -outer planar, and can evaluate the inclusion-exclusion formula in polynomial time given these values. We call this (to our best knowledge, new999Let us remark that inclusion exclusion was used before for counting problems in planar graphs by Curticapean in [Cur16] to reducing counting non-perfect matchings to non-perfect matchings, but in a very different way.) idea Efficient inclusion-exclusion.

We point out that without this new idea it would even be hard to get very special subcases of our general theorem, such as to count -vertex independent sets in subgraphs of grids in time.

#### Counting Patterns: Combinining all ideas

To prove Theorem 1.1 in its full generality, we combine all above new insights with the isomorphism check as exploited by Bodlaender et al. [BNvdZ16]. But to combine all above steps, still a number of technical hurdles need to be overcome.

First, when the step in which we (non-deterministically) guess a path with little intersection is replaced with summing over all , we will over count. We resolve this in different ways depending on whether the set of paths is completely disjoint or nearly-disjoint. In the first case we can avoid over counting by keeping track of that we need to intersect some paths in the recursion. We implement idea by associating a set of monitors with a recursive call. Specifically, a monitor is a set with two associated integers and . We distinguish ‘small’ monitors (with vertices), and large monitors (with an unbounded number of vertices). Given a set of monitors

in a subproblem, we count, for every vector

such that , the number of occurrences of in on vertex set such that for every . In the second case, we apply the efficient inclusion-exclusion idea (in a slightly more technical, but essentially same, way as we did to reduce the outerplanarity of )

Before we continue with sparsifying a balanced cycle separator, we need to ensure that the subproblem is ‘clean’. Specifically, we need that the number of monitors and the number of ‘boundary vertices’ (i.e. vertices of which we need to track how the pattern maps to them) are . To ensure this, we employ a cleaning step that aims at sparsifying separators that balance the number of vertices in ‘small’ monitors and boundary vertices. After of such steps, there will only of such vertices left.

### Organization

Notation, useful standard tools, and other preliminaries are described in Section 2. In Section 3 we set up main building blocks of Theorem 1.1, which we subsequently prove in Section 4.

## 2 Preliminaries

#### Notation and Basic Definitions

With a triangulated graph we mean a graph with a given embedding in which all faces are of size . Let , , denote for the remainder of , and for being congruent mod . We use and for all subsets of of size at most and respectively equal to . In this paper suppresses factors polynomial in the problem instance size. Let be an undirected graph. Whenever , we let denote . Similarly, if , we let denote the graph . If , we shorthand . If is a set family and we denote . If are sets we denote for all vectors indexed by with values from . We use both the and index notation in this paper, to occasionally avoid subscripts. Given two vectors , we let denote that for every . If , denotes the length of (that is, the number of edges on) the shortest path from to .

If , we denote . If is clear from the context it will be omitted. We use to omit factors, let denote all functions of the type and denote all functions of the type .

#### Functions

Given a function and , we let . We let denote that is injective (that is implies that ). If for a superset , we say extends if for every . In this case we also say is the projection of on . If and , we say and agree if for every . If is a singleton set, we may also interpret it as a single element of . If and are undirected graphs, we denote for the set of injective functions , and for the set of injective functions . A bijection is an isomorphism if if and only if . An automorphism is an isomorphism from a graph to itself. We let denote the set of automorphisms of .

#### Separations and Their Isomorphism Classes

A colored graph if a pair where is a graph and is a coloring function. Two colored graphs and are isomorphic if there exists an isomorphism from to such that for every . It is known that testing whether two colored -vertex planar graphs are isomorphic can be done in time: Using standard techniques (see e.g. [Sch09, Theorem 1]) one can reduce planar colored subgraph isomorphisms to normal planar subgraph isomorphism, which can be solved in planar graphs in polynomial time [HW74]. By the same standard reduction from colored subgraph isomorphism to subgraph isomorphism, and the canonization algorithm for planar subgraph isomorphism by Datta et al. [DLN09], we also have the following:

###### Theorem 2.1.

There exists a polynomial time algorithm that given a colored planar graphs outputs a string such that if and only if is isomorphic to .

A separation of a graph is pair of two subsets with no edges between and in . We say is the separator of this separation and that is the order of this separation. If , we say is below if . Two separations and are isomorphic if and there exists an automorphism such that for every . We let (respectively, ) denote an (arbitrarily fixed) maximal set of pair-wise non-isomorphic separations of below of order at most (respectively, exactly ). We also shorthand , since the input pattern will be fixed throughout this paper, and shorthand and . Define to be the number of separations of below such that .

###### Lemma 2.2.

Given and , we can enumerate and in time. In the same time we can also compute of each separation .

###### Proof.

Iterate over all possibilities for the separator . Subsequently, for each connected component of , create a colored graph on vertex set with colors assigned to the vertices in and a single color to all vertices in . To enumerate and compute , we can iterate over all possibilities of , label each connected component with their canonical string . And compute the number which we define as the number of connected components satisfying , and be the number of connected components with and .

Subsequently, we enumerate over all non-negative vectors such that and . Note that each such uniquely defines gives a non-isomorphic separation in which and contains exactly connected components such that . For each such and , we add the separation to . Moreover, by the above discussion it also follows that , as for every connected component with canonical string we have options to choose the connected components included in from the available connected components. ∎

###### Lemma 2.3.

If is connected and has bounded degree, .

###### Proof.

There are at most possibilities for the set . The graph has at most connected components, and these can be distributed among and in ways. ∎

The following lemma is a direct consequence of the proof from Section 3.3 of [BNvdZ16]:

###### Lemma 2.4.

For any planar , .

#### Planar Graphs

A cycle of a graph is a sequence such that and for every . The cycle is simple if every vertex appears at most once in it. The length of is . If is planar and its embedding in is clear from the context, we let denote the subgraph of consisting of and all edges and vertices enclosed by (the ‘interior of ’), and let denote the subgraph of consisting of and all vertices and edges not enclosed by (the ‘exterior’ of ). The strict interior (exterior) of is the interior (exterior) except , and are denoted with and .

###### Definition 2.5.

For a graph and a vertex in , by we denote the set of vertices of reachable from in . If is not in , should be read as the empty set. If this is extended in the natural way, i.e. . Suppose is a connected graph, and are different vertices of . An -separator is a subset of vertices of such that and . Moreover, is said to be a minimal -separator if no strict subset of is an -separator, and is minimal if it is a minimal -separator for some .

#### Outerplanarity

A planar embedding of a graph is -outerplanar if all its vertices are on the outerface, and it is -outerplanar if after the removal of the vertices on the outerface an -outerplanar embedding remains. A graph is -outerplanar is it admits a -outerplanar embedding. We will need the following facts on outerplanarity:

###### Lemma 2.6 ([Bie15]).

Every -outerplanar graph can be triangulated to a -outerplanar graph.

###### Lemma 2.7 ([Bak94]).

There is an algorithm that given a planar graph and integer , outputs subsets such that is -outerplanar for every and for every there exists an such that .

###### Lemma 2.8 ([Bod98]).

Given a -outerplanar graph , we can construct a treedecomposition of of width in polynomial time.

#### Inclusion Exclusion

If is set family over a universe , then

 |m⋃i=1Ai|=∑∅≠R⊆[m](−1)|R|−1|⋂i∈RAi|. (1)

Note that resembles a set of ‘required sets’.

#### Balanced Separators

A -proper weight assignment is an assignment of weight to vertices summing to with all weights being at most . An -balanced cycle separator for in is a cycle such that the weight of all vertices in the strict interior of is at most and the weight of all vertices in the strict exterior of is at most . If is a set of vertices, we say is balanced for if it is balanced for the weight function that assigns to all vertices of and weight to all other vertices. We use the following lemma:

###### Lemma 2.9 (Folklore (see e.g Lemma 5.3.2. in [Km])).

There is a linear-time algorithm that, given a triangulated graph, spanning tree of , and a -proper assignment to vertices, returns a nontree edge such that the fundamental cycle of with respect to is a -balanced cycle separator for in .

In particular, the lemma implies we can find such separators of size in polynomial time whenever the diameter of is at most or when the graph is -outerplanar and triangulated.

#### A Menger-like Theorem for Nearly Disjoint Paths

###### Definition 2.10.

A sequence of -separators is called an -separator chain if for each , the following holds:

 Si∖Sj⊆reach(s,G−Sj)andSj∖Si⊆reach(t,G−Si).

If is clear from the context, we denote for the private vertices of , and for the public vertices of . If for all we call disjoint.

Somewhat counter-intuitively, for to be a separator chain some connectivity might be required that is not present in the graph, but assuming these connections exist will be notationally convenient as it gives some sense of linear order in the chain. We frequently will be interested in separator chains in graph not having the required connectivity and fix this issue by working with appropriate super graphs, which is allowed as this only filters out some separators.

A crucial tool in our approach the following useful lemma from [FLM16], already designed specifically to find patterns in planar graphs in sub-exponential parameterized time.

###### Lemma 2.11 ([Flm+16]).

There is a polynomial time algorithm that, given a connected graph , a pair of distinct vertices, and integers , outputs one of the following structures in :

1. A chain of -separators with for each ,

2. A sequence of -paths with for each .

#### Crossing Paths

We use some standard definitions and tools for crossing paths in planar graphs:

###### Definition 2.12 ([Cr06]).

A path crosses another path if there exists a bounded connected region in with the following properties: and each cross the boundary of exactly twice and these crossings are interleaved. A set of paths is said to be non-crossing if every pair of paths is distinct and non-crossing.

It is easy to modify a set of paths with common endpoints, into another set of paths in which every edge occurs equally often as in such that is non-crossing in polynomial time. See also [CR06] for more details. A set of non-crossing paths with common endpoints in an embedded graph can be sorted in a natural way: sort all edges in clockwise order, and order the paths lexicographically according to this order. We denote the algorithm that does this for us .

###### Definition 2.13 (Alignment of cycle).

Let be a cycle and be an arbitrary but fixed consecutive ordering of its vertices. Suppose , and let

 C←={v1,…,vi},C↓={vi+1,…,vj},C→={vj+1,…,vk},C↑={vk+1,…,vl}.

Then form an alignment of .

We will use the sorting step to obtain the following consequence of Lemma 2.11.

###### Lemma 2.14.

Let be an inner-triangular graph with outer boundary , and let be an alignment of . Let be obtained by adding vertices adjacent to all vertices for every direction . There is a polynomial time algorithm that, given and integers either finds a chain of

1. disjoint -separators in with for each , or

2. -separators in with for each .

###### Proof.

Apply Lemma 2.11 with as given. If a chain of separators is found we are done immediately. Otherwise, gives a non-crossing ordered set of paths from . As each such a path is a -separator this is also a chain of -separators by the ordering. ∎

#### Tree decompositions and treewidth

A tree decomposition of a graph  is a pair  in which is a tree, and are subsets such that with the following properties: (i) for any , there exists an  such that , (ii) if and , then for all on the (unique) path from to in .

The width  of a tree decomposition is the maximum bag size minus one, and the treewidth of a graph is the minimum treewidth over all nice tree decompositions of .

## 3 Monitors, Subproblems and Helper Reductions

In this section we set up machinery that will be used in Section 4. In Subsection 3.1, we introduce definitions that will facilitate the presentation of the algorithm in subroutines. In Subsection 3.2, we show how to ensure the input graph is -outerplanar and how to solve subproblems with pattern vertices in time. The latter will form a base case for our divide and conquer scheme leading to the proof Theorem 1.1. In Subsection 3.3 we provide more technical lemma’s that use systems of separators for reductions, and how to acquire a balanced separator.

### 3.1 Monitors, Subproblems and Reductions

A monitor is an object that ‘monitors’ a particular set of vertices , in the sense that for some range of intersection sizes one counts all pattern occurrence with exactly vertices in :

###### Definition 3.1 (Monitor).

A monitor over is a triple . If is a set of monitors over and , we denote

 lowM(M) :=max{Mlow:(M,Mlow,Mupp)∈M}, uppM(M) :=min{Mupp:(M,Mlow,Mupp)∈M}.

We let denote the set of vectors with for every monitor . We say a monitor is small if and , and it is large if and . We denote for the set of small monitors in , and for the set of laronitorge monitors. If and , we say if for every it holds that .

Now we define a ‘subproblem’, which corresponds to a recursive call of the divide and conquer scheme we will employ to prove Theorem 1.1 in Section 4.

###### Definition 3.2 (Subproblem).

A subproblem is a tuple where is a graph, , and is a family of monitors over . The answer to is the vector indexed by every , and function such that

 a[r,(X,Y),f]:=|{g∈ind(P[X],G):g extends f∧gpicksr}|.

We index answers also by non-canonical separations; the value in the answer then can be deduced algorithmically fast via finding the value in the answer with corresponding separator in the same equivalence class via basic data-structures.

Note that there are possible values for , options for , and options for . While generating subproblems, we will therefore ensure that , and that for any invoked subproblem.

The following lemma allows us to only compute for a maximal set of non-isomorphic separations .

###### Lemma 3.3.

If is isomorphic to , then .

###### Proof.

Suppose there is an such that for every , and that such that , and (i.e. is counted in ). Then contributes to and since and determine it follows that