Parameterized Complexity of $(A,\ell)$-Path Packing

Given a graph $G = (V,E)$, $A \subseteq V$, and integers $k$ and $\ell$, the \textsc{$(A,\ell)$-Path Packing} problem asks to find $k$ vertex-disjoint paths of length $\ell$ that have endpoints in $A$ and internal points in $V \setminus A$. We study the parameterized complexity of this problem with parameters $|A|$, $\ell$, $k$, treewidth, pathwidth, and their combinations. We present sharp complexity contrasts with respect to these parameters. Among other results, we show that the problem is polynomial-time solvable when $\ell \le 3$, while it is NP-complete for constant $\ell \ge 4$. We also show that the problem is W[1]-hard parameterized by pathwidth${}+|A|$, while it is fixed-parameter tractable parameterized by treewidth${}+\ell$.


Introduction
Let G = (V , E) be a graph and A ⊆ V . A path P in G with at least one edge is an A-path if the first and last vertices of P belong to A and all other vertices of P belong to V \A. Given G and A, A-Path Packing is the problem of finding the maximum number of vertex-disjoint A-paths in G. The A-Path Packing problem is well studied and even some generalized versions are known to be polynomial-time solvable (see e.g., [7,8,17,26,31,32]). Note that A-Path Packing is a generalization of Maximum Matching since they are equivalent when A = V .
In this paper, we study a variant of A-Path Packing that also generalizes Maximum Matching. An A-path of length is an (A, )-path, where the length of a path is the number of edges in the path. Now our problem is defined as follows: On the other hand, ALPP is fixed-parameter tractable when parameterized by k + and thus by |A| + as well (Theorem 3.5). We later strengthen Observation 3.2 by showing that the problem is NP-complete for every fixed ≥ 4 even on grid graphs (Theorem 5.3). We then study structural parameters such as treewidth and pathwidth in combination with the standard parameters. We first observe that ALPP can be solved in time n O(tw) (Observation 4.1), where n and tw are the number of vertices and the treewidth of the input graph, respectively. Furthermore, we show that ALPP parameterized by tw + is fixed-parameter tractable (Observation 4.2). We finally show that Full-ALPP parameterized by pw + |A| is W[1]-hard (Theorem 4.5), where pw is the pathwidth of the input graph.
For SAPP, a simple reduction (Lemma 6.1) will show that all our positive results on ALPP hold also on this short-path version. Although negative results cannot be translated directly, we can show the hardness of the cases where |A| or is a constant (Theorems 6.6 and 6.7). We leave the complexity of SAPP parameterized by tw unsettled.

Preliminaries
A graph G = (V , E) is a grid graph if V is a finite subset of Z 2 and E = {{(r , c), (r , c )} | |r − r | + |c − c | = 1}. From the definition, all grid graphs are planar, bipartite, and of maximum degree at most 4. To understand the intractability of a graph problem, it is preferable to show hardness on a very restricted graph class. The class of grid graphs is one of such target classes.
A tree decomposition of a graph G = (V , E) is a pair ({X i | i ∈ I }, T = (I , F)), where X i ⊆ V for each i and T is a tree such that -for each vertex v ∈ V , there is i ∈ I with v ∈ X i ; -for each edge {u, v} ∈ E, there is i ∈ I with u, v ∈ X i ; -for each vertex v ∈ V , the induced subgraph T [{i | v ∈ X i }] is connected.
The width of a tree decomposition ({X i | i ∈ I }, T ) is max i∈I |X i | − 1, and the treewidth of a graph G, denoted tw(G), is the minimum width over all tree decompositions of G.
The pathwidth of a graph G, denoted pw(G), is defined by restricting the trees T in tree decompositions to be paths. We call such decompositions path decompositions. It is easy to see that pathwidth does not change significantly by subdividing some edges and attaching paths to some vertices. To be self-contained, we present a proof in the appendix (see Section A).

Lemma 2.1
If G is a graph obtained from a graph G = (V , E) by subdividing a set of edges F ⊆ E an arbitrary number of times, and attaching a path of arbitrary length to each vertex in a set U ⊆ V , then pw(G ) ≤ pw(G) + 2.

Standard Parameterizations of ALPP
In this section, we completely determine the complexity of ALPP with respect to the standard parameters |A|, k, , and their combinations. (Recall that k ≤ |A|/2.) We first observe that using one of them as a parameter does not make the problem tractable. That is, the problem remains NP-complete even if one of |A|, k, is a constant. We then show that the problem is tractable when ≤ 3 or when k + is the parameter.

Intractable Cases
The first observation is that Full-ALPP is NP-complete on grid graphs even if |A| = 2 (and thus k = 1). This can be shown by an easy reduction from Hamiltonian Cycle on grid graphs [20]. This observation is easily extended to every fixed even |A| by adding dummy paths of length as connected components into the graph and their endpoints into A. Observation 3.1 For every even constant α ≥ 2, Full-ALPP with |A| = α is NPcomplete on grid graphs.
The NP-hardness of Full-ALPP for fixed ≥ 4 can be shown by an easy reduction from Path Partition [21].
We omit the proof as we later strengthen Observation 3.2 to hold on grid graphs (see Sect. 5). Note that the condition ≥ 4 in the statement above is tight as the problem is polynomial-time solvable when ≤ 3 (see Theorem 3.3).

Tractable Cases
For the case of = 3, we construct an auxiliary graph Fig. 2): We show that (G, A, k, 3) is a yes-instance if and only if G has a matching of cardinality k + |V \A|.
To prove the if direction, assume that G has a matching of size k + |V \A|. Let M be a maximum matching of G that includes the maximum number of vertices in V 1 ∪ V 2 among all maximum matchings of G . We claim that M actually includes all vertices in V 1 ∪ V 2 . Suppose to the contrary that v 1 or v 2 is not included in M for some v ∈ V \A. Now, since M is maximum, exactly one of v 1 and v 2 is included in M.
is a maximum matching that uses more vertices in V 1 ∪V 2 than M. This contradicts how M was selected.
is a maximum matching that uses the same number of vertices in V 1 ∪ V 2 as M. Since M is maximum and w 2 is not included in M , the vertex w 1 has to be included in M , but such a case leads to a contradiction as we saw in Case 1.
Since M is a matching, these eight vertices are pairwise distinct, and thus (x, u, v, y) and (x , u , v , y ) are vertex-disjoint (A, 3)-paths. Since |M| ≥ k + |V \A| and each edge in E A,1 ∪ E 1,2 uses one vertex of V 1 , M includes at least k edges in E 2,2 . By constructing an (A, 3)-path for each edge in M ∩ E 2,2 , we obtain a desired set of k vertex-disjoint (A, 3)-paths.
In their celebrated paper on Color-Coding [1], Alon, Yuster, and Zwick showed the following result. By using Proposition 3.4 as a black box, we can show that ALPP parameterized by k + is fixed-parameter tractable. Proof Let (G, A, k, ) be an instance of ALPP. Observe that the problem ALPP can be seen as a variant of the Subgraph Isomorphism problem as we search for H = k P +1 in G as a subgraph with the restriction that each endpoint of P +1 in H has to be mapped to a vertex in A, where P +1 denotes an ( + 1)-vertex path (which has length ) and k P +1 denotes the disjoint union of k copies of P +1 . We reduce this problem to the standard Subgraph Isomorphism problem [18].
Let G and H be the graphs obtained from G and H , respectively, by subdividing each edge once. The graphs G and H = k P 2 +1 are bipartite. We then construct G from G by attaching a triangle to each vertex in A; that is, for each vertex u ∈ A we add two new vertices v, w and edges {u, v}, {v, w}, and {w, u}. Similarly, we construct H from H by attaching a triangle to each endpoint of each P 2 +1 . Note that |V (G )| ∈ O(n 2 ), |V (H )| = k(2 + 1), and tw(H ) = 2. Thus, by Proposition 3.4, it suffices to show that (G, A, k, ) is a yes-instance of ALPP if and only if G has a subgraph isomorphic to H .
To show the only-if direction, assume that G has k vertex-disjoint (A, )-paths P 1 , . . . , P k . In G , for each P i , there is a unique path Q i of length 2 plus triangles attached to the endpoints; that is, Q i consists of the vertices of P i , the new vertices and edges introduced by subdividing the edges in P i , and the triangles attached to the endpoints of the subdivided path. Furthermore, since the paths P i are pairwise vertex-disjoint, the subgraphs Q i of G are pairwise vertex-disjoint. Thus, G has a subgraph isomorphic to H = 1≤i≤k Q i .
To prove the if direction, assume that G has a subgraph X isomorphic to H . Let R 1 , . . . , R k be the connected components of X . Each R i is isomorphic to a path of length 2 with a triangle attached to each endpoint. Let u, v ∈ V (R i ) be the degree-3 vertices of R i . Since G is obtained from the triangle-free graph G by attaching triangles at the vertices in A, we have u, v ∈ A. Since the u-v path of length 2 in R i is obtained from a u-v path of length in G by subdividing each edge once,

Structural Parameterizations
In this section, we study structural parameterizations of ALPP. First we present XP and FPT algorithms parameterized by tw and tw + , respectively. As the techniques are rather standard in the field, we only sketch the high-level ideas of the algorithms.
The XP-time algorithm parameterized by tw is a standard dynamic-programming over a tree decomposition. We first compute a nice tree decomposition of width O(tw) using known algorithms [4,6,23] and then solve the problem in a bottom-up manner. The DP table for each bag stores the existence of a partial solution for all possible ways of the intersection between the bag and the partial solution. Since a bag intersects at most O(tw) vertex-disjoint (A, )-paths, it is straightforward to see that the table size can be bounded by (|A| · ) O(tw) and that we can compute all entries of the tables for all bags in time polynomial in the total table size. As |A| and are at most n, the total running time is n O(tw) . The FPT algorithm parameterized tw + is achieved by expressing the problem in the monadic second-order logic (MSO 2 ) on graphs. It is known that given an n-vertex graph of treewidth w and assignments to some free variables of an MSO 2 formula ϕ, one can find in time O( f (|ϕ| + w) · n), where f is some computable function, an assignment to the rest of free variables that satisfies ϕ and maximizes a given linear function in the sizes of the free variables of ϕ [2,4,10]. It is straightforward to express in MSO 2 a formula ϕ (X , Y ) with two free variables X and Y such that -the length of ϕ (X , Y ) depends only on , and -when we assign a vertex set A to X and an edge set F to Y , G models ϕ (X , Y ) if and only if G has vertex-disjoint (A, )-paths formed by F.
We assign the terminal vertex set A in the input of ALPP to the variable X , and maximize the size of the edge set F assigned to Y . As mentioned above, this can be done in time O( f (|ϕ | + w) · n) for n-vertex graphs of treewidth at most w, where f is some computable function.

Observation 4.2 ALPP parameterized by tw + is fixed-parameter tractable.
Now we show that Full-ALPP is W[1]-hard parameterized by pathwidth (and hence also by treewidth), even if we also consider |A| as an additional parameter. We present a reduction from a W[1]-complete problem k-Multi-Colored Clique (k-MCC) [15], which goes through an intermediate version of our problem. Specifically, we will consider a version of Full-ALPP with the following modifications: the graph has (positive integer) edge weights, and the length of a path is the sum of the weights of its edges; the set A is given to us partitioned into pairs indicating the endpoints of the sought A-paths; for each such pair the value of may be different.
More formally, Extended-ALPP is the following problem: we are given a graph G = (V , E), a weight function w : E → Z + , and r triples ( We are asked if there exists a set of r vertex-disjoint paths in G such that for each i ∈ [r ] 1 , the ith path in this set has s i and t i as its endpoints and the sum of the weights of its edges is i . We first show that establishing that this variation of the problem is hard implies also the hardness of Full-ALPP.

Lemma 4.3 There exists an algorithm which, given an instance of Extended-ALPP on an n-vertex graph G with r triples and maximum edge weight W , constructs in time polynomial in n + W an equivalent instance
Proof First, we simplify the given instance of Extended-ALPP by removing edge weights: for every edge e = {u, v} ∈ E(G) with w(e) > 1, we remove this edge and replace it with a path from u to v with length w(e) going through new vertices (in other words, e has been subdivided w(e) − 1 times). It is not hard to see that we have an equivalent instance of Extended-ALPP on the new graph, which we call G 1 , where the weight of all edges is 1 and |V (G 1 )| ≤ n 2 · W . We now give a polynomial-time reduction from this new instance of Extended-ALPP to Full-ALPP.
Let p = |V (G 1 )| and = 2 p 2 . For each i ∈ [r ] we do the following: we construct a new vertex s i and connect it to s i using a path of length p 2 + i p going through new vertices; we construct a new vertex t i and connect it to t i using a path of length . This completes the construction and it is clear that |A| = 2r , the new graph G has order at most 2 p 3 ≤ 2n 6 · W 3 and can be constructed in time polynomial in n + W .
We claim that the new graph G has |A|/2 vertex-disjoint (A, )-paths if and only if the Extended-ALPP instance of G 1 has a positive answer. Indeed, if there exists a collection of r vertex-disjoint paths in G 1 such that the i-th path has endpoints s i , t i and length i , we add to this path the paths from s i to s i and from t i to t i and this gives a path of length = 2 p 2 with endpoints in A. Observe that all these paths are vertex-disjoint, so we obtain a yes-certificate of Full-ALPP. For the converse direction, suppose that G has a set A of |A|/2 vertex-disjoint (A, )-paths. The set A does not contain a path with endpoints s i and s j since such a path has length at least we can conclude that each path P in A connects s i and t i for some i, and the subpath of P connecting s i and t i has length We therefore obtain a solution to the Extended-ALPP instance.
Finally, observe that the only modifications we have done on G is to subdivide some edges and to attach paths to some vertices. By Lemma 2.1, the pathwidth is increased only by at most 2.
We can now reduce the k-MCC problem to Extended-ALPP. Proof We are given a graph G = (V , E) with V partitioned into k sets V 1 , . . . , V k , and are asked for a clique of size k that contains one vertex from each set. To ease notation, we will assume that n is odd and |V i | = n for i ∈ [k] (so the graph has kn vertices in total) and that the vertices of V i are numbered 1, . . . , n. We define two lengths L 1 = (k + 1)(n − 1) and L 2 = 60n 6 .
For i ∈ [k] we construct a vertex-selection gadget as follows (see Fig. 3): we make n paths of length k, call them P i, j , where j ∈ [n]. Let a i, j and b i, j be the first and last vertices of path P i, j , respectively. We label the remaining vertices of the path P i, j as x i, j,i for i ∈ {1, . . . , k}\{i} in some arbitrary order. Then for each j ∈ [n − 1] we connect a i, j to a i, j+1 and b i, j to b i, j+1 . All edges constructed so far have weight 1. We set s i = a i,1 and t i = a i,n . We add to the instance the triple (s i , t i , L 1 ).
We now need to construct an edge-verification gadget as follows (see Fig. 4): for each i 1 , i 2 ∈ [k] with i 1 < i 2 , we construct three vertices s i 1 ,i 2 , t i 1 ,i 2 , p i 1 ,i 2 . For each edge e of G between V i 1 and V i 2 , we do the following: suppose e connects vertex j 1 of V i 1 to vertex j 2 of V i 2 . We add the following four edges: Fig. 4 An example of the edge-verification gadget for V i 1 and V i 2 (i 1 < i 2 ). In this example, there are exactly three edges between V i 1 and V i 2 We call the edges constructed in the above step heavy edges, since their weight is close to Note that in the above description we have created some parallel edges, for example from s i 1 ,i 2 to x i 1 ,2 j 1 ,i 2 (if the vertex j 1 of V i 1 has several neighbors in V i 2 ). This can be avoided by subdividing such edges once and assigning weights to the new edges so that the total weight stays the same. For simplicity we ignore this detail in the remainder since it does not significantly affect the pathwidth of the graph (see Lemma 2.1). This completes the construction.
Let us now prove correctness. First assume that we have a k-multicolored clique in G, encoded by a function σ : [k] → [n], that is, σ (i) is the vertex of the clique that belongs in V i . For the i-th vertex-selection gadget we have the triple (s i , t i , L 1 ). We construct a path from s i to t i by traversing the paths P i, j for j ∈ [n]\{σ (i)} in the increasing order of j and by appropriately using the "horizontal" edges connecting adjacent paths. See Fig. 5. The path has length L 1 : we have traversed n − 1 paths P i, j with j = σ (i), each of which has k edges; we have also traversed n − 1 horizontal edges connecting adjacent paths. The total length is therefore, (n − 1)k + n − 1 = L 1 . In this way we have satisfied all the k triples (s i , t i , L 1 ) and have not used the vertices Consider now a triple (s i 1 ,i 2 , t i 1 ,i 2 , L 2 ), for i 1 < i 2 . Because we have selected a clique, there exists an edge between vertex σ (i 1 ) of V i 1 and σ (i 2 ) of V i 2 . For this edge we have constructed four edges in our new instance, linking s i 1 ,i 2 to t i 1 ,i 2 with a total weight of L 2 . We use these paths to satisfy the k 2 triples (s i 1 ,i 2 , t i 1 ,i 2 , L 2 ). These paths are disjoint from each other: when i 1 < i 2 , x i 1 ,σ (i 1 ),i 2 is only used in the path from s i 1 ,i 2 to t i 1 ,i 2 and when i 1 > i 2 , x i 1 ,σ (i 1 ),i 2 is only used in the path from s i 2 ,i 1 to t i 2 ,i 1 . Furthermore, these paths are disjoint from the paths in the vertex-selection gadgets, For the converse direction, suppose we have a valid solution for the Extended-ALPP instance. First, consider the path connecting s i to t i . This path has length L 1 , therefore it cannot be using any heavy edges, since these edges have cost at least L 2 /4 − n 5 − n 3 > L 1 . Inside the vertex-selection gadget, the path may use either all of the edges of a path P i, j or none. Let us now see how many P i, j are unused. First, a simple parity argument shows that the number of paths traversed in the a i, j → b i, j direction is equal to those traversed in the opposite direction, so the total number of used paths is even. Since we have an odd number of paths in total (as n is odd), at least one path is not used. We conclude that exactly one P i, j is not used, otherwise the path from s i to t i would be too short. Let σ (i) be defined as the index j such that the internal vertices of P i, j are not used in the s i → t i path of the solution. We define a clique in G by selecting for each i the vertex σ (i).
Let us argue why this set induces a clique. Let j 1 , j 2 be the vertices selected in V i 1 , V i 2 respectively, with i 1 < i 2 , and consider the triple (s i 1 ,i 2 , t i 1 ,i 2 , L 2 ). This triple must be satisfied by a path that uses exactly four heavy edges, since each heavy edge has weight at least L 2 /5 + n 6 and at most L 2 /3 − 3n 6 , and all other edges together have weight smaller than n 3 . Hence, every such path is using at least two internal vertices of some P i, j because every heavy edge is incident on such a vertex. By our previous reasoning, the paths that satisfy the (s i , t i , L 1 ) triples have used all such vertices except for one path P i, j for each i. There exist therefore exactly k(k − 1) such vertices available, so each of the k(k − 1)/2 triples (s i 1 ,i 2 , t i 1 ,i 2 , L 2 ) has a path using exactly two of these vertices. Hence, each such path consists of four heavy edges and no other edges.
Such a path must therefore be using one edge incident on s i 1 ,i 2 , one edge incident on t i 1 ,i 2 and two edges incident on p i 1 ,i 2 . The used edge incident on s i 1 ,i 2 must have as other endpoint x i 1 ,2 j 1 ,i 2 , which implies that its weight is L 2 /4 + j 1 n 4 + j 2 n 2 , for some j 2 . Similarly, the edge incident on t i 1 ,i 2 must have weight L 2 /4 − j 1 n 4 − j 2 n 2 , as its other endpoint is necessarily x i 2 ,2 j 2 ,i 1 . We conclude that the only way that the length of this path is L 2 is if j 1 = j 1 and j 2 = j 2 . Therefore, we have an edge between the two selected vertices, and as a result a k-clique.
To conclude we observe that deleting the 3· k 2 vertices s i 1 ,i 2 , p i 1 ,i 2 , t i 1 ,i 2 disconnects the graph into components that correspond to the vertex gadgets with some paths attached. By Lemma 2.1, each such component has pathwidth at most 4 as it can be seen as a graph obtained from a subdivision of the 2 × n grid by attaching paths to some vertices. As a result the whole graph has pathwidth 3 · k 2 + 4.

Hardness on Grid Graphs
In this section, we show that for every constant ≥ 4, Full-ALPP is NP-complete on grid graphs. We first reduce Planar Circuit SAT to Full-ALPP on planar bipartite graphs of maximum degree at most 4. We then modify the instance by subdividing edges and adding terminal vertices in an appropriate way, and have an equivalent instance on grid graphs. The input of Circuit SAT is a Boolean circuit with a number of inputs and one output. The question is whether the circuit can output true by appropriately setting its inputs. Circuit SAT is NP-complete since CNF SAT [9] can be seen as a special case. When the underlying graph of the circuit is planar, the problem is called Planar Circuit SAT. Using planar crossover gadgets [27], we can show that Planar Circuit SAT is NP-complete. Furthermore, since NOR gates can replace other gates such as AND, OR, NOT, NAND, and XOR without introducing any new crossing, we can conclude that Planar Circuit SAT having NOR gates only is NP-complete.
Let I = (G, A, ) be an instance of Full-ALPP with G = (V , E). Let ψ be a mapping that assigns each e ∈ E an (A, )-path in G, and ψ(E) = {ψ(e) | e ∈ E}. We say that ψ is a guide to I if every set of |A|/2 vertex-disjoint (A, )-paths, if any exists, is a subset of ψ(E). When a guide is given additionally to an instance of Full-ALPP, we call the problem Guided Full-ALPP. Observe that a guide to an instance is not a restriction but just additional information.

Lemma 5.1 For every fixed ≥ 4, Guided Full-ALPP is NP-complete on planar bipartite graphs of maximum degree at most 4.
Proof Given a planar circuit with only NOR gates, we construct an equivalent instance of Guided Full-ALPP with the fixed . We only need input gadget, output gadget, split gadget, NOR gadget, and a way to connect the gadgets. See Fig. 6 for the high-level idea of the reduction.
The general ideas of our gadgets are as follows. The key ingredient is a cycle of length 2 p for some p in which every th vertex belongs to A. We call such a cycle a basic cycle. There are exactly two ways to pack p vertex-disjoint (A, )-paths into a basic cycle of length 2 p , and each of the packings corresponds to the true or false (c) (d) Fig. 8 The input gadgets. The black vertices belong to A and the white vertices belong to V \A signal passing through the corresponding part of the circuit. Our gadgets mostly consist of basic cycles and they intersect in such a way that an (A, )-path using an edge in a basic cycle cannot use any edge in another basic cycle. This can be guaranteed if two basic cycles intersect at a vertex whose distances from A in the two basic cycles are of different parities. In this way, the choice for one basic cycle propagates to other basic cycles. The NOR gadgets are little more complicated as they involve self-intersecting cycles, but the general idea is the same. We explicitly present the gadgets for the cases = 4 and = 5. For even (resp. odd) > 5, the gadgets can be obtained from the one for = 4 (resp. = 5) by subdividing /2 − 2 times each edge incident to a vertex in A.

Connections between gadgets
We first explain how the gadgets are connected. Each gadget has one or three pairs of vertices that are shared with other gadgets. We call them connection pairs. All those vertices belong to the terminal set A. In the figures, we draw each connection pair so that the two vertices are next to each other vertically and mark them with a dashed rectangle. If the (A, )-paths using the vertices of a connection pair are going to the positive direction, then we interpret it as that a true signal is sent via the connection pair. If the paths are going to the negative direction, then the connection pair is carrying a false signal. (See Fig. 7.) Note that our reduction below forces the paths at each connection pair to proceed in the same direction. Input gadgets The input gadget is simply a path of length 3 , where the endpoints form its unique connection pair. See Fig. 8. For a full (A, )-path packing, we only have two options. One corresponds to true input (Fig. 8c) and the other to false input (Fig. 8d).
Output gadgets The output gadget consists of two paths of length , where its unique connection pair includes one endpoint from each path. See Fig. 9. To have a full packing, the input to this gadget has to be true.

Split gadgets
To simulate the split of a wire depicted in Fig. 10, the split gadget consists of three paths of length 3 , each of which is identical to the input gadget, and a cycle of length 10 that synchronizes the three paths. See Fig. 11. To have a full (A, )-path packing, there are only two ways to pack (A, )-paths into a split gadget. Figure 12 shows the two ways: one on the left corresponds to a split of a true signal, and the other a split of a false signal.
NOR gadgets Recall that NOR stands for "NOT OR" and that the output y of a NOR gate is true if and only if both inputs x 1 and x 2 are false. The NOR gadgets are given in Fig. 13. The structure of the gadget is rather involved. It has three connection pairs, two for the inputs and one for the output, and the endpoints of each pair are connected by a path of length 5 . Additionally, there is a long self-intersecting cycle that somehow Guides The guide ψ(e) for each e ∈ E can be easily set from Figs. 8c, d, 9c, 12a, b, 14a-d. For each edge e, the unique gray bar that includes the edge represents the (A, )-path ψ(e).
Correctness The correctness of each gadget implies the correctness of the whole reduction. Thus, it suffices to show that the output of the reduction is planar bipartite graph of maximum degree at most 4. The resultant graph clearly has maximum degree 4 and is planar. To see that the graph is bipartite, consider a 2-coloring of a gadget, which is not the output gadget. If is even, then all vertices in the connection pairs have the same color. If is odd, then each upper vertex of a connection pair in the figures has the same color, and the other vertices in the connection pairs have the other color. Therefore, the entire graph is 2-colorable.  For each edge h of G e , we set ψ e (h) = ψ(h) if h is not contained in the path P ψ(e) of length 3 that corresponds to ψ(e). If h is contained in P ψ(e) , then we set ψ e (h) to the unique (A, )-path in P ψ(e) that contains h. Observe that ψ e is a guide to (G e , A e , ). Furthermore, (G, A, , ψ) and (G e , A e , , ψ e ) are equivalent (see Fig. 16): if ψ(e) is used in a full (A, )-path packing of G, then we use two (A, )-paths in P ψ(e) ; otherwise we use the middle (A, )-path in P ψ(e) connecting two new terminals. (G, A, , ψ) and (G e , A e , , ψ e ) are equivalent instances of Guided Full-ALPP. Now we are ready to prove the main theorem of this section.

Theorem 5.3 For every constant ≥ 4, Full-ALPP is NP-complete on grid graphs.
Proof We reduce Guided Full-ALPP on planar bipartite graphs of maximum degree at most 4 for fixed ≥ 4 (which is NP-complete by Lemma 5.1) to Full-ALPP on grid graphs for the same . Let (G, A, , ψ) be an instance of Guided Full-ALPP, where G = (V , E) is a planar bipartite graph of maximum degree at most 4.
A rectilinear embedding of a graph is a planar embedding into the Z 2 grid such that -each vertex is mapped to a grid point; -each edge {u, v} is mapped to a rectilinear path between u and v consisting of vertical and horizontal segments connecting grid points; -the rectilinear paths corresponding to two different edges may intersect only at their endpoints.
Every planar graph of maximum degree at most 4 has a rectilinear embedding, and a rectilinear embedding of area at most (n + 1) 2 can be computed in linear time [25], where n is the number of vertices. Let R 1 be a rectilinear embedding of G with area at most (n + 1) 2 . By multiplying each coordinate in the embedding by 2 , we obtain an enlarged rectilinear embedding R 2 of G. Let U be one color class of a 2-coloring of G. Now, for each v ∈ U , we locally modify R 2 around the grid point (x v , y v ) corresponding to v as illustrated in Fig. 17. We denote by R 3 the locally modified embedding.
From R 3 , we construct a new graph G and its rectilinear embedding R by inserting degree-2 vertices at each intersection point of a grid point and the inner part of a rectilinear path corresponding to an edge. Clearly, G is a grid graph. Let e ∈ E and λ e be the (geometric) length of the rectilinear path in R 1 corresponding to e. Then the rectilinear path in R 3 corresponding to e has length 2 · λ e + 1. Therefore, G is the graph obtained from G by subdividing each edge e, 2 · λ e times. By Observation 5.2, we can easily compute A and ψ such that (G, A, , ψ) is equivalent to (G , A , , ψ ). Finally, from the definition of a guide to an instance of Full-ALPP, (G , A , , ψ ) is equivalent to (G , A , ). As everything in this reduction can be done in time polynomial, the theorem holds. Fig. 18 The construction of G (right) from G (left) when = 3

Short A-Paths
As mentioned before, the positive results on ALPP presented so far can be translated to the ones on SAPP by the following lemma. To bound the treewidth of G , observe that G can be seen as a graph obtained from G by attaching triangles to edges, and then by subdividing some edges. Such operations preserve the treewidth unless G is a forest. (If G is a forest, then the treewidth increases by 1.) To see this, let {u, v} be the target edge of one of such operations. Let w be the new vertex introduced by the operation. Every tree decomposition T of the original graph has a bag B including both u and v since {u, v} is an edge of the original graph. We add to T a new bag B = {u, v, w} adjacent only to B. Clearly, the obtained decomposition is a tree decomposition of the graph obtained by the operation, and its width is the maximum of |B | − 1 and the width of T . Now assume that (G, A, k, ) is a yes instance of SAPP, and let P 1 , . . . , P k be vertex-disjoint A ≤ -paths in G. For each i ∈ [k], let i be the length of P i . We construct an (A, )-path P i in G from P i by replacing an arbitrary edge {u, v} in P i with its detour of length − i +1. Since P 1 , . . . , P k are vertex-disjoint and the detours are internally vertex-disjoint, the (A, )-paths P 1 , . . . , P k are vertex-disjoint.
Conversely, assume that (G , A, k, ) is a yes instance of ALPP, and let P 1 , . . . , P k be vertex-disjoint (A, )-paths in G . Note that each P i is a concatenation of some detours. We obtain an A ≤ -path P i in G by replacing all detours in P i with the original edges in G. Since P 1 , . . . , P k are vertex-disjoint and V (P i ) ⊆ V (P i ) for each i ∈ [k], the A ≤ -paths P 1 , . . . , P k are vertex-disjoint.

Corollary 6.5 SAPP parameterized by tw + is fixed-parameter tractable.
On the other hand, the negative results on ALPP cannot be directly translated to the one on SAPP. We here prove the hardness of the cases with constant |A| ≥ 4 or with constant ≥ 4. Note that SAPP with k = 1 (or |A| = 2) is polynomial-time solvable because it reduces to the all-pairs shortest path problem. We leave the complexity of SAPP parameterized by tw unsettled. Theorem 6.6 For every even constant α ≥ 4, Full-SAPP with |A| = α is NP-complete.
Proof Since the problem is clearly in NP, we present a reduction from the following NP-complete problem 2D1SP [13]. Given a graph G = (V , E) and two terminal pairs (s 1 , t 1 ) and (s 2 , t 2 ), the problem 2D1SP asks whether there exist two vertex-disjoint paths P 1 from s 1 to t 1 and P 2 from s 2 to t 2 , where P 1 is asked to be a shortest s 1 -t 1 path in G. We reduce 2D1SP to Full-SAPP with |A| = 4. (We can extend this to any even α = |A| by adding dummy components.) Let n = |V | and = 5n − 1. Let 1 be the shortest path distance between s 1 and t 1 in G. We add four vertices s 1 , t 1 , s 2 , and t 2 to G. We add a path of length 3n between s 1 and s 1 , a path of length 2n − 1 − 1 between t 1 and t 1 , a path of length 2n between s 2 and s 2 , and a path of length 2n between t 2 and t 2 . We call the obtained graph G and set A = {s 1 , t 1 , s 2 , t 2 }.
Assume that G has a shortest s 1 -t 1 path P 1 and a (not necessarily shortest) s 2 -t 2 path P 2 vertex-disjoint from P 1 . For each i ∈ {1, 2}, we extend P i to a path P i between s i and t i by adding the unique paths between s i to s i an t i to t i . The length of P 1 is 3n + 1 + (2n − 1 − 1) = and the length of P 2 is 2n + P 2 + 2n ≤ , where P 2 is the length of P 2 .
Conversely, assume that G has two vertex-disjoint A ≤ -paths P 1 and P 2 . Without loss of generality, we can assume that one of the endpoints of P 1 is s 1 . Then we can see that the other endpoint of P 1 is t 1 since the distance between s 1 and the vertices s 2 and t 2 is at least 3n + 2n > . Let P 1 be the subpath of P 1 that connects s 1 and t 1 . Now the length of the A ≤ -path P 1 is 3n + P 1 + (2n − 1 − 1) ≤ , and thus P 1 ≤ 1 . Hence P 1 is a shortest path between s 1 and t 1 in G. Let P 2 be the subpath of P 2 that connects s 2 and t 2 . Since P 1 and P 2 are vertex-disjoint, so are P 1 and P 2 .

Theorem 6.7 For every constant ≥ 4, Full-SAPP is NP-complete.
Proof We show the NP-hardness of Full-SAPP with constant ≥ 4 by a reduction from a variant of 3-Sat with the following restrictions: (1) each clause is a disjunction of two or three literals, and (2) each variable occurs exactly twice as a positive literal and exactly once as a negative literal. We call this variant 3-Sat(2, 1). It is known that 3-Sat(2, 1) is NP-complete [16].
Let (U , C) be an instance of 3-Sat(2, 1) with the variables U = {u 1 , . . . , u n } and the clauses C = {C 1 , . . . , C m }. If the positive literal of u i appears in C p and C q with p < q, then we say that the first occurrence of u i is in C p and the second is in C q .
For each i ∈ [n], we construct the variable gadget for u i as follows (see Fig. 19 (left)). Take three paths of length from s 1 i to t 1 i , from s 2 i to t 2 i , and from s i to t i . We to t 1 , from s 2 i to t 1 i , and from s i to t 2 i . We call these paths slanted. For j ∈ {1, 2}, we call the vertex of distance 2 from t j i on the corresponding vertical path x j i . We call the vertex of distance 2 from t i on the corresponding slanted path x i .
For each C ∈ C, we construct the clause gadget for C as follows (see Fig. 19 (right)). Assume that C includes c literals. Take two vertices s C and t C and then add c internally disjoint paths of length between s C and t C . We bijectively map the neighbors of t C to the literals in C. For each neighbor v of t C , if v is mapped to the jth positive occurrence of u i , then we identify v with x j i in the variable gadget for u i . Similarly, if v is mapped to the negative occurrence of u i , then we identify v with x i .
We call the constructed graph G and set This completes the construction. We show that (U , C) is a yes instance of 3-Sat(2, 1) if and only if (G, A, |A|/2, ) is a yes instance of Full-SAPP.
To show the only-if direction, assume that there is a truth assignment to the variables in U that satisfies C. For each variable u i ∈ U , if u i is set to be true, then we take the slanted paths in the variable gadget for u i ; otherwise, we take the vertical paths. Since the variable gadgets are vertex-disjoint, the paths taken so far are vertex-disjoint. Then for each clause C ∈ C, let l be a literal in C that set to be true. Observe that the neighbor, say v l , of t C mapped to l is not used in the paths selected in the variable gadgets. Thus we can take the s C -t C path passing through v l . Since all paths selected have length and all vertices in A are used as endpoints of the selected path, (G, A, |A|/2, ) is a yes instance of Full-SAPP.
To prove the if direction, assume that there is a set of |A|/2 vertex-disjoint A -paths P in G. First observe that for each C ∈ C, t C is the only vertex distance at most from s C : for each neighbor v of t C , the distance from s C to v is − 1, and the distance from v to any vertex in A\{s C , t C } is at least min{2, − 2} ≥ 2. Thus, for each C ∈ C, there is a path in P that has s C and t C as its endpoints. Next we claim that for each variable u i ∈ U , either all vertical paths or all slanted paths in the variable gadget for u i are selected into P. To see this, observe that is the set of vertices in A\{s C , t C | C ∈ C} that are distance at most from s 1 i (resp. s 2 i , s i ). Therefore, if we pick a vertical (resp. slanted) path in a variable gadget, then we have to take all vertical (resp. slanted) paths in that variable gadget. We now construct a truth assignment to U by setting u i true if and only if P includes the slanted paths in the variable gadget for u i . For C ∈ C, let P ∈ P be the path connecting s C and t C . Let l be the literal in C corresponding to the neighbor of t C on P. If l is a positive literal of a variable u i , then P includes the slanted paths in the variable gadget for u i , and thus u i is set to be true. If l is a negative literal of u i , then P includes the vertical paths in the variable gadget for u i , and thus u i is set to be false. In both cases, l is true and C is satisfied.

Concluding Remarks
In this paper, we have introduced a new problem (A, )-Path Packing (ALPP) and showed tight complexity results. One possible future direction would be the parameterization by clique-width cw, a generalization of treewidth (see [19]). In particular, we ask the following two questions.
-Does ALPP admit an algorithm of running time O(n cw )? -Is ALPP fixed-parameter tractable parameterized by cw + ?
We also considered a variant of the problem which we call A ≤ -Path Packing (SAPP). We showed that results similar to the ones on ALPP hold also on SAPP, but we were not able to determine the complexity parameterized by treewidth. We left the following question on SAPP.
Another interesting direction on ALPP (and on SAPP) would be a systematic study on restricted graph classes. A special case of ALPP have been studied on important graph classes as the 2-fixed-endpoint Hamiltonian path problem (2HP), where we are given two vertices s and t and asked whether there is a Hamiltonian path from s to t. Clearly, 2HP is equivalent to ALPP with A = {s, t} and = n − 1. The complexity of 2HP on interval graphs was asked in 1993 [12] and is still open (see [24]). It is known that 2HP is polynomial-time solvable on proper interval graphs [3]. It is natural to expect that with its full generality, ALPP would be intractable on those graph classes. by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

A Proof of Lemma 2.1
In this section, we prove Lemma 2.1 stating that: if G is a graph obtained from a graph G = (V , E) by subdividing a set of edges F ⊆ E an arbitrary number of times, and attaching a path of arbitrary length to each vertex in a set U ⊆ V , then pw(G ) ≤ pw(G) + 2.
To this end, we use a characterization of pathwidth in terms of the following search game. We are given a graph G = (V , E) with all edges contaminated. The goal in this game is to clear all edges. In each turn, we can place a searcher on a vertex or remove a searcher from a vertex. An edge is cleared by having searchers on both endpoints. A cleared edge is immediately recontaminated when a removal of a searcher results in a path not passing through any searchers from the edge to a contaminated edge. The minimum number of searchers needed to clear all edges of G is the node search number, and we denote it by ns(G). It is known that ns(G) = pw(G) + 1 for every graph G [5,14,22]. Proof Let p = pw(G) + 1. Since ns(G) ≤ p, there is a sequence S of placements and deletions of searchers to clear all edges of G using at most p searchers. To clear all edges of G , we extend S as follows. For each placement of a searcher on a vertex v ∈ V , we insert, right after this placement, a subsequence that clears all paths corresponding to the edges between v and its neighbors having searchers on them at this point. This can be done with two extra searchers that clear the paths one-by-one. The extra searchers are deleted in the end of the subsequence, and thus we only need two extra searchers in total. This implies that pw(G ) = ns(G ) − 1 ≤ ns(G) + 1 = pw(G) + 2.
Lemma A.2 (Folklore) If G is a graph obtained from a graph G = (V , E) by attaching a path of arbitrary length to each vertex in a set U ⊆ V , then pw(G ) ≤ pw(G)+1.
Proof We assume that E = ∅ since otherwise the statement is clearly true. There is a sequence S of placements and deletions of searchers to clear all edges of G using at most p = pw(G) + 1 searchers. To clear all edges of G , we extend S as follows. Using two searchers, we first clear the paths attached to the isolated vertices in U (if such exist). We then replace each placement of a searcher on a non-isolated vertex u ∈ U with a subsequence that clears the path P = (u, p 1 , p 2 , . . . , p q ) attached to u. This can be done with two searchers by first placing a searcher on p q , then placing a searcher on p q−1 , deleting a searcher on p q , placing a searcher on p q−2 , and so on. At the end of the subsequence, u has a searcher on it and all other vertices in P do not have searchers. We need only one extra searcher in total. Hence, pw(G ) = ns(G ) − 1 ≤ ns(G) = pw(G) + 1.
In the proofs of Lemmas A.1 and A.2, we show that search sequences for the original graph can be "locally" extended for the new graph by using one or two temporal searchers. Thus we obtain Lemma 2.1 as the combined version of the lemmas.