A linear fixed parameter tractable algorithm for connected pathwidth

The graph parameter of pathwidth can be seen as a measure of the topological resemblance of a graph to a path. A popular definition of pathwidth is given in terms of node search where we are given a system of tunnels that is contaminated by some infectious substance and we are looking for a search strategy that, at each step, either places a searcher on a vertex or removes a searcher from a vertex and where an edge is cleaned when both endpoints are simultaneously occupied by searchers. It was proved that the minimum number of searchers required for a successful cleaning strategy is equal to the pathwidth of the graph plus one. Two desired characteristics for a cleaning strategy is to be monotone (no recontamination occurs) and connected (clean territories always remain connected). Under these two demands, the number of searchers is equivalent to a variant of pathwidth called {\em connected pathwidth}. We prove that connected pathwidth is fixed parameter tractable, in particular we design a $2^{O(k^2)}\cdot n$ time algorithm that checks whether the connected pathwidth of $G$ is at most $k.$ This resolves an open question by [Dereniowski, Osula, and Rz{\k{a}}{\.{z}}ewski, Finding small-width connected path-decompositions in polynomial time. Theor. Comput. Sci., 794:85-100, 2019]. For our algorithm, we enrich the typical sequence technique that is able to deal with the connectivity demand. Typical sequences have been introduced in [Bodlaender and Kloks. Efficient and constructive algorithms for the pathwidth and treewidth of graphs. J. Algorithms, 21(2):358-402, 1996] for the design of linear parameterized algorithms for treewidth and pathwidth. The proposed extension is based on an encoding of the connectivity property that is quite versatile and may be adapted so to deliver linear parameterized algorithms for the connected variants of other width parameters as well.


Introduction
1 A graph H is a minor of a graph G if H can be obtained by some subgraph of G by contracting edges. 2 An equivalent setting of graph searching is to see G as a system of pipelines or corridors that is contaminated by some poisonous gas or some highly infectious substance. The searchers can be seen as cleaners that deploy a decontamination strategy [13,19]. The fact that the fugitive is invisible, fast, lucky, and agile permits us to see him as being omnipresent in any edge that has not yet been cleaned.
x y Figure 1 A graph G of connected pathwidth 2 with a subgraph of connected pathwidth 3.
computing, in particular in [4], where the authors considered the problem of capturing an intruder by mobile agents (acting for example as antivirus programs). As agents deploy their cleaning strategy, they must guarantee that, at each moment of the search, the cleaned territories remain connected, so to permit the safe exchange of information between the coordinating agents. The systematic study of connected graph searching was initiated in [3,5]. When, in node searching, we demand that the search strategies are monotone and connected, we define monotone connected node search number, denoted by mcns(G). The graph decomposition counterpart of this parameter was introduced by Dereniowski in [16]. He defined the connected pathwidth of a connected graph, denoted by cpw(G), by considering connected path-decompositions Q = {B 1 , . . . , B q } where the following additional property is satisfied: For every i ∈ {1, . . . , q}, the subgraph of G induced by h∈{1,...,i} B h is connected.
As noticed in [16], for every connected graph G, mcns(G) = cpw(G) + 1 (see also [1]). Notice that the above demand results to a break of symmetry: the fact that B 1 , . . . , B q is a connected path-decomposition does not imply that the same holds for B q , . . . , B 1 (while this is always the case for conventional path-decompositions). This sense of direction seems to be the source of all combinatorial particularities (and challenges) of connected pathwidth.
Computing connected pathwidth. It is easy to see that checking whether cpw(G) ≤ k is an NP-complete problem: if we define G * as the graph obtained from G after adding a new vertex adjacent with all the vertices of G, then observe that pw(G) = cpw(G * ) − 1. This motivates the question on the parameterized complexity of the problem. The first progress in this direction was done recently in [17] by Dereniowski, Osula, and Rzążewski who gave an f (k) · n O(k 2 ) time algorithm. In [17,Conjecture 1], they conjectured that there is a fixed parameter algorithm checking whether cpw(G) ≤ k. The general question on the parameterized complexity of the connected variants of graph search was raised as an open question by Fedor V. Fomin during the GRASTA 2017 workshop [18].
A somehow dissuasive fact towards a parameterized algorithm for connected pathwidth is that connected pathwdith is not closed under minors and therefore it does not fit in the powerful algorithmic framework of Graph Minors (which is the case with pathwidth). The removal of an edge may increase the parameter. For instance, the connected pathwidth of the graph in Figure 1 has connected pathwidth 2 while if we remove the edge {x, y} its connected pathwidth increases to 3. On the positive side, connected pathwidth is closed under contractions (see e.g., [1]), i.e, its value does not increase when we contract edges and, moreover, the yes-instances of the problem have bounded pathwidth, therefore they also have bounded treewidth. Based on these observations, the existence of a parameterized algorithm would be implied if we can prove that, for any k, the set Z k of contraction-minimal 3 graphs with connected pathwidth more than k is finite: as contraction containment can be expressed

64:4 A Linear Fixed Parameter Tractable Algorithm for Connected Pathwidth
in MSO logic, one should just apply Courcelle's theorem [14] to check whether some graph of Z k is a contraction of G. The hurdle in this direction is that we have no idea whether Z k is finite or not. The alternative pathway is to try to devise a linear parameterized algorithm by applying the algorithmic techniques that are already known for pathwidth.
The typical sequence technique. The main result of [8] was an algorithm that, given a path-decomposition Q of G of width at most k and an integer w, outputs, if exists, a path-decomposition of G of width at most w, in 2 O(k(w+log k)) · n time. In this algorithm Bodlaender and Kloks introduced the celebrated typical sequence technique, a refined dynamic programming technique that encodes partial path/tree decompositions as a system of suitably compressed sequences of integers, able to encode all possible path-decompositions of width at most w (see also [15,30]). This technique was later extended/adapted for the design of parametrized algorithms for numerous graph parameters such as branchwidth [9], linearwidth [10], cutwidth [39], carving-width [38], modified cutwidth, and others [6,7,40]. In [6] this technique was viewed as a result of un-nondeterminization: a stepwise evolution of a trivial hypothetical non-deterministic algorithm towards a deterministic parameterized algorithm. A considerable generalization of the characteristic sequence technique was proposed in the PhD thesis of Soares [32] where this technique was implemented under the powerful metaalgorithmic framework of q-branched Φ-width. Non-trivial extensions of the typical sequence technique where proposed for devising parameterized algorithms for parameters on matroids such as matroid pathwidth [23], matroid branchwidth [25], as well as all the parameters on graphs or hypergraphs that can be expressed by them. Very recently Bodlaender, Jaffke, and Telle in [7] suggested refinements of the typical sequence technique that enabled the polynomial time computation of several width parameters on directed graphs. Finally, Bojańczyk and Pilipczuk suggested an alternative approach to the typical sequence technique, based on MSO transductions between decompositions [11].
Unfortunately, the above mentioned state of the art on the typical sequence technique is unable to encompass connected pathwidth. A reason for this is that the connectivity demand is a "global property" applying to every prefix of the path-decomposition which correspond to an unbounded number of subgraphs of arbitrary size.
Our result. In this paper we resolve affirmatively the conjecture that checking whether cpw(G) ≤ k is fixed parameter tractable. Our main result is the following. Theorem 1. One may construct an algorithm that given an n-vertex connected graph G, a path-decomposition Q = B 1 , . . . , B q of G of width at most k and an integer w, outputs a connected path-decomposition of G of width at most w or reports correctly that such an algorithm does not exist in 2 O(k(w+log k)) · n time.
To design an algorithm checking whether cpw(G) ≤ k we first use the algorithms of [8] and [20], to build, if exists, a path decomposition of G of width at most k, in 2 O(k 2 ) · n time. In case of a negative answer we know than cpw(G) > k, otherwise we apply the algorithm of Theorem 1. The overall running time is dominated by the algorithm of Fürer in [20] which is 2 O(k 2 ) · n.
Our techniques. We now give a brief description of our techniques by focusing on the novel issues that we introduce. This description demands some familiarity with the typical sequence technique. Otherwise, the reader can go directly to the next section.
Let Q = B 1 , . . . , B q be a (nice) path-decomposition of G of width at most k. For every i ∈ [q], we let G i = (G i , B i ) be the boundaried graph where G i = G[ h∈{1,...,i} B h ]. We follow standard dynamic programming over a path-decomposition that consists in computing a representation of the set of partial solutions associated to G i , which in our case are connected path-decompositions of G i of width at most w. The challenge is how to handle in a compact way the connectivity requirement of a path-decomposition of a graph that can be of arbitrarily large size.
A connected path-decomposition P = A 1 , . . . , A of G i is represented by means of a (G i , P)-encoding sequence S = s 1 , . . . , s . For every j ∈ [ ], the element s j of the sequence S is a triple (bd(s j ), cc(s j ), val(s j )) where: bd( To compress a (G i , P)-encoding sequence S, we identify a subset bp(S) of indexes, called breakpoints, such that j ∈ bp(S) if bd(s j−1 ) = bd(s j ) (type-1) or cc(s j−1 ) = cc(s j ) (type-2) or j is an index belonging to a typical sequence of the integer sequence val(s b ), . . . , val(s c−1 ) where b, c ∈ [ ] are consecutive type-1 or 2-breakpoints. We define rep(S) as the induced subsequence S[bp(S)].
The novelty in this representation is the cc(·) component which is a near-partition of the subset B i ∩ V (G j i ) of boundary vertices. The critical observation is that for every j ∈ [ − 1], cc(s j+1 ) is coarser than cc(s j ). This, together with the known results on typical sequences, allows us to prove that the size of rep(S) is O(kw) and that the number of representative sequences is 2 O(k(w+log k)) . Finally, as in the typical sequence technique, we define a domination relation over the set of representative sequences. The DP algorithm over the path-decomposition Q consists then in computing a domination set The above scheme extends the current state of the art on typical sequences as it further incorporates the encoding of the connectivity property. While this is indeed a "global property", it appears that its evolution with respect to the bags of the decomposition can be controlled by the second component of our encoding and this is done in terms of a sequence of a gradually coarsening partitions. This establishes a dynamic programming framework that can potentially be applied on the connected versions of most of the parameters where the typical sequence technique was used so far. Moreover, it may be the starting point of the algorithmic study of parameters where other, alternative to connectivity, global properties are imposed to the corresponding decompositions.
Consequences in connected graph searching. The original version of graph searching was the edge searching variant, defined 4 by Parsons [33,34], where the only differences with node searching is that a searcher can additionally slide along an edge and sliding is the only way to clean an edge. The corresponding search number is called edge search number and is denoted by es(G). If we additionally demand that the searching strategy is connected and monotone, then we define the monotone connected edge search number denoted by mces(G). As proved 4 An equivalent model was proposed independently by Petrov [35]. The models of Parsons and Petrov where different but also equivalent, as proved by Golovach in [21,22]. The model of Parsons was inspired by an earlier paper by Breisch [12], titled "An intuitive approach to speleotopology", where the aim was to rescue an (unlucky) speleologist lost in a system of caves. Notice that "unluckiness" cancels the speleologist's will of being rescued as, from the searchers' point of view, it imposes on him/her the status of an "evading entity". As a matter of fact, the connectivity issue appears even in the first inspiring model of the search game. In a more realistic scenario, the searchers cannot "teleport" themselves to non-adjacent territories of the caves while this was indeed permitted in the original setting of Parsons. in [29], es(G) = pw(G v ), where G v is the graph obtained if we subdivide twice each edge of G. Applying the same reduction as in [29] for the monotone and connected setting, one can prove that mces(G) = cpw(G v ). As we already mentioned, mcns(G) = cpw(G v ) + 1. These two reductions imply that the result of Theorem 1 holds also for mcns and mces, i.e., the search numbers for the monotone and connected versions of both node and edge searching.
Observe that a near-partition may contain several copies of the empty set. A partition of S is a near-partition with the additional constraint that if it contains the empty set, then this is the unique block. Let Q be a near-partition of a set S and Q be a near-partition of a set S such that S ⊆ S . We say that Q is thinner than Q , or that Q is coarser than Q, which we denote Q Q , if for every block X of Q, there exists a block X of Q such that X ⊆ X . For a near-partition Q = {X 1 , . . . , X } of S and a subset S ⊆ S, we define the projection of Q onto S as the near-partition Observe that if Q is a partition, then Q |S may not be a partition: if several blocks of Q are subsets of S \ S , then Q |S contains several copies of the emptyset.
Sequences. Let S be a set. A sequence of elements of S, denoted by α = a 1 , . . . , a , is a subset of S equipped with a total ordering: for 1 i < j , a i occurs before a j in the sequence α. The length of a sequence is the number of elements that it contains. Let X ⊆ [ ] be a subset of indexes of α. We define the subsequence of α induced by X as the sequence α[X] on the subset {a i | i ∈ X} such that, for i, j ∈ X, a i occurs before a j in α[X] if and only if i < j.
The duplication of the element a j , with j ∈ [ ], in the sequence α = a, . . . , a yields the sequence α = a 1 , . . . , a j , a j , . . . , a of length + 1. A sequence β is an extension of the sequence α if it is either α or it results from a series of duplications on α. We define the set of extensions of α as: Ext(α) = {α * | α * is an extension of α}.
Let α = a 1 , . . . , a be a sequence and α * = a 1 , . . . , a p be an extension of α. If p ≤ +k, then α * results from a series of at most k duplications and we say that α * is a (≤ k)-extension of α. With the definition of an extension, every element of α * is a copy of some element of α. We define the extension surjection as a surjective function δ α * →α : An extension surjection δ α * →α is a certificate that α * ∈ Ext(α). Finally, we observe that if α * ∈ Ext(α), then α is an induced subsequence of α * . Moreover, if α * ∈ Ext(α) and β ∈ Ext(α * ), then β is an extension of α.
Graphs and boundaried graphs. Given a graph G = (V, E) and a vertex set S ⊆ V (G), we denote by G[S] the subgraph of G that is induced by the vertices of S, i.e., the graph The neighborhood of a vertex v in G is the set of vertices that are adjacent to v in G and is denoted by N G (v).
A boundaried graph is a pair G = (G, B) such that G is a graph over a vertex set V and B ⊆ V is a subset of distinguished vertices, called boundary vertices. We say that a boundaried graph G = (G, B) is connected if either G is connected and B = ∅ or, in case B = ∅, every connected component C of G contains some boundary vertex, that is C ∩ B = ∅. The definition of a connected path-decomposition also naturally extends to boundaried graphs as follows.

Integer sequences
Let us recall the notion of typical sequences introduced by Bodlaender and Kloks [8] (see also [15,30]). α = a 1 , . . . , a be an integer sequence. The typical sequence Tseq(α) is obtained after iterating the following operations, until none is possible anymore:

Definition 3. Let
if for some i ∈ [ − 1], a i = a i+1 , then remove a i+1 from α; if there exists i, j ∈ [ ] such that i j − 2 and ∀h, i < h < j, a i ≤ a h ≤ a j or ∀h, i < h < j, a i ≥ a h ≥ a j , then remove the subsequence a i+1 , . . . , a j−1 from α.
As a typical sequence Tseq(α) = b 1 , . . . , b i , . . . , b r is a subsequence of α, it follows that, for every i ∈ [r], there exists j i ∈ [ ] such that b i = a ji . Herefater every such index j i is called a tip of the sequence α.
We extend the definition of the ≤-relation and -relation on integer sequences to sequences of integer sequences. Let P = L 1 , . . . , , L r and Q = K 1 , . . . , K r be two sequences of integer sequences such that for every i ∈ [r], L i and K i have the same length. We say that Finally we say that P Q if there exist P ∈ Ext(P) and Q ∈ Ext(Q) such that P ≤ Q . If P Q and Q P, then we say that P ≡ Q. The relation ≡ is an equivalence relation.

Boundaried sequences
We now define the main notion that will allow us to represent and manipulate (connected) path-decompositions of a boundaried graph G = (G, B) (see Subsection 3.1). = s 1 , . . . , s such that for every j ∈ [ ], s j = (bd(s j ), cc(s j ), val(s j )) is defined as follows:

64:8 A Linear Fixed Parameter Tractable Algorithm for Connected Pathwidth Definition 5 (B-boundaried sequence). Let B be a finite set. A B-boundaried sequence is a sequence S
bd(s j ) ⊆ B with the property that for every x ∈ B, the indices j ∈ [l] such that x ∈ bd(s j ) are consecutive; cc(s j ) is a near-partition of i≤j bd(s i ) ⊆ B with the property that for every j < , cc(s j ) cc(s j+1 ); val(s j ) is a positive integer. The width of S is defined as width(S) = max j∈ (|bd(s j )| + val(s j )).
As in [8,24], we will bound the number of representatives of B-boundaried sequences. For doing so, we bound the number of B-boundaried models and then use [8,Lemma 3.5] which gives an upper bound on the number of typical sequences. Taking into account the fact that there are O(|B|) breakpoints and |B| O(k) different coarsening scenarios for the encoded near-partitions, we prove the following bound. Notice that the notion of a B-boundary model corresponds to the one of interval model in [8]. Besides the B-boundary model of a sequence S, we introduce the profile of S, which corresponds to the concept of list representation in [8].

If T is a B-boundaried sequence such that S T, then there exist an extension S * of S
and an extension T * of T such that S * ≤ T * .

The relation
is transitive, and ≡ is an equivalence relation (refering to boundary sequences).

Operations on B-boundaried sequences
Given a finite set B, we define two operations on B-boundaried sequences that will be later used in the DP algorithm. The projection of a B-boundaried sequence S onto B B aims at changing the status of a boundary element from B \ B to the status of a non-boundary element. The second operation deals with the insertion in a B-boundaried sequence of a new boundary element x with respect to a subset X ⊆ B. S = s 1 , . . . , s i , . . . , s be a B-boundaried sequence. For  a subset B ⊆ B, the projection of S onto B is  We observe that though the B-boundaried sequence S is connected, its projection S |B onto B ⊆ B may not be connected. This is the case if for some j ∈ [ ], the partition cc(s j ) contains several blocks and at least one of them is a subset of B \ B . Notice that the projection operation does not change the width of a sequence.  if j < f x , then bd(s x j ) = bd(s j ); cc(s x j ) = cc(s j ) and val(s We can show that if T is an extension of S, then, to every valid insertion position (f x , l x ) with respect to some subset X ⊆ B in S, one can associate a valid insertion position (f * x , l * x ) with respect to X in T. The reverse is not true as illustrated by Figure 4. T δ T→S (·)

Insertion into a B-boundaried sequence
x Figure 4 Let T be a 2-extension of the B-boundaried sequence S. Suppose that (5, 10) is a valid insertion position with respect to some set X ⊆ B in T. Observe that as 4 = δ T→S (5) and 9 = δ T→S (10), (4,9) is also a valid insertion position with respect to some for X ⊆ B in S. However, Ins(T, x, X, 5, 10) is not a 2-extension of Ins(S, x, X, 4,9).
However the next two lemmas provides an alternative by means of 2-extensions of S. The idea of the proof of Lemma 20 is illustrated by Figure 5.  Figure 5 Let the B-boundaried sequence T be an extension of S that is certified by the surjective function δ T→S (·) such that f * The fact that T is an extension of R can be certified by the surjective

Computing the connected pathwidth
A (connected) path-decomposition P = A 1 , . . . , A of a graph G is nice if |A 1 | = 1 and ∀i ∈ [p], |A i−1 A i | = 1. A bag A i , for 1 < 1 ≤ , is called an introduce bag if A i A i−1 and a forget bag otherwise. As we will show, connected B-boundaried sequences are combinatorial objects designed in order to encode connected path-decompositions. Our algorithm is based on two routines. Forget Routine processes the forget bags by performing a projection operation on the B-boundaried sequences associated to those bags, while Insertion Routine handles the insertion bags by performing an insertion operation in the associated boundaried sequences. It is worth to observe that cc(s j ) is, in general, not a partition of A j (see Figure 3). Also, notice that if G j is connected and B ∩ V j = ∅, then cc(s j ) = {∅}. Notice that if P is a connected path-decomposition, then S is a connected B-boundaried sequence.

64:12 A Linear Fixed Parameter Tractable Algorithm for Connected Pathwidth
Definition 22. Let G = (G, B) be a connected boundaried graph and S a B-boundaried sequence. We say that S is realizable in G if there is an extension S * of S that is the (G, P)-encoding sequence of some connected path-decomposition P of G.
Let us observe that if a B-boundaried sequence S is realizable, then S is connected. The set of representative B-boundaried sequences of a connected boundaried graph G = (G, B) of width ≤ w is defined as: To compute the connected pathwidth of a graph, rather than computing Rep w (G), we compute a subset D w (G) ⊆ Rep w (G), called domination set, such that for every representative B-boundaried sequence S ∈ Rep w (G), there exists a representative B-boundaried sequence R ∈ D w (G) where R S. Observe that a connected boundaried graph G = (G, B) has connected pathwidth at most w if and only if D w+1 (G) = ∅.

Forget Routine
Let G = (G, B) be a boundaried graph. If x ∈ B is a boundary vertex, we denote by B x = B \ {x}. We define G x = (G, B x ), that is, while the graph G is left unchanged, we remove x from the set of boundary vertices. Forget Routine is described in Algorithm 1. Its correctness is proved in two steps. We first establish the completeness of the algorithm that is: for every connected path-decomposition P of G x , there exists some B-boundaried sequence S ∈ D w (G) such that rep(S |B\{x} ) rep(T) where T is the (G x , P)-encoding sequence. For the soundness of the routine we prove that for every B-boundaried sequence S ∈ D w (G),

Insertion Routine
Let G = (G, B) be a boundaried graph with G = (V, E). For a subset X ⊆ B, we set G x = (V ∪ {x}, E ∪ {xy | y ∈ X}) and G x = (G x , B x ) where B x = B ∪ {x}. Algorithm 2 is describing Insertion Routine (notations of Figure 5 are used in the pseudo-code). To prove its correctness, we proceed in two steps. We first establish the completeness of the algorithm: for every connected path-decomposition P x of G x , the (G x , P x )-encoding sequence T x is dominated by some B x -boundaried sequence S x that can be computed from a B-boundaried sequence S belonging to D w (G). Then we argue about the soundness of Insertion Routine that is: if S x is generated from a B-boundaried S ∈ D w (G), then rep(S x ) belongs to D w (G x ). The proofs of completeness and soundness rely both on Lemma 19, and Lemma 20. As for Forget Routine, the time complexity follows from Lemma 10.

The dynamic programming algorithm
We are now in position to prove Theorem 1. We are given a nice path-decompositon Q = B 1 , . . . , B q of G of width at most k and for each i ∈ [q], we consider the boundaried graphs G i = (G[V i ], B i ), where V i = 1≤h≤i B h . We have a way to compute D w (G i+1 ) from D w (G i ), in 2 O(k 2 ) · n time, using the algorithms of Theorem 23 or Theorem 24 depending on whether B i is an insertion or a forget bag. We next describe the set D w+1 (G 1 ). For this, we take the representative set Rep w+1 (G 1 ) that consists for the following four possible connected B 1 -boundaried sequences:  [8,Section 6] Bodlaender and Kloks explained how to turn their decision algorithm for pathwidth and treewidth to one that is able to construct, in case of a positive answer, the corresponding decomposition. It is straightforward to see that the modification of [8, Section 6] that transforms the decision algorithm for pathwidth to one that also constructs the corresponding path-decomposition also applies to our algorithm for connected pathwidth. This completes the proof of Theorem 1.
If we now use the result of Fürer [20] for constructing a path-decomposition of width at most k in 2 O(k 2 ) · n time and taking into account that pw(G) ≤ cpw(G), we have the following.
Theorem 25. One may construct an algorithm that, given an n-connected graph G and a non-negative integer k, either outputs a connected path-decomposition of G of width at most k or correctly reports that such a decomposition does not exist in 2 O(k 2 ) · n time.