2012 ACM Subject Classification Theory of computation → Parameterized complexity and exact algorithms; Mathematics of computing → Graph algorithms
Keywords and phrases linear layouts, stack layouts, queue layouts, parameterized complexity, fair allocation
Funding Thomas Depian: Supported by the Vienna Science and Technology Fund (WWTF) [10.47379/ICT22029]. Martin Nöllenburg: Supported by the Vienna Science and Technology Fund (WWTF) [10.47379/ICT22029].
Acknowledgements The authors acknowledge the use of AI tools (in particular Claude Opus 5.5) for proofreading the pre-final version of this submission and identifying some additional related literature. No such tools were used for obtaining the results and the writeup of the pre-final version. The authors assume full responsibility for the submission.
Introduction
A linear layout ⟨ ≺ , σ ⟩ \langle\prec, \sigma\rangle ⟨ ≺ , σ ⟩ of a graph G G G consists of a total order ≺ \prec ≺ of its vertices and a partition σ \sigma σ of its edges into pages, such that edges on the same page avoid specified patterns with respect to ≺ \prec ≺ . Over the last four decades, linear layouts have been a central research topic in graph drawing and topological graph theory. Two prominent examples are stack layouts and queue layouts , in which no two independent edges on the same page are allowed to cross or nest, respectively. These names reflect the data structures used to store the edges of each page during a left-to-right sweep of ≺ \prec ≺ : upon reaching a vertex v v v , edges whose right endpoint is v v v are removed from the corresponding stack or queue, after which edges whose left endpoint is v v v are inserted. With suitable ordering of the operations at each vertex, these accesses follow a last-in-first-out or first-in-first-out discipline, respectively.
Motivated by applications in VLSI design [13 , 46 ] , permutation sorting [44 , 48 ] , compact graph encodings [32 , 43 ] , RNA folding [27 ] , and traffic-light control [35 ] , stack and queue layouts have been extensively studied from both algorithmic and structural perspectives. Research has addressed their computational complexity [11 , 12 , 17 , 25 , 29 ] , their connections to planarity [1 , 7 , 19 ] , and their relationships with other graph properties and parameters [50 , 51 ] .
Several variants extend this framework by imposing additional constraints or modifying the permitted edge patterns. Merker and Ueckerdt [41 , 42 ] introduced the local stack (queue) number of a graph G G G , defined as the minimum ℓ \ell ℓ such that G G G admits a stack (queue) layout in which the edges incident to each vertex belong to at most ℓ \ell ℓ pages. Alam et al. [2 ] studied dispersable layouts, which require the edges on each page to form a matching. Other works have explored layouts that mix different data structures or use alternative ones to organize the edges on each page (see, e.g., [3 , 8 , 18 , 28 , 36 ] ). More recently, Förster et al. [22 ] introduced the weighted book thickness of a graph, defined as the minimum average page index of its edges over all stack layouts. Bekos et al. [6 ] studied a relaxation that permits a bounded number of otherwise forbidden patterns within each page.
Capacitated Linear Layouts. In this paper, we introduce capacitated linear layouts , a generalization of stack and queue layouts in which each edge of the input graph G G G is assigned one of χ \chi χ colors, and each page has a separate budget for each color. The goal is to find a stack or queue layout using at most ℓ \ell ℓ pages, subject to the constraint that, on each page, the number of edges of each color does not exceed the corresponding budget. The classical notions of stack and queue layouts are recovered by setting χ = 1 \chi= 1 χ = 1 and assigning every page a budget of ∣ E ( G ) ∣ |E(G)| ∣ E ( G ) ∣ ; see Figure 1 for an illustrating example.
Figure 1. (a) An edge-colored graph G G G and a (b) 2-page stack and (c) 2-page queue layout of G G G . Observe that there is no 2-page stack layout of G G G with spine order ≺ 1 \prec_1 ≺ 1 where the two blue edges are on different pages.
Motivating Examples. In partitioned book embeddings , the assignment of edges to pages is part of the input [4 , 40 ] . These can be seen as a special case of capacitated linear layouts, where edges assigned to page p p p receive color p p p , and the budget of page p p p is ∣ E ( G ) ∣ |E(G)| ∣ E ( G ) ∣ for color p p p and 0 for every other color. When colors encode different types of elements—for example, in signed graphs with positive and negative relations among social media users [38 ] —capacitated linear layouts can model fair allocation problems, with suitable budgets specifying the share of each type assigned to each page. Moreover, edge colors can distinguish job classes or customers, and per-color page budgets constrain the number of jobs of each class assigned to each buffer, similar to the scheduling problem considered by Das and Wiese [15 ] . In graph visualization, users may focus their attention on the first few pages, motivating layouts that distribute edges of each color evenly across pages to ensure that edges from every color appear
among the first pages (see [21 ] for related fairness-aware formulations in graph drawing). Finally, fairness constraints have also been studied in other graph problems, including graph clustering [23 ] and graph bisection [31 ] .
Contributions. We study the computational complexity of capacitated linear layouts from a parameterized perspective. Deciding whether a graph admits a 1-page queue layout or a 2-page stack layout is already NP-complete [9 , 29 , 52 ] . These hardness results carry over to our model, implying paraNP-hardness with respect to the number of pages, the number of colors, and their combination. We, therefore, focus on the fixed-order setting in which the vertex order ≺ \prec ≺ is given as part of the input and must be preserved. This restriction is consistent with many of the above-discussed motivating applications and indeed is well studied in the literature on stack and queue layouts [10 , 11 , 20 , 29 , 39 , 49 ] . In particular, when ≺ \prec ≺ is fixed, deciding if a graph admits an ℓ \ell ℓ -page queue layout can be done in polynomial time for any ℓ > 0 \ell> 0 ℓ > 0 [29 ] . For stack layouts the problem is tractable for ℓ ≤ 2 \ell\le2 ℓ ≤ 2 , while it is NP-hard for ℓ ≥ 4 \ell\ge4 ℓ ≥ 4 pages [49 ] and open for three pages [5 , 47 ] . We formalize the following problems.
Fixed Order Capacitated Stack (Queue) Layout [short FoCapSL (FoCapQL)]
Given A graph G = ( V , E ) G = (V, E) G = ( V , E ) , an edge coloring function δ : E → [ χ ] \delta: E \to[\chi] δ : E → [ χ ] on χ \chi χ colors, a linear order ≺ \prec ≺ on V V V , an integer ℓ ∈ N \ell\in\mathbb{N} ℓ ∈ N , and budgets b p : [ χ ] → N 0 b_p : [\chi] \to\mathbb{N}_0 b p : [ χ ] → N 0 for every page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] .
Question Does there exist an ℓ \ell ℓ -page stack (queue) layout ⟨ ≺ , σ ⟩ \langle\prec, \sigma\rangle ⟨ ≺ , σ ⟩ of G G G such that ∣ { e ∈ E ∣ δ ( e ) = c , σ ( e ) = p } ∣ ≤ b p ( c ) |\{e \in E \mid\delta(e) = c, \sigma(e) = p\}| \le b_p(c) ∣ { e ∈ E ∣ δ ( e ) = c , σ ( e ) = p } ∣ ≤ b p ( c ) for every page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] and color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] ?
Since we mainly consider ℓ = 2 \ell= 2 ℓ = 2 pages for FoCapSL, we call the corresponding restricted variant Fixed Order Capacitated 2-Page Stack Layout (FoCap2PSL for short). We note that our problem parallels previous studies of bounded vertex colorings, where each color can be used at most b b b times, for some value of b b b ; see, e.g., the work by Jansen [33 ] . In our setting, the graph to color would be the edge conflict graph with respect to the linear order ≺ \prec ≺ and the number of allowed colors is the number of pages ℓ \ell ℓ . However, recall that we have, on the one hand, an edge-colored graph G G G and we can observe, on the other hand, that known hardness results for bounded vertex colorings for constant b b b require an unbounded number of colors, i.e., pages. In contrast, when adding edge colors we show that, despite ≺ \prec ≺ being fixed, both problems are NP-complete already for two pages ( ℓ = 2 ) (\ell= 2) ( ℓ = 2 ) , which clearly separates the complexity of the problems with and without page capacities unless P = N P \mathrm{P} = \mathrm{NP} P = NP . Furthermore, we study the complexity of the problems when parameterized by the number of pages, colors, and/or the structure of the edge conflict graph. We summarize our results in Figure 2.
Preliminaries
For an integer ℓ ≥ 1 \ell\ge1 ℓ ≥ 1 , we let [ ℓ ] [\ell] [ ℓ ] denote the set { 1 , 2 , … , ℓ } \{1, 2, \ldots, \ell\} { 1 , 2 , … , ℓ } and define [ ℓ ] 0 : = [ ℓ ] ∪ { 0 } [\ell]_0 := [\ell] \cup\{0\} [ ℓ ] 0 := [ ℓ ] ∪ { 0 } . Let G = ( V , E ) G = (V, E) G = ( V , E ) be a simple and undirected graph. We let C ( G ) \mathcal{C}(G) C ( G ) denote the set of connected components of G G G . Let ≺ \prec ≺ be a linear order of the vertices V V V . We say that two edges u v , x y ∈ E uv, xy \in E uv , x y ∈ E with u ≺ v u \prec v u ≺ v , x ≺ y x \prec y x ≺ y , and u ≺ x u \prec x u ≺ x cross under ≺ \prec ≺ if u ≺ x ≺ v ≺ y u \prec x \prec v \prec y u ≺ x ≺ v ≺ y and they nest under ≺ \prec ≺ if u ≺ x ≺ y ≺ v u \prec x \prec y \prec v u ≺ x ≺ y ≺ v . For a given integer ℓ \ell ℓ , let σ : E → [ ℓ ] \sigma: E \to[\ell] σ : E → [ ℓ ] be a function that assigns each edge to one of ℓ \ell ℓ pages. We call the linear layout ⟨ ≺ , σ ⟩ \langle\prec, \sigma\rangle ⟨ ≺ , σ ⟩ a stack (queue) layout if there are no two edges u v , x y ∈ E uv, xy \in E uv , x y ∈ E with σ ( u v ) = σ ( x y ) \sigma(uv) = \sigma(xy) σ ( uv ) = σ ( x y ) that cross (nest) under ≺ \prec ≺ . In this case, we also refer to ≺ \prec ≺ as the spine order and to σ \sigma σ as the page assignment of ⟨ ≺ , σ ⟩ \langle\prec, \sigma\rangle ⟨ ≺ , σ ⟩ . The conflict graph S ( G , ≺ ) = ( E , F ) \mathcal{S}(G, \prec) = (E, F) S ( G , ≺ ) = ( E , F ) of G G G and ≺ \prec ≺ for stack layouts contains one vertex for every edge e ∈ E e \in E e ∈ E . Two edges e 1 , e 2 ∈ E e_1, e_2 \in E e 1 , e 2 ∈ E are adjacent in S ( G , ≺ ) \mathcal{S}(G, \prec) S ( G , ≺ ) if and only if e 1 e_1 e 1 and e 2 e_2 e 2 cross under ≺ \prec ≺ ; see
Figure 3 for an example. We write S \mathcal{S} S if G G G and ≺ \prec ≺ are clear from the context and define the conflict graph Q ( G , ≺ ) \mathcal{Q}(G,\prec) Q ( G , ≺ ) for queue layouts analogously with conflicts defined by nesting edges. Observe that there is a one-to-one correspondence between page assignments of ℓ \ell ℓ -page stack (queue) layouts ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ and proper ℓ \ell ℓ -vertex colorings of the conflict graph.
Figure 3. (a) An example graph G G G and (b) its conflict graph S \mathcal{S} S for the spine order a ≺ b ≺ c ≺ d ≺ e a \prec b \prec c \prec d \prec e a ≺ b ≺ c ≺ d ≺ e . Since S \mathcal{S} S is bipartite, there exists a 2-page stack layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ .
For a graph G = ( V , E ) G = (V,E) G = ( V , E ) , let δ : E → [ χ ] \delta: E \to[\chi] δ : E → [ χ ] be a function that assigns each edge e ∈ E e \in E e ∈ E one of χ ≤ m \chi\le m χ ≤ m colors. We call G = ( V , E , δ ) G = (V,E,\delta) G = ( V , E , δ ) an edge-colored graph. For an instance I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) \mathcal{I} = (G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) of FoCapPSL (FoCapQL), we define n : = ∣ V ∣ n := |V| n := ∣ V ∣ , m : = ∣ E ∣ m := |E| m := ∣ E ∣ , χ \chi χ to be the number of colors, λ : = ∣ C ( H ) ∣ \lambda:= |\mathcal{C}(\mathcal{H})| λ := ∣ C ( H ) ∣ , and γ : = max { ∣ V ( C ) ∣ ∣ C ∈ C ( H ) } \gamma:= \max\{|V(C)| \mid C \in\mathcal{C}(\mathcal{H})\} γ := max { ∣ V ( C ) ∣ ∣ C ∈ C ( H )} , where H \mathcal{H} H denotes the corresponding conflict graph for stack (queue) layouts. Moreover, we call b p ( c ) b_p(c) b p ( c ) the budget of color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] on page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] . We say that the instance I \mathcal{I} I is balanced if b p ( c ) = b q ( c ) b_p(c) = b_q(c) b p ( c ) = b q ( c ) holds for every two pages p , q ∈ [ ℓ ] p,q \in[\ell] p , q ∈ [ ℓ ] and color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] . It is tight if ∑ p ∈ [ ℓ ] , c ∈ [ χ ] b p ( c ) = m \sum_{p\in[\ell],c\in[\chi]} b_p(c) = m ∑ p ∈ [ ℓ ] , c ∈ [ χ ] b p ( c ) = m , i.e., the sum over all budgets equals the number of edges. A stack (queue) layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ which respects the budget constraints imposed by I \mathcal{I} I is called admissible and constitutes a solution to I \mathcal{I} I .1
Fixed Order 2-Page Stack Layouts
We start our investigation of capacitated linear layouts by considering 2-page stack layouts. As already noted in earlier work [11 ] , for a fixed spine order ≺ \prec ≺ , a graph G G G has a 2-page stack layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ if and only if the conflict graph S ( G , ≺ ) S(G,\prec) S ( G , ≺ ) is bipartite. When pages have capacities, the situation becomes more intricate. In particular, in the upcoming sections we will uncover an interplay between the structure of S S S and the number of colors χ \chi χ .
Parameterizing by the Number of Connected Components of S S S
Let I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I}=(G,\delta,\prec,\ell=2,b_1,b_2) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) be an instance of FoCap2PSL. As our first parameter, we consider the number λ \lambda λ of connected components in S S S . As a “warm-up” exercise, we present a fixed-parameter algorithm in λ \lambda λ . Later, in § 3.2 , we justify this parameter choice by establishing NP-hardness for unbounded λ \lambda λ .
Theorem 1. Fixed Order Capacitated 2-Page Stack Layout can be solved constructively in O ( 2 λ ⋅ ( n + χ ) + n 2 ) O(2^\lambda\cdot(n+\chi)+n^2) O ( 2 λ ⋅ ( n + χ ) + n 2 ) time (which is FPT in λ = ∣ C ( S ( G , ≺ ) ) ∣ \lambda=|\mathcal{C}(S(G,\prec))| λ = ∣ C ( S ( G , ≺ )) ∣ ).
Proof. Let I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I}=(G,\delta,\prec,\ell=2,b_1,b_2) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) be an instance of FoCap2PSL. Observe that G G G must be planar to admit a 2-page stack layout, which we can check in O ( n ) O(n) O ( n ) time [30 ] . Thus, for the remainder of the proof we use the fact that m ∈ O ( n ) m\in O(n) m ∈ O ( n ) holds for any positive instance; instances where G G G is not planar are rejected.
We first compute, in O ( n 2 ) O(n^2) O ( n 2 ) time, the conflict graph S S S and check if it is bipartite; if not, we reject I \mathcal{I} I as this is a necessary condition to admit a solution. Let C 1 , … , C λ C_1,\ldots,C_\lambda C 1 , … , C λ be the connected components of S S S . Consider a connected component C i = ( E i , F i ) C_i=(E_i,F_i) C i = ( E i , F i ) , i ∈ [ λ ] i\in[\lambda] i ∈ [ λ ] . Its bipartition into E i 1 E_i^1 E i 1 and E i 2 E_i^2 E i 2 is unique and encodes two possible page assignments for the edges of G G G contained in C i C_i C i : Either σ ( e ) = 1 \sigma(e)=1 σ ( e ) = 1 if e ∈ E i 1 e\in E_i^1 e ∈ E i 1 and σ ( e ) = 2 \sigma(e)=2 σ ( e ) = 2 if e ∈ E i 2 e\in E_i^2 e ∈ E i 2 or vice-versa. Note that this choice is independent of the choice made for other connected components C j C_j C j , j ∈ [ λ ] j\in[\lambda] j ∈ [ λ ] , i ≠ j i\ne j i = j . Thus, we can branch on all 2 λ 2^\lambda 2 λ possible page assignments for the edges of G G G . Each branch corresponds to a 2-page stack layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ , and we can check in O ( n + χ ) O(n+\chi) O ( n + χ ) time if it is admissible. The instance I \mathcal{I} I admits a solution if and only if one branch corresponds to an admissible layout. The running time follows by combining all steps. ◀
Hardness for Many Constant-Sized Components in S S S
In this section, we justify the use of λ = ∣ C ( S ) ∣ \lambda=|\mathcal{C}(S)| λ = ∣ C ( S ) ∣ as parameter by establishing NP-completeness of FoCap2PSL for unbounded λ \lambda λ . Furthermore, our reduction shows that the problem remains NP-complete even when every connected component of S S S has constant size. To this end, we reduce from Monotone Not All Equal 3Sat-E4, a 3-Sat variant that remains NP-complete [14 ] . The input to this problem is a formula φ \varphi φ over variables X X X with clause set C C C such that each clause c ∈ C c\in C c ∈ C consists of exactly three distinct positive literals and every variable x ∈ X x\in X x ∈ X appears in exactly four clauses. The question is whether there exists a truth assignment Ψ : X → { 0 , 1 } \Psi:X\to\{0,1\} Ψ : X → { 0 , 1 } such that every clause contains two variables with different truth assignments, i.e., one that is assigned to true and one that is assigned to false.
Overview of the Reduction. The high-level idea of our reduction is as follows. We construct an instance I \mathcal{I} I where we introduce for every variable x ∈ X x\in X x ∈ X eight edges of a unique color col ( x ) \operatorname{col}(x) col ( x ) . Four of these edges are placed in the gadget for the variable x x x . These edges are forced to be placed on the same page and will encode the truth assignment Ψ ( x ) \Psi(x) Ψ ( x ) .
Each of the remaining four edges is part of a clause gadget for a clause c ∈ C c\in C c ∈ C with x ∈ c x\in c x ∈ c ; recall that x x x appears in exactly four clauses. The variable gadget enforces four of eight edges to be on the same page. We can set the budget for col ( x ) \operatorname{col}(x) col ( x ) such that the four remaining edges must be on the same page independent of their location along the spine. This allows us to transport the variable assignment from the variable gadgets into the clause gadgets. Finally, the gadget for every clause c ∈ C c\in C c ∈ C also contains four disjoint edges of a unique color col ( c ) \operatorname{col}(c) col ( c ) . Three of these edges are in conflict with the edges for the variables, each of them with an edge of a different variable x ∈ c x\in c x ∈ c . The last edge has no conflict. By setting the budget of col ( c ) \operatorname{col}(c) col ( c ) accordingly, we can ensure that at most two variable-edges in the clause are on the same page, i.e., for every clause c c c there is one variable set to true and one to false. In the following, we describe the gadgets in detail.
Variable Gadget. Let x ∈ X x\in X x ∈ X be a variable of φ \varphi φ . The variable gadget for x x x consists of a selecting edge s x t x s_xt_x s x t x and a dummy edge u x v x u_xv_x u x v x . Moreover, it consists of four variable edges a x i b x i a_x^ib_x^i a x i b x i , i = 1 , 2 , 3 , 4 i=1,2,3,4 i = 1 , 2 , 3 , 4 . The order of the endpoints of these edges is u x ≺ v x ≺ s x ≺ a x ≺ t x ≺ b x 1 ≺ b x 2 ≺ b x 3 ≺ b x 4 u_x\prec v_x\prec s_x\prec a_x\prec t_x\prec b_x^1\prec b_x^2\prec b_x^3\prec b_x^4 u x ≺ v x ≺ s x ≺ a x ≺ t x ≺ b x 1 ≺ b x 2 ≺ b x 3 ≺ b x 4 ; see also Figure 4 a. All edges of the form a x i b x i a_x^ib_x^i a x i b x i , i = 1 , 2 , 3 , 4 i=1,2,3,4 i = 1 , 2 , 3 , 4 , receive the same color col ( x ) \operatorname{col}(x) col ( x ) . The two other edges receive the same color which is different from col ( x ) \operatorname{col}(x) col ( x ) , i.e., δ ( s x t x ) = δ ( u x v x ) = d x ≠ col ( x ) \delta(s_xt_x)=\delta(u_xv_x)=d_x\ne\operatorname{col}(x) δ ( s x t x ) = δ ( u x v x ) = d x = col ( x ) . We distribute the budget for the colors on the pages as follows. For color d x d_x d x , we set b 1 ( d x ) = b 2 ( d x ) = 1 b_1(d_x)=b_2(d_x)=1 b 1 ( d x ) = b 2 ( d x ) = 1 , and for color col ( x ) \operatorname{col}(x) col ( x ) , we set b 1 ( col ( x ) ) = b 2 ( col ( x ) ) = 4 b_1(\operatorname{col}(x))=b_2(\operatorname{col}(x))=4 b 1 ( col ( x )) = b 2 ( col ( x )) = 4 . The edges s x t x s_xt_x s x t x and u x v x u_xv_x u x v x will be the only two edges of color d x d_x d x . Together with their placement with respect to the variable edges, we can make the following observation; recall also Figure 4 a.
Figure 4. Gadgets representing (a) the variable x x x in its true state and (b) the clause c = ( x ∨ y ∨ z ) c=(x\vee y\vee z) c = ( x ∨ y ∨ z ) where x x x and z z z are set to true and y y y to false in the reduction for Theorem 4.
Observation 2. In every admissible 2-page stack layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ of the variable gadget for a variable x ∈ X x\in X x ∈ X we have σ ( s x t x ) ≠ σ ( u x v x ) = σ ( a x i b x i ) \sigma(s_xt_x)\ne\sigma(u_xv_x)=\sigma(a_x^ib_x^i) σ ( s x t x ) = σ ( u x v x ) = σ ( a x i b x i ) for every $i=1,2,3,4.
Clause Gadget. Let c ∈ C c\in C c ∈ C be a clause of φ \varphi φ . Since φ \varphi φ is monotone, we have that c = ( x ∨ y ∨ z ) c=(x\vee y\vee z) c = ( x ∨ y ∨ z ) for some x , y , z ∈ X x,y,z\in X x , y , z ∈ X . The clause gadget for c c c consists of three literal edges a x c b x c a_x^cb_x^c a x c b x c , a y c b y c a_y^cb_y^c a y c b y c , and a z c b z c a_z^cb_z^c a z c b z c . Moreover, it contains four validator edges u x c v x c u_x^cv_x^c u x c v x c , u y c v y c u_y^cv_y^c u y c v y c , u z c v z c u_z^cv_z^c u z c v z c , and u C v C u^\mathsf{C}v^\mathsf{C} u C v C . We use the order u q c ≺ a q c ≺ v q c ≺ b q c u_q^c\prec a_q^c\prec v_q^c\prec b_q^c u q c ≺ a q c ≺ v q c ≺ b q c among the endpoints of the literal and validator edge corresponding to the literal q ∈ { x , y , z } q\in\{x,y,z\} q ∈ { x , y , z } . In the end, we concatenate the respective total orders and append u C ≺ v C u^\mathsf{C}\prec v^\mathsf{C} u C ≺ v C ; see Figure 4 b. We re-use the color of a variable for its corresponding literal edge. More formally, we have δ ( a q c b q c ) = col ( q ) \delta(a_q^cb_q^c)=\operatorname{col}(q) δ ( a q c b q c ) = col ( q ) for q ∈ { x , y , z } q\in\{x,y,z\} q ∈ { x , y , z } . Moreover, we color the validator edges in a unique color col ( c ) \operatorname{col}(c) col ( c ) , i.e., δ ( u q c v q c ) = col ( c ) \delta(u_q^cv_q^c)=\operatorname{col}(c) δ ( u q c v q c ) = col ( c ) , for q ∈ { x , y , z , T } q\in\{x,y,z,\mathsf{T}\} q ∈ { x , y , z , T } , and set the budget b 1 ( col ( c ) ) = b 2 ( col ( c ) ) = 2 b_1(\operatorname{col}(c))=b_2(\operatorname{col}(c))=2 b 1 ( col ( c )) = b 2 ( col ( c )) = 2 . The budget constraint together with the relative placement of these edges allows us to establish the following lemma, which will play a central role when establishing correctness of the reduction.
Lemma 3. Let ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ be an admissible 2-page stack layout of the constructed instance that contains the clause gadget for a clause c ∈ C c\in C c ∈ C with c = ( x ∨ y ∨ z ) c=(x\vee y\vee z) c = ( x ∨ y ∨ z ) . We have $\sigma(a_q^cb_q^c)=\sigma(s_qt_q)
for every q ∈ { x , y , z } q \in\{x,y,z\} q ∈ { x , y , z } . Moreover, there exist two literals p , q ∈ { x , y , z } p,q \in\{x,y,z\} p , q ∈ { x , y , z } such that σ ( a p c b p c ) ≠ σ ( a q c b q c ) \sigma(a_{p}^{c}b_{p}^{c}) \ne\sigma(a_{q}^{c}b_{q}^{c}) σ ( a p c b p c ) = σ ( a q c b q c ) .
Proof. Let c ∈ C c \in C c ∈ C be a clause of φ \varphi φ with c = ( x ∨ y ∨ z ) c = (x \lor y \lor z) c = ( x ∨ y ∨ z ) . For the first statement, assume for the sake of a contradiction that there exists a q ∈ { x , y , z } q \in\{x,y,z\} q ∈ { x , y , z } such that σ ( a q c b q c ) ≠ σ ( s q t q ) \sigma(a_{q}^{c}b_{q}^{c}) \ne\sigma(s_{q}t_{q}) σ ( a q c b q c ) = σ ( s q t q ) . By Observation 2, we have that σ ( a q b q i ) ≠ σ ( s q t q ) \sigma(a_{q}b_{q}^{i}) \ne\sigma(s_{q}t_{q}) σ ( a q b q i ) = σ ( s q t q ) for every i = 1 , 2 , 3 , 4 i = 1,2,3,4 i = 1 , 2 , 3 , 4 . Thus, there are at least five edges of color col ( q ) \operatorname{col}(q) col ( q ) on the same page σ ( a q c b q c ) \sigma(a_{q}^{c}b_{q}^{c}) σ ( a q c b q c ) . However, we have b 1 ( col ( q ) ) = b 2 ( col ( q ) ) = 4 b_{1}(\operatorname{col}(q)) = b_{2}(\operatorname{col}(q)) = 4 b 1 ( col ( q )) = b 2 ( col ( q )) = 4 . Consequently, ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ cannot be an admissible solution.
To show that also the second statement is true, assume for the sake of a contradiction that there exists an admissible 2-page stack layout with σ ( a x c b x c ) = σ ( a y c b y c ) = σ ( a z c b z c ) \sigma(a_{x}^{c}b_{x}^{c}) = \sigma(a_{y}^{c}b_{y}^{c}) = \sigma(a_{z}^{c}b_{z}^{c}) σ ( a x c b x c ) = σ ( a y c b y c ) = σ ( a z c b z c ) . From u q c ≺ a q c ≺ v q c ≺ b q c u_{q}^{c} \prec a_{q}^{c} \prec v_{q}^{c} \prec b_{q}^{c} u q c ≺ a q c ≺ v q c ≺ b q c it follows that σ ( a q c b q c ) ≠ σ ( u q c v q c ) \sigma(a_{q}^{c}b_{q}^{c}) \ne\sigma(u_{q}^{c}v_{q}^{c}) σ ( a q c b q c ) = σ ( u q c v q c ) for every q ∈ { x , y , z } q \in\{x,y,z\} q ∈ { x , y , z } and hence σ ( u x c v x c ) = σ ( u y c v y c ) = σ ( u z c v z c ) \sigma(u_{x}^{c}v_{x}^{c}) = \sigma(u_{y}^{c}v_{y}^{c}) = \sigma(u_{z}^{c}v_{z}^{c}) σ ( u x c v x c ) = σ ( u y c v y c ) = σ ( u z c v z c ) . Recall that all validator edges have color col ( c ) \operatorname{col}(c) col ( c ) . Thus, there exists a page that contains at least three edges of color col ( c ) \operatorname{col}(c) col ( c ) . However, we have b 1 ( col ( c ) ) = b 2 ( col ( c ) ) = 2 < 3 b_{1}(\operatorname{col}(c)) = b_{2}(\operatorname{col}(c)) = 2 < 3 b 1 ( col ( c )) = b 2 ( col ( c )) = 2 < 3 , which contradicts the assumption that ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ was an admissible solution. Consequently, σ ( a x c b x c ) = σ ( a y c b y c ) = σ ( a z c b z c ) \sigma(a_{x}^{c}b_{x}^{c}) = \sigma(a_{y}^{c}b_{y}^{c}) = \sigma(a_{z}^{c}b_{z}^{c}) σ ( a x c b x c ) = σ ( a y c b y c ) = σ ( a z c b z c ) cannot hold, and we can find p , q ∈ c p,q \in c p , q ∈ c that fulfills the second claim from the statement.
Putting Everything Together. For an instance φ \varphi φ of Monotone Not All Equal 3Sat-E4, we arbitrarily order the variables X X X and clauses C C C . We construct the variable gadget and clause gadget for every variable x ∈ X x \in X x ∈ X and clause c ∈ C c \in C c ∈ C . Finally, we order them on the spine ≺ \prec ≺ by first placing the variable gadgets in increasing order, followed by the clause gadgets, again in increasing order. We observe that the variable gadgets induce the largest connected components of S S S ; recall Figure 4 . Using Lemma 3 , we obtain:
Theorem 4. Fixed Order Capacitated 2-Page Stack Layout is NP-complete even when restricted to balanced and tight instances ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) (G,\delta,\prec,\ell= 2,b_{1},b_{2}) ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) where every connected component of S ( G , ≺ ) S(G,\prec) S ( G , ≺ ) has at most five vertices.
Proof. Containment in NP is immediate. To show NP-hardness, let φ \varphi φ be an instance of Monotone Not All Equal 3Sat-E4 on η \eta η variables X X X and μ \mu μ clauses C C C , and let I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I} = (G,\delta,\prec,\ell= 2,b_{1},b_{2}) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) be the instance of FoCap2PSL obtained from the above-described reduction. Since every gadget has constant size and is constructed precisely once for every variable and clause of φ \varphi φ , we can conclude that the size of I \mathcal{I} I is in O ( η + μ ) O(\eta+ \mu) O ( η + μ ) . Moreover, the number of colors is also linear in η + μ \eta+ \mu η + μ . The instance can be constructed in the same time. Regarding the size of the connected components in S S S , we can observe that every variable gadget induces two connected components: One corresponds to the single edge u x v x u_{x}v_{x} u x v x which is in conflict with no other edge. The other edges of the variable gadget induce a single connected component of size five in S S S ; recall Figure 4 a. Clause gadgets induce connected components of size at most two in S S S . Since all gadgets are disjoint with respect to ≺ \prec ≺ , the largest connected component of S S S has size at most five. We now establish correctness of the reduction.
( ⇒ ) (\Rightarrow) ( ⇒ ) Assume that φ \varphi φ is a positive instance and let Ψ : X → { 0 , 1 } \Psi: X \to\{0,1\} Ψ : X → { 0 , 1 } be a witnessing truth assignment. We now construct based on Ψ \Psi Ψ a page assignment σ \sigma σ such that ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ witnesses that I \mathcal{I} I is a positive instance of FoCap2PSL. To this end, consider a variable x ∈ X x \in X x ∈ X and its corresponding variable gadget. If x x x is set to false, we assign the edge s x t x s_{x}t_{x} s x t x to the first page and otherwise to the second page. The remaining edges are assigned to the respective other page (as also prescribed by the necessary page assignment from Observation 2). This assignment is crossing-free since the variable edges are only in conflict with the selecting edge s x t x s_xt_x s x t x ; the dummy edge u x v x u_xv_x u x v x does not cross any other edge. Moreover, we assigned to each page precisely one edge of color d x d_x d x , which matches the budget for these pages.
We apply the “mirrored” page assignment in the clause gadgets. More formally, for a clause c = ( x ∨ y ∨ z ) ∈ C c = (x \lor y \lor z) \in C c = ( x ∨ y ∨ z ) ∈ C , we assign the literal edge a q c b q c a_q^cb_q^c a q c b q c to the page σ ( s q t q ) \sigma(s_qt_q) σ ( s q t q ) for every q ∈ { x , y , z } q \in\{x,y,z\} q ∈ { x , y , z } . The validator edge u q c v q c u_q^cv_q^c u q c v q c is assigned to the respective other page, i.e., it holds σ ( u q c v q c ) ≠ σ ( a q c b q c ) \sigma(u_q^cv_q^c) \ne\sigma(a_q^cb_q^c) σ ( u q c v q c ) = σ ( a q c b q c ) . This ensures that the clause gadget will be crossing-free. For the last validator edge, i.e., u τ c v τ c u_\tau^cv_\tau^c u τ c v τ c , we consider the unique variable q ∈ { x , y , z } q \in\{x,y,z\} q ∈ { x , y , z } whose truth assignment is different from the other two. We set σ ( u τ c v τ c ) = σ ( u q c v q c ) \sigma(u_\tau^cv_\tau^c) = \sigma(u_q^cv_q^c) σ ( u τ c v τ c ) = σ ( u q c v q c ) , i.e., assign u τ c v τ c u_\tau^cv_\tau^c u τ c v τ c to the same page as u q c v q c u_q^cv_q^c u q c v q c . This way each page contains two edges of color col ( c ) \operatorname{col}(c) col ( c ) , which matches the budget for color col ( c ) \operatorname{col}(c) col ( c ) . Finally, regarding the color col ( q ) \operatorname{col}(q) col ( q ) for some q ∈ X q \in X q ∈ X , we make the following observation. Since σ ( s q t q ) = σ ( a q c b q c ) \sigma(s_qt_q) = \sigma(a_q^cb_q^c) σ ( s q t q ) = σ ( a q c b q c ) , we conclude σ ( a q b i q ) ≠ σ ( a q c b q c ) \sigma(a_qb_i^q) \ne\sigma(a_q^cb_q^c) σ ( a q b i q ) = σ ( a q c b q c ) for every i = 1 , 2 , 3 , 4 i = 1,2,3,4 i = 1 , 2 , 3 , 4 . Since every variable appears in exactly four clauses, we derive that every page contains four edges of color col ( q ) \operatorname{col}(q) col ( q ) , and we also have b 1 ( col ( q ) ) = b 2 ( col ( q ) ) = 4 b_1(\operatorname{col}(q)) = b_2(\operatorname{col}(q)) = 4 b 1 ( col ( q )) = b 2 ( col ( q )) = 4 . Combining all, we conclude that ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution to I \mathcal{I} I .
(⟸ \Longleftarrow ⟸ ) Assume that I \mathcal{I} I is a positive instance of FoCap2PSL and let ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ be a witnessing solution. We now construct a variable assignment Ψ : X → { 0 , 1 } \Psi: X \to\{0,1\} Ψ : X → { 0 , 1 } that satisfies φ \varphi φ . To this end, consider a variable x ∈ X x \in X x ∈ X . We set it to true if and only if σ ( s x t x ) = 2 \sigma(s_xt_x) = 2 σ ( s x t x ) = 2 . To see that Ψ \Psi Ψ is a solution to φ \varphi φ , consider an arbitrary clause c = ( x ∨ y ∨ z ) ∈ C c = (x \lor y \lor z) \in C c = ( x ∨ y ∨ z ) ∈ C . Since ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution, we know from Lemma 3 that there exist two literals p , q ∈ { x , y , z } p,q \in\{x,y,z\} p , q ∈ { x , y , z } such that σ ( a p c b p c ) ≠ σ ( a q c b q c ) \sigma(a_p^cb_p^c) \ne\sigma(a_q^cb_q^c) σ ( a p c b p c ) = σ ( a q c b q c ) . Since the very same lemma guarantees σ ( a q c b q c ) = σ ( s q t q ) \sigma(a_q^cb_q^c) = \sigma(s_qt_q) σ ( a q c b q c ) = σ ( s q t q ) for every q ∈ { x , y , z } q \in\{x,y,z\} q ∈ { x , y , z } , we conclude that there are two variables p , q ∈ { x , y , z } p,q \in\{x,y,z\} p , q ∈ { x , y , z } with Ψ ( p ) ≠ Ψ ( q ) \Psi(p) \ne\Psi(q) Ψ ( p ) = Ψ ( q ) . These two variables NAE-satisfy the clause c c c and since c c c was selected arbitrarily, we derive that Ψ \Psi Ψ is a solution to φ \varphi φ . ◀
Parameterizing by the Number of Colors
In this section, we consider the number χ \chi χ of colors as parameter. In particular, we show with Theorem 8 that Fixed Order Capacitated 2-Page Stack Layout is in XP and W[1 ] -hard with respect to this parameter. We establish XP-membership in Lemma 5 and provide the complementing hardness result in Lemma 7 .
XP-Membership. Let I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I} = (G,\delta,\prec,\ell= 2,b_1,b_2) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) be an instance of FoCap2PSL. We provide a dynamic programming (DP) algorithm to establish XP-membership. At a high-level, we iteratively consider the connected components of S \mathcal{S} S . Using a O ( λ ⋅ ( m + 1 ) χ ) O(\lambda\cdot(m+1)^\chi) O ( λ ⋅ ( m + 1 ) χ ) -sized DP-table D \mathcal{D} D , we track for every color vector μ = ( μ 1 , … , μ χ ) \boldsymbol{\mu} = (\mu_1,\ldots,\mu_\chi) μ = ( μ 1 , … , μ χ ) whether it is possible to have μ c ∈ [ m ] 0 \mu_c \in[m]_0 μ c ∈ [ m ] 0 edges of color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] on the first page using the first i ∈ [ λ ] 0 i \in[\lambda]_0 i ∈ [ λ ] 0 connected components of S \mathcal{S} S . The respective number of colored edges on the second page can be obtained by simple arithmetic. We check in the end whether a vector matching our budgets can be realized.
Lemma 5. Fixed Order Capacitated 2-Page Stack Layout can be solved constructively in O ( χ ⋅ λ ⋅ ( m + 1 ) χ + n 2 ) O(\chi\cdot\lambda\cdot(m+1)^\chi+ n^2) O ( χ ⋅ λ ⋅ ( m + 1 ) χ + n 2 ) time (which is XP in the number of colors χ \chi χ ).
Proof. Let I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I} = (G,\delta,\prec,\ell= 2,b_1,b_2) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) be an instance of Fixed Order Capacitated 2-Page Stack Layout. Since G G G must be planar to admit a 2-page stack layout, we assume that m ∈ O ( n ) m \in O(n) m ∈ O ( n ) holds. As a preprocessing step, we compute the conflict graph S \mathcal{S} S in O ( n 2 ) O(n^2) O ( n 2 ) time. We reject I \mathcal{I} I if it is not bipartite, which is a necessary condition. Otherwise, we consider an arbitrary order C 1 , … , C λ C_1,\ldots,C_\lambda C 1 , … , C λ of its connected components; recall λ = ∣ C ( S ) ∣ \lambda= |\mathcal{C}(\mathcal{S})| λ = ∣ C ( S ) ∣ .
We are now ready to describe our dynamic programming (DP) algorithm. Let i ∈ [ λ ] 0 i \in[\lambda]_0 i ∈ [ λ ] 0 be an index and μ ˉ = ( μ 1 , … , μ χ ) \bar{\mu} = (\mu_1,\ldots,\mu_\chi) μ ˉ = ( μ 1 , … , μ χ ) be a color vector with μ c ∈ [ m ] 0 \mu_c \in[m]_0 μ c ∈ [ m ] 0 for every color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] . Note that there are O ( ( m + 1 ) χ ) O((m+1)^\chi) O (( m + 1 ) χ ) different color vectors. We will make use of a binary DP-table D D D where we set D [ i , μ ˉ ] = 1 D[i,\bar{\mu}] = 1 D [ i , μ ˉ ] = 1 if and only if there exists a solution ⟨ ≺ , σ i ⟩ \langle\prec,\sigma_i\rangle ⟨ ≺ , σ i ⟩ for the edges ⋃ j ∈ [ i ] E ( C j ) \bigcup_{j\in[i]} E(C_j) ⋃ j ∈ [ i ] E ( C j ) with μ c \mu_c μ c edges of color c c c on the first page, for every c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] . In this case, the solution ⟨ ≺ , σ i ⟩ \langle\prec,\sigma_i\rangle ⟨ ≺ , σ i ⟩ induces μ ˉ \bar{\mu} μ ˉ . As our base case, we define D [ 0 , μ ˉ ] = 1 D[0,\bar{\mu}] = 1 D [ 0 , μ ˉ ] = 1 if and only if μ ˉ = ⟨ 0 , … , 0 ⟩ \bar{\mu} = \langle0,\ldots,0\rangle μ ˉ = ⟨ 0 , … , 0 ⟩ . Clearly, without placing any edge, any solution can only induce the zero vector. For some i ∈ [ λ ] i \in[\lambda] i ∈ [ λ ] , observe that the connected component C i C_i C i is bipartite. As a consequence, there are precisely two possible crossing-free page assignments for the edges from C i C_i C i . Let a ˉ 1 = ( μ 1 1 , … , μ χ 1 ) \bar{a}_1 = (\mu_1^1,\ldots,\mu_\chi^1) a ˉ 1 = ( μ 1 1 , … , μ χ 1 ) and a ˉ 2 = ( μ 1 2 , … , μ χ 2 ) \bar{a}_2 = (\mu_1^2,\ldots,\mu_\chi^2) a ˉ 2 = ( μ 1 2 , … , μ χ 2 ) be their corresponding color vectors for the first page. Let μ ˉ \bar{\mu} μ ˉ be a color vector. We set D [ i , μ ˉ ] = 1 D[i,\bar{\mu}] = 1 D [ i , μ ˉ ] = 1 if and only if there exists a j ∈ { 1 , 2 } j \in\{1,2\} j ∈ { 1 , 2 } such that μ ˉ − a ˉ j \bar{\mu}-\bar{a}_j μ ˉ − a ˉ j has only non-negative entries and D [ i − 1 , μ ˉ − a ˉ j ] = 1 D[i-1,\bar{\mu}-\bar{a}_j] = 1 D [ i − 1 , μ ˉ − a ˉ j ] = 1 holds. This is correct since a solution that witnesses D [ i − 1 , μ ˉ − a ˉ j ] = 1 D[i-1,\bar{\mu}-\bar{a}_j] = 1 D [ i − 1 , μ ˉ − a ˉ j ] = 1 can be extended to a solution for D [ i , μ ˉ ] = 1 D[i,\bar{\mu}] = 1 D [ i , μ ˉ ] = 1 by using the corresponding page assignment; see also Figure 5 . Moreover, a solution that witnesses D [ i , μ ˉ ] = 1 D[i,\bar{\mu}] = 1 D [ i , μ ˉ ] = 1 also witnesses D [ i − 1 , μ ˉ − a ˉ j ] = 1 D[i-1,\bar{\mu}-\bar{a}_j] = 1 D [ i − 1 , μ ˉ − a ˉ j ] = 1 by removing the edges from C i C_i C i . Evaluating a single entry D [ i , μ ˉ ] D[i,\bar{\mu}] D [ i , μ ˉ ] takes O ( χ ) O(\chi) O ( χ ) time. Since D D D has O ( λ ⋅ ( m + 1 ) χ ) O(\lambda\cdot(m+1)^\chi) O ( λ ⋅ ( m + 1 ) χ ) entries, we can compute D D D in O ( χ ⋅ λ ⋅ ( m + 1 ) χ ) O(\chi\cdot\lambda\cdot(m+1)^\chi) O ( χ ⋅ λ ⋅ ( m + 1 ) χ ) time.
Figure 5. (a) An admissible 2-page stack layout for the edges E ( C 1 ) E(C_1) E ( C 1 ) . The edges of E ( C 2 ) E(C_2) E ( C 2 ) are indicated with dashed lines. (b) The two possible solutions that we can obtain when adding E ( C 2 ) E(C_2) E ( C 2 ) . We indicate above the layout the corresponding color vectors and table entries.
Once the table D D D has been computed, we need to check whether some color vector fulfills the budget constraints. To this end, consider a color vector μ ˉ = ( μ 1 , … , μ χ ) \bar{\mu} = (\mu_1,\ldots,\mu_\chi) μ ˉ = ( μ 1 , … , μ χ ) . Observe that a solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ that induces μ ˉ \bar{\mu} μ ˉ has ∣ δ − 1 ( c ) ∣ − μ c |\delta^{-1}(c)|-\mu_c ∣ δ − 1 ( c ) ∣ − μ c edges of color c c c on page two, for every c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] . Using this observation, we conclude that I I I admits a solution if and only if there exists a color vector μ ˉ = ( μ 1 , … , μ χ ) \bar{\mu} = (\mu_1,\ldots,\mu_\chi) μ ˉ = ( μ 1 , … , μ χ ) such that D [ λ , μ ˉ ] = 1 D[\lambda,\bar{\mu}] = 1 D [ λ , μ ˉ ] = 1 , μ c ≤ b 1 ( c ) \mu_c \leq b_1(c) μ c ≤ b 1 ( c ) , and ∣ δ − 1 ( c ) ∣ − μ c ≤ b 2 ( c ) |\delta^{-1}(c)|-\mu_c \leq b_2(c) ∣ δ − 1 ( c ) ∣ − μ c ≤ b 2 ( c ) holds for every color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] . We can test this in O ( ( m + 1 ) χ ) O((m+1)^\chi) O (( m + 1 ) χ ) time as a postprocessing step. Therefore, our DP-algorithm has a running time of O ( χ ⋅ λ ⋅ ( m + 1 ) χ + n 2 ) O(\chi\cdot\lambda\cdot(m+1)^\chi+ n^2) O ( χ ⋅ λ ⋅ ( m + 1 ) χ + n 2 ) and the statement follows.
W[1 ] -Hardness. Next, we show that FoCap2PSL is W[1 ] -hard when parameterized by the number of colors χ \chi χ . To this end, we devise a parameterized reduction from the problem Multidimensional Subset Sum, defined as follows. Given a multiset S S S of η \eta η d d d -dimensional vectors over N 0 d \mathbb{N}_0^d N 0 d and a d d d -dimensional target vector t ˉ \bar{t} t ˉ , does there exist a subset S ′ ⊆ S S' \subseteq S S ′ ⊆ S such that ∑ s ˉ ∈ S ′ s ˉ = t ˉ \sum_{\bar{s}\in S'} \bar{s} = \bar{t} ∑ s ˉ ∈ S ′ s ˉ = t ˉ ? The problem is known to be W[1 ] -hard when parameterized by the dimension d d d , even when the numbers are unary encoded [24 ] .
In our reduction, we have overall d + 1 d+1 d + 1 colors. Each number is represented as a star and a vector is encoded as a set of d d d nested stars, one in each color c ∈ [ d ] c \in[d] c ∈ [ d ] . Since we only have two pages, we can use an additional edge in color d + 1 d+1 d + 1 to force all of these edges to be placed on the same page. Placing them on the first page represents membership in the solution set S ′ ⊆ S S^\prime\subseteq S S ′ ⊆ S and by appropriately setting the budget for both pages, we can ensure equivalence between the solutions to both problems.
Number Gadget. The number gadget for an integer x ∈ N x \in\mathbb{N} x ∈ N , x ≥ 1 x \geq1 x ≥ 1 , consists of the vertices u x u_x u x and v x i v_x^i v x i , i ∈ [ x ] i \in[x] i ∈ [ x ] , arranged in the order u x ≺ v x 1 ≺ … ≺ v x x u_x \prec v_x^1 \prec\ldots\prec v_x^x u x ≺ v x 1 ≺ … ≺ v x x . We connect u x u_x u x with every v x i v_x^i v x i , i ∈ [ x ] i \in[x] i ∈ [ x ] , i.e., introduce a star K 1 , x K_{1,x} K 1 , x with center u x u_x u x ; see also Figure 6 . The number x = 0 x=0 x = 0 is represented by the empty number gadget. To represent a vector s ˉ = ( x 1 , … , x d ) \bar{s}=(x_1,\ldots,x_d) s ˉ = ( x 1 , … , x d ) , we combine d d d number gadgets into a vector gadget as follows, where a s ˉ b s ˉ a_{\bar{s}}b_{\bar{s}} a s ˉ b s ˉ is a new edge that we will use to ensure correctness of the reduction; see again Figure 6 for an example.
Figure 6. The vector gadget which features the number gadgets for 3, 1, and 5, respectively.
a s ˉ ≺ u x 1 ≺ u x 2 ≺ … ≺ u x d ≺ b s ˉ ≺ v x d 1 ≺ … ≺ v x d x d ≺ v x d − 1 1 ≺ … ≺ v x 1 x 1 a_{\bar{s}} \prec u_{x_1} \prec u_{x_2} \prec\ldots\prec u_{x_d} \prec b_{\bar{s}} \prec v_{x_d}^1 \prec\ldots\prec v_{x_d}^{x_d} \prec v_{x_{d-1}}^1 \prec\ldots\prec v_{x_1}^{x_1} a s ˉ ≺ u x 1 ≺ u x 2 ≺ … ≺ u x d ≺ b s ˉ ≺ v x d 1 ≺ … ≺ v x d x d ≺ v x d − 1 1 ≺ … ≺ v x 1 x 1
We color the edges of the number gadgets based on the dimension they represent, i.e., we have δ ( u x i v x i j ) = i \delta(u_{x_i}v_{x_i}^j)=i δ ( u x i v x i j ) = i for every i ∈ [ d ] i \in[d] i ∈ [ d ] , j ∈ [ x i ] j \in[x_i] j ∈ [ x i ] . Moreover, we color the edge a s ˉ b s ˉ a_{\bar{s}}b_{\bar{s}} a s ˉ b s ˉ in the color “for” dimension d + 1 d+1 d + 1 : δ ( a s ˉ b s ˉ ) = d + 1 \delta(a_{\bar{s}}b_{\bar{s}})=d+1 δ ( a s ˉ b s ˉ ) = d + 1 . Note that the edge a s ˉ b s ˉ a_{\bar{s}}b_{\bar{s}} a s ˉ b s ˉ is in conflict with every other edge from the vector gadget, which leads to the following observation.
Observation 6. In every 2-page stack layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ of the vector gadget for a vector s ˉ = ( x 1 , … , x d ) \bar{s}=(x_1,\ldots,x_d) s ˉ = ( x 1 , … , x d ) we have σ ( a s ˉ b s ˉ ) ≠ σ ( u x i v x i j ) \sigma(a_{\bar{s}}b_{\bar{s}}) \neq\sigma(u_{x_i}v_{x_i}^j) σ ( a s ˉ b s ˉ ) = σ ( u x i v x i j ) for every i ∈ [ d ] i \in[d] i ∈ [ d ] and j ∈ [ x i ] j \in[x_i] j ∈ [ x i ] . In particular, we have σ ( u x y v x y i ) = σ ( u x z v x z j ) \sigma(u_{x_y}v_{x_y}^i)=\sigma(u_{x_z}v_{x_z}^j) σ ( u x y v x y i ) = σ ( u x z v x z j ) for every y , z ∈ [ d ] y,z \in[d] y , z ∈ [ d ] , i ∈ [ x y ] i \in[x_y] i ∈ [ x y ] , and j ∈ [ x z ] j \in[x_z] j ∈ [ x z ] .
We now use Observation 6 to establish correctness of our reduction; see also Figure 7 for a small example of the construction.
Figure 7. An instance of FoCap2PSL constructed for the instance ( S = { s ˉ 1 , s ˉ 2 , s ˉ 3 , s ˉ 4 } , t ˉ = ( 2 , 2 , 2 ) ) (S=\{\bar{s}_1,\bar{s}_2,\bar{s}_3,\bar{s}_4\},\bar{t}=(2,2,2)) ( S = { s ˉ 1 , s ˉ 2 , s ˉ 3 , s ˉ 4 } , t ˉ = ( 2 , 2 , 2 )) of Multidimensional Subset Sum. The layout depicts the solution S ′ = { s ˉ 1 , s ˉ 3 } S^\prime=\{\bar{s}_1,\bar{s}_3\} S ′ = { s ˉ 1 , s ˉ 3 } .
Lemma 7. Fixed Order Capacitated 2-Page Stack Layout is W[1 ] -hard when parameterized by the number of colors χ \chi χ .
Proof. Let ( S , t ˉ ) (S,\bar{t}) ( S , t ˉ ) be an instance of Multidimensional Subset Sum on d d d dimensions with t ˉ = ( t 1 , … , t d ) \bar{t}=(t_1,\ldots,t_d) t ˉ = ( t 1 , … , t d ) such that every number can be bounded by a polynomial in η = ∣ S ∣ \eta=|S| η = ∣ S ∣ ; we recall that Multidimensional Subset Sum remains W[1 ] -hard parameterized by d d d in
case [24 ] . Consider an arbitrary order of the η \eta η vectors in S = { s ˉ 1 , … , s ˉ η } S = \{\bar{s}_1,\ldots,\bar{s}_\eta\} S = { s ˉ 1 , … , s ˉ η } . We now create an instance of FoCap2PSL by first creating the vector gadget for every vector s ˉ i \bar{s}_i s ˉ i , i ∈ [ η ] i \in[\eta] i ∈ [ η ] and placing it on the spine ≺ \prec ≺ ordered by index. For every color c ∈ [ d ] c \in[d] c ∈ [ d ] , we set b 1 ( c ) = t c b_1(c) = t_c b 1 ( c ) = t c and b 2 ( c ) = ( ∑ ( … , x c , … ) ∈ S x c ) − t c = ∣ δ − 1 ( c ) ∣ − t c b_2(c) = \left(\sum_{(\ldots,x_c,\ldots)\in S}x_c\right)-t_c = |\delta^{-1}(c)|-t_c b 2 ( c ) = ( ∑ ( … , x c , … ) ∈ S x c ) − t c = ∣ δ − 1 ( c ) ∣ − t c . Finally, we set b 1 ( d + 1 ) = b 2 ( d + 1 ) = η b_1(d+1)=b_2(d+1)=\eta b 1 ( d + 1 ) = b 2 ( d + 1 ) = η . Let I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I}=(G,\delta,\prec,\ell=2,b_1,b_2) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) be the obtained instance. We observe that its size is linear in η + ∑ s ˉ ∈ S ∑ x i ∈ s ˉ x i \eta+\sum_{\bar{s}\in S}\sum_{x_i\in\bar{s}}x_i η + ∑ s ˉ ∈ S ∑ x i ∈ s ˉ x i , which is polynomial in η \eta η . Moreover, we have χ = d + 1 \chi=d+1 χ = d + 1 . It remains to show correctness of the reduction to obtain W[1 ] -hardness by χ \chi χ .
(⇒) Assume that ( S , t ˉ ) (S,\bar{t}) ( S , t ˉ ) is a positive instance of Multidimensional Subset Sum and let S ′ ⊆ S S'\subseteq S S ′ ⊆ S be a set of vectors such that ∑ s ˉ ∈ S ′ s ˉ = t ˉ \sum_{\bar{s}\in S'}\bar{s}=\bar{t} ∑ s ˉ ∈ S ′ s ˉ = t ˉ . We now construct a solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ for I \mathcal{I} I as follows. For every s ˉ i ∈ S \bar{s}_i\in S s ˉ i ∈ S , i ∈ [ η ] i\in[\eta] i ∈ [ η ] , we set σ ( a s ˉ i b s ˉ i ) = 1 \sigma(a_{\bar{s}_i}b_{\bar{s}_i})=1 σ ( a s ˉ i b s ˉ i ) = 1 if and only if s ˉ i ∉ S ′ \bar{s}_i\notin S' s ˉ i ∈ / S ′ . We assign all other edges of the corresponding vector gadget to the respective other page. Observe that no two edges of the vector gadget cross in this page assignment; note that σ \sigma σ resembles a necessary page assignment established in Observation 6. Moreover, the edges of the number gadgets are placed on the first page if and only if s ˉ i \bar{s}_i s ˉ i is part of the solution, i.e., s ˉ i ∈ S ′ \bar{s}_i\in S' s ˉ i ∈ S ′ . Since all gadgets are disjoint with respect to ≺ \prec ≺ , the obtained linear layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a stack layout. To see that it is also admissible, we observe, on the one hand, that for every color c ∈ [ d ] c\in[d] c ∈ [ d ] we have exactly t c = b 1 ( c ) t_c=b_1(c) t c = b 1 ( c ) edges of color c c c on the first page. This is because S ′ S' S ′ is a solution to ( S , t ˉ ) (S,\bar{t}) ( S , t ˉ ) and thus we have ∑ ( … , x c , … ) ∈ S ′ x c = t c \sum_{(\ldots,x_c,\ldots)\in S'}x_c=t_c ∑ ( … , x c , … ) ∈ S ′ x c = t c . Consequently, the second page contains ( ∑ ( … , x c , … ) ∈ S x c ) − t c = b 2 ( c ) \left(\sum_{(\ldots,x_c,\ldots)\in S}x_c\right)-t_c=b_2(c) ( ∑ ( … , x c , … ) ∈ S x c ) − t c = b 2 ( c ) edges of color c c c . Regarding color d + 1 d+1 d + 1 , since b 1 ( d + 1 ) = b 2 ( d + 1 ) = ∣ S ∣ b_1(d+1)=b_2(d+1)=|S| b 1 ( d + 1 ) = b 2 ( d + 1 ) = ∣ S ∣ and we have ∣ S ′ ∣ , ∣ S ∣ − ∣ S ′ ∣ ≤ ∣ S ∣ |S'|,|S|-|S'|\leq|S| ∣ S ′ ∣ , ∣ S ∣ − ∣ S ′ ∣ ≤ ∣ S ∣ , the budget for color d + 1 d+1 d + 1 is fulfilled. Thus, ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ witnesses that I \mathcal{I} I is a positive instance of FoCap2PSL.
(⇐) For the reverse direction, assume that I \mathcal{I} I is a positive instance of FoCap2PSL and let ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ be a solution. To construct a solution S ′ S' S ′ to ( S , t ˉ ) (S,\bar{t}) ( S , t ˉ ) , we consider every vector s ˉ i = ( x 1 , … , x d ) ∈ S \bar{s}_i=(x_1,\ldots,x_d)\in S s ˉ i = ( x 1 , … , x d ) ∈ S . We add s ˉ i \bar{s}_i s ˉ i to S ′ S' S ′ if and only if σ ( a s ˉ i b s ˉ i ) = 2 \sigma(a_{\bar{s}_i}b_{\bar{s}_i})=2 σ ( a s ˉ i b s ˉ i ) = 2 . To see that S ′ S' S ′ is a solution, recall that, for every s ˉ i ∈ S \bar{s}_i\in S s ˉ i ∈ S , we have σ ( u x y j ) = σ ( u x z j ′ ) \sigma(u_{xy}^{j})=\sigma(u_{xz}^{j'}) σ ( u x y j ) = σ ( u x z j ′ ) for every y , z ∈ [ d ] y,z\in[d] y , z ∈ [ d ] , j ∈ [ x y ] j\in[x_y] j ∈ [ x y ] , and j ′ ∈ [ x z ] j'\in[x_z] j ′ ∈ [ x z ] by Observation 6, i.e., all edges of the number gadgets for s ˉ i \bar{s}_i s ˉ i are assigned to the same page. In particular, they are placed on the first page if and only if we have added s ˉ i \bar{s}_i s ˉ i to the solution set S ′ S' S ′ . Consider a color c ∈ [ d ] c\in[d] c ∈ [ d ] . Since ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution to I \mathcal{I} I , the first page contains at most b 1 ( c ) = t c b_1(c)=t_c b 1 ( c ) = t c edges of color c c c and the second page contains at most b 2 ( c ) = ∣ δ − 1 ( c ) ∣ − t c b_2(c)=|\delta^{-1}(c)|-t_c b 2 ( c ) = ∣ δ − 1 ( c ) ∣ − t c edges of color $c. Moreover, G G G contains precisely ∑ ( … , x c , … ) ∈ S x c = b 1 ( c ) + b 2 ( c ) \sum_{(\ldots,x_c,\ldots)\in S}x_c=b_1(c)+b_2(c) ∑ ( … , x c , … ) ∈ S x c = b 1 ( c ) + b 2 ( c ) edges of color c c c . Thus, by applying these arguments for every color c ∈ [ d ] c\in[d] c ∈ [ d ] , we can conclude ∑ s ˉ ∈ S ′ s ˉ = t ˉ \sum_{\bar{s}\in S'}\bar{s}=\bar{t} ∑ s ˉ ∈ S ′ s ˉ = t ˉ , i.e., ( S , t ˉ ) (S,\bar{t}) ( S , t ˉ ) is a positive instance of Multidimensional Subset Sum.
The following theorem summarizes Lemmas 5 and 7.
Theorem 8. Fixed Order Capacitated 2-Page Stack Layout is in XP and W[1 ] -hard when parameterized by the number of colors χ \chi χ .
An FPT-Algorithm for Few Colors and Bounded-Size Components
In this section, we establish our last result for FoCap2PSL, namely a fixed-parameter tractable algorithm when parameterized by the number of colors χ \chi χ and the size of the largest connected component in the conflict graph γ = max { ∣ V ( C ) ∣ ∣ C ∈ C ( S ) } \gamma=\max\{|V(C)|\mid C\in\mathcal{C}(S)\} γ = max { ∣ V ( C ) ∣ ∣ C ∈ C ( S )} . Note that both parameters are necessary for an FPT-algorithm since we have shown that the problem is W[1 ] -hard parameterized by χ \chi χ (Theorem 8 ) and paraNP-hard by γ \gamma γ (Theorem 4 ). In the following, we establish a more general result in which ℓ \ell ℓ is not assumed to be 2 but a parameter.
:::
While this is not necessary to establish the result of this section, it will later allow us to show that FoCapQl is FPT with respect to χ \chi χ , γ \gamma γ , and the number of pages ℓ \ell ℓ . Let I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) \mathcal{I}=(G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) be an instance of FoCapSl. On a high level, since both χ \chi χ and γ \gamma γ are bounded, we can assign to each connected component of S S S one of g ( χ , γ ) g(\chi,\gamma) g ( χ , γ ) -many types, for some computable function g g g . Moreover, since also the number of pages is bounded, each type has at most h ( ℓ , γ ) h(\ell,\gamma) h ( ℓ , γ ) different valid, i.e., crossing-free, page assignments, for some computable function h h h . We can observe that from the perspective of a solution, all that matters is how many components from each type use a particular page assignment. The precise distribution of components to page assignments is irrelevant. Thus, we can encode the problem of finding an admissible layout as an integer linear program (ILP) with a bounded number of variables – essentially one for each type and their possible page assignment. Fixed-parameter tractability then follows by checking feasibility for the ILP in FPT-time:
Proposition 9 (See, e.g., [37 , 45 ] ). Let P \mathcal{P} P be an integer linear program in η \eta η variables. Then, it can be solved in time f ( η ) ⋅ ∣ P ∣ O ( 1 ) f(\eta)\cdot|\mathcal{P}|^{O(1)} f ( η ) ⋅ ∣ P ∣ O ( 1 ) for some computable function f f f .
In the following, we formalize each of the above-hinted steps.
Component Types and Their Embeddings.
In the following, for an edge e ∈ E e\in E e ∈ E and connected component C ∈ C ( S ) C\in\mathcal{C}(S) C ∈ C ( S ) , we write e ∈ V ( C ) e\in V(C) e ∈ V ( C ) to denote that e e e is represented by a vertex of C C C . We start by defining the component types.
Definition 10. Two connected components C i , C j ∈ C ( S ) C_i,C_j\in\mathcal{C}(S) C i , C j ∈ C ( S ) have the same component type, denoted C i ∼ C j C_i\sim C_j C i ∼ C j , if and only if there exists an isomorphism ξ : V ( C i ) → V ( C j ) \xi:V(C_i)\to V(C_j) ξ : V ( C i ) → V ( C j ) from C i C_i C i to C j C_j C j such that δ ( e ) = δ ( ξ ( e ) ) \delta(e)=\delta(\xi(e)) δ ( e ) = δ ( ξ ( e )) for every e ∈ V ( C i ) e\in V(C_i) e ∈ V ( C i ) .
Note that ∼ \sim ∼ is an equivalence relation whose number of classes is bounded:
Lemma 11. There are O ( γ ⋅ 2 γ 2 ⋅ χ γ ) O(\gamma\cdot2^{\gamma^2}\cdot\chi^\gamma) O ( γ ⋅ 2 γ 2 ⋅ χ γ ) equivalence classes in C ( S ) / ∼ \mathcal{C}(S)/\sim C ( S ) / ∼ . We can compute the partition of C ( S ) \mathcal{C}(S) C ( S ) into ∼ \sim ∼ in O ( γ 3 ⋅ 2 γ 2 + γ ⋅ log γ ⋅ χ γ ⋅ m ) O(\gamma^3\cdot2^{\gamma^2+\gamma\cdot\log\gamma}\cdot\chi^\gamma\cdot m) O ( γ 3 ⋅ 2 γ 2 + γ ⋅ l o g γ ⋅ χ γ ⋅ m ) time.
Proof. Each connected component C ∈ C ( S ) C\in\mathcal{C}(S) C ∈ C ( S ) has at most γ \gamma γ vertices. Moreover, every vertex e ∈ V ( C ) e\in V(C) e ∈ V ( C ) has one of χ \chi χ colors. For every i ∈ [ γ ] i\in[\gamma] i ∈ [ γ ] , there are 2 ( i 2 ) ⋅ χ i 2^{\binom{i}{2}}\cdot\chi^i 2 ( 2 i ) ⋅ χ i different vertex-colored graphs (on the vertex set [ i ] [i] [ i ] ). Thus, for up to γ \gamma γ vertices, there are
∑ i = 1 γ 2 ( i 2 ) ⋅ χ i ≤ γ ⋅ 2 ( γ 2 ) ⋅ χ γ ∈ O ( γ ⋅ 2 γ 2 ⋅ χ γ ) \sum_{i=1}^{\gamma}2^{\binom{i}{2}}\cdot\chi^i\leq\gamma\cdot2^{\binom{\gamma}{2}}\cdot\chi^\gamma\in O(\gamma\cdot2^{\gamma^2}\cdot\chi^\gamma) i = 1 ∑ γ 2 ( 2 i ) ⋅ χ i ≤ γ ⋅ 2 ( 2 γ ) ⋅ χ γ ∈ O ( γ ⋅ 2 γ 2 ⋅ χ γ )
different vertex-colored graphs. Every equivalence class in C ( S ) / ∼ \mathcal{C}(S)/\sim C ( S ) / ∼ contains a connected component which is isomorphic to one of these graphs. Consequently, we can upper bound the number of equivalence classes in C ( S ) / ∼ \mathcal{C}(S)/\sim C ( S ) / ∼ by O ( γ ⋅ 2 γ 2 ⋅ χ γ ) O(\gamma\cdot2^{\gamma^2}\cdot\chi^\gamma) O ( γ ⋅ 2 γ 2 ⋅ χ γ ) .
For the running time, we first observe that S S S contains m m m vertices, one for each edge in G G G , and that the number of connected components is, therefore, also at most m m m . For each connected component C ∈ C ( S ) C\in\mathcal{C}(S) C ∈ C ( S ) , we can iterate over all equivalence classes (found so far). For each potential equivalence class, we can branch over all O ( γ ! ) = O ( 2 γ ⋅ log γ ) O(\gamma!)=O(2^{\gamma\cdot\log\gamma}) O ( γ !) = O ( 2 γ ⋅ l o g γ ) possible bijections ξ \xi ξ and check in O ( γ 2 ) O(\gamma^2) O ( γ 2 ) time whether one of them is a color-preserving isomorphism or whether C C C induces a “new” equivalence class in C ( S ) / ∼ \mathcal{C}(S)/\sim C ( S ) / ∼ . Combining all, the running time bound follows readily.
Since every connected component C ∈ C ( S ) C\in\mathcal{C}(S) C ∈ C ( S ) has at most γ \gamma γ vertices, there are at most ℓ γ \ell^\gamma ℓ γ possible page assignments σ \sigma σ for the edges e ∈ V ( C ) e\in V(C) e ∈ V ( C ) , i.e., vertex-colorings of C C C . However, we must exclude those that introduce crossings on a page, i.e., only allow proper colorings of $C:
Definition 12. Let [ C ] [C] [ C ] be an equivalence class of ∼ \sim ∼ . The valid page assignments Σ ( [ C ] ) \Sigma([C]) Σ ([ C ]) is the set of all page assignments σ : V ( C ) → [ ℓ ] \sigma: V(C) \to[\ell] σ : V ( C ) → [ ℓ ] such that there are no two edges a b , c d ∈ C ab, cd \in C ab , c d ∈ C with σ ( a b ) = σ ( c d ) \sigma(ab) = \sigma(cd) σ ( ab ) = σ ( c d ) such that a ≺ c ≺ b ≺ d a \prec c \prec b \prec d a ≺ c ≺ b ≺ d .
We can efficiently compute the valid page assignments Σ ( [ C ] ) \Sigma([C]) Σ ([ C ]) of an equivalence class [ C ] [C] [ C ] :
Observation 13. Let [ C ] [C] [ C ] be an equivalence class of ∼ \sim ∼ . It holds ∣ Σ ( [ C ] ) ∣ ∈ O ( ℓ γ ) |\Sigma([C])| \in O(\ell^\gamma) ∣Σ ([ C ]) ∣ ∈ O ( ℓ γ ) . We can compute the set Σ ( [ C ] ) \Sigma([C]) Σ ([ C ]) in O ( ℓ γ ⋅ γ 2 ) O(\ell^\gamma\cdot\gamma^2) O ( ℓ γ ⋅ γ 2 ) time.
For an equivalence class [ C ] [C] [ C ] of ∼ \sim ∼ , a valid page assignment σ ∈ Σ ( [ C ] ) \sigma\in\Sigma([C]) σ ∈ Σ ([ C ]) , and a color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] , we let # p ( [ C ] , σ , c ) \#_p([C], \sigma, c) # p ([ C ] , σ , c ) denote the number of edges of color c c c assigned to page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] in the page assignment σ \sigma σ . We are now ready to state our ILP.
Using an ILP to Find a Solution. We now define the ILP P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) for I \mathcal{I} I . For every equivalence class [ C ] [C] [ C ] of ∼ \sim ∼ , we define n [ C ] : = ∣ [ C ] ∣ = ∣ { C ′ ∈ C ( S ) ∣ C ′ ∼ C } ∣ n_{[C]} := |[C]| = |\{C' \in\mathcal{C}(S) \mid C' \sim C\}| n [ C ] := ∣ [ C ] ∣ = ∣ { C ′ ∈ C ( S ) ∣ C ′ ∼ C } ∣ to be the number of connected components C ′ C' C ′ of S S S of component type [ C ] [C] [ C ] . For every equivalence class [ C ] [C] [ C ] of ∼ \sim ∼ and every page assignment σ ∈ Σ ( [ C ] ) \sigma\in\Sigma([C]) σ ∈ Σ ([ C ]) , we introduce an integer variable x [ C ] , σ x_{[C],\sigma} x [ C ] , σ that captures the number of connected components C ′ ∈ [ C ] C' \in[C] C ′ ∈ [ C ] whose vertices, i.e., edges of G G G , are assigned to pages according to σ \sigma σ in a solution. Observe that every variable assignment with 0 ≤ x [ C ] , σ ≤ n [ C ] 0 \leq x_{[C],\sigma} \leq n_{[C]} 0 ≤ x [ C ] , σ ≤ n [ C ] and ∑ σ ∈ Σ ( [ C ] ) x [ C ] , σ = n [ C ] \sum_{\sigma\in\Sigma([C])} x_{[C],\sigma} = n_{[C]} ∑ σ ∈ Σ ([ C ]) x [ C ] , σ = n [ C ] for every [ C ] ∈ C ( S ) / ∼ [C] \in\mathcal{C}(S)/\sim [ C ] ∈ C ( S ) / ∼ and σ ∈ Σ ( [ C ] ) \sigma\in\Sigma([C]) σ ∈ Σ ([ C ]) can be translated into a crossing-free linear layout of G G G . To capture this, we introduce the following constraints:
0 ≤ x [ C ] , σ ≤ n [ C ] ∀ [ C ] ∈ C ( S ) / ∼ , σ ∈ Σ ( [ C ] ) 0 \leq x_{[C],\sigma} \leq n_{[C]} \qquad\forall[C] \in\mathcal{C}(S)/\sim,\ \sigma\in\Sigma([C]) 0 ≤ x [ C ] , σ ≤ n [ C ] ∀ [ C ] ∈ C ( S ) / ∼ , σ ∈ Σ ([ C ])
(BND)
∑ σ ∈ Σ ( [ C ] ) x [ C ] , σ = n [ C ] ∀ [ C ] ∈ C ( S ) / ∼ \sum_{\sigma\in\Sigma([C])} x_{[C],\sigma} = n_{[C]} \qquad\forall[C] \in\mathcal{C}(S)/\sim σ ∈ Σ ([ C ]) ∑ x [ C ] , σ = n [ C ] ∀ [ C ] ∈ C ( S ) / ∼
(SUM)
We need additional constraints to ensure that a layout also respects our budget constraints. To this end, recall that we let # p ( [ C ] , σ , c ) \#_p([C], \sigma, c) # p ([ C ] , σ , c ) denote the number of edges e ∈ V ( C ) e \in V(C) e ∈ V ( C ) of color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] assigned to page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] in the page assignment σ ∈ Σ ( [ C ] ) \sigma\in\Sigma([C]) σ ∈ Σ ([ C ]) . Note that this value is a constant that can be precomputed. To get the overall number of edges of color c c c on some page p p p , we can sum this value up over all valid page assignments for all equivalence classes [ C ] ∈ C ( S ) / ∼ [C] \in\mathcal{C}(S)/\sim [ C ] ∈ C ( S ) / ∼ , which should not exceed the budget constraint for color c c c on page p p p :
∑ [ C ] ∈ C ( S ) / ∼ ∑ σ ∈ Σ ( [ C ] ) # p ( [ C ] , σ , c ) ⋅ x [ C ] , σ ≤ b p ( c ) ∀ c ∈ [ χ ] , p ∈ [ ℓ ] \sum_{[C] \in\mathcal{C}(S)/\sim} \sum_{\sigma\in\Sigma([C])} \#_p([C], \sigma, c) \cdot x_{[C],\sigma} \leq b_p(c) \qquad\forall c \in[\chi],\ p \in[\ell] [ C ] ∈ C ( S ) / ∼ ∑ σ ∈ Σ ([ C ]) ∑ # p ([ C ] , σ , c ) ⋅ x [ C ] , σ ≤ b p ( c ) ∀ c ∈ [ χ ] , p ∈ [ ℓ ]
(BGT)
This concludes the definition of the ILP. Next, we show that it is feasible if and only if our instance of FoCap2PSL admits a solution. We use this result to complete our FPT-algorithm for FoCap2PSL parameterized by ℓ + γ + χ \ell+ \gamma+ \chi ℓ + γ + χ .
Theorem 14. Fixed Order Capacitated Stack Layout is FPT in the number of pages ℓ \ell ℓ , number of colors χ \chi χ , and the maximum size γ \gamma γ of a connected component of S ( G , ≺ ) S(G,\prec) S ( G , ≺ ) .
Proof. Let I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) \mathcal{I} = (G,\delta,\prec,\ell,(b_p)_{p \in[\ell]}) I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) be an instance of Fixed Order Capacitated Stack Layout. We compute the conflict graph S S S and the partition of its connected components into the equivalence classes C ( S ) / ∼ \mathcal{C}(S)/\sim C ( S ) / ∼ in O ( m 2 + γ 2 ⋅ 2 γ 2 + γ log γ ⋅ χ γ ⋅ m ) O(m^2 + \gamma^2 \cdot2^{\gamma^2+\gamma\log\gamma} \cdot\chi^\gamma\cdot m) O ( m 2 + γ 2 ⋅ 2 γ 2 + γ l o g γ ⋅ χ γ ⋅ m ) time; recall also Lemma 11. Next, we construct the above-introduced integer linear program P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) . Observe that P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) has one variable for every valid page assignment of every equivalence class of ∼ \sim ∼ . Thus, by Lemma 11 and Observation 13, we can bound the number of variables in P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) by O ( γ ⋅ 2 γ 2 ⋅ χ γ ⋅ ℓ γ ) O(\gamma\cdot2^{\gamma^2} \cdot\chi^\gamma\cdot\ell^\gamma) O ( γ ⋅ 2 γ 2 ⋅ χ γ ⋅ ℓ γ ) . We can construct P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) in O ( γ ⋅ 2 γ 2 ⋅ χ γ ⋅ ℓ γ ⋅ γ 2 + ℓ ⋅ χ ) O(\gamma\cdot2^{\gamma^2} \cdot\chi^\gamma\cdot\ell^\gamma\cdot\gamma^2 + \ell\cdot\chi) O ( γ ⋅ 2 γ 2 ⋅ χ γ ⋅ ℓ γ ⋅ γ 2 + ℓ ⋅ χ ) time. By Proposition 9, we can check in g ( γ ⋅ 2 γ 2 ⋅ χ γ ⋅ ℓ γ ) ⋅ ∣ P ( I ) ∣ O ( 1 ) g(\gamma\cdot2^{\gamma^2} \cdot\chi^\gamma\cdot\ell^\gamma) \cdot|\mathcal{P}(\mathcal{I})|^{O(1)} g ( γ ⋅ 2 γ 2 ⋅ χ γ ⋅ ℓ γ ) ⋅ ∣ P ( I ) ∣ O ( 1 ) time whether P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) admits a solution for some
::: computable function g g g . Since the size of P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) can be bounded by h ( ℓ , γ , χ ) ⋅ n O ( 1 ) h(\ell,\gamma,\chi)\cdot n^{O(1)} h ( ℓ , γ , χ ) ⋅ n O ( 1 ) for some computable function h h h , we can bound the overall running time by f ( ℓ , γ , χ ) ⋅ n O ( 1 ) f(\ell,\gamma,\chi)\cdot n^{O(1)} f ( ℓ , γ , χ ) ⋅ n O ( 1 ) for some computable function f f f . To establish the statement, it remains to connect solutions for P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) with those for I \mathcal{I} I .
Claim 15. I \mathcal{I} I is a positive instance if and only if Σ ( [ C ] ) ≠ ∅ \Sigma([C]) \ne\emptyset Σ ([ C ]) = ∅ for every equivalence class [ C ] ∈ C ( S ) / ∼ [C] \in\mathcal{C}(S)/\sim [ C ] ∈ C ( S ) / ∼ and P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) is feasible.
Proof. For the sake of the proof, assume that Σ ( [ C ] ) ≠ ∅ \Sigma([C]) \ne\emptyset Σ ([ C ]) = ∅ holds for every equivalence class [ C ] ∈ C ( S ) / ∼ [C] \in\mathcal{C}(S)/\sim [ C ] ∈ C ( S ) / ∼ . Otherwise, the equivalence is trivial. We now argue the remaining part of the if and only if.
(⇒ \Rightarrow ⇒ ) Assume that I \mathcal{I} I is a positive instance and consider a solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ . Since ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution, it is in particular a valid stack layout. Thus, every connected component C ∈ C ( S ) C \in\mathcal{C}(S) C ∈ C ( S ) uses one of its valid page assignments σ ′ ∈ Σ ( [ C ] ) \sigma' \in\Sigma([C]) σ ′ ∈ Σ ([ C ]) . We now consider every equivalence class [ C ] [C] [ C ] of ∼ \sim ∼ and every valid page assignment σ ′ ∈ Σ ( [ C ] ) \sigma' \in\Sigma([C]) σ ′ ∈ Σ ([ C ]) . In line with the intended semantics of our variables, we set x [ C ] , σ ′ x_{[C],\sigma'} x [ C ] , σ ′ equal to the number of connected components from S ∩ [ C ] S \cap[C] S ∩ [ C ] that use the page assignment σ ′ \sigma' σ ′ . Since these are at least zero and at most n [ C ] n_{[C]} n [ C ] , this variable assignment fulfills Constraint (BND). Additionally, since every connected component C ′ ∈ [ C ] C' \in[C] C ′ ∈ [ C ] uses precisely one of its valid page assignments, the sum of these variables must equal n [ C ] n_{[C]} n [ C ] , i.e., we also fulfill Constraint (SUM). Moreover, since ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is an admissible layout, the number of edges of color c c c on every page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] is at most b p ( c ) b_p(c) b p ( c ) . Thus, the variable assignment also satisfies Constraint (BGT) and hence witnesses that P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) is feasible.
(⇐ \Leftarrow ⇐ ) Assume that P ( I ) \mathcal{P}(\mathcal{I}) P ( I ) is feasible (and that Σ ( [ C ] ) ≠ ∅ \Sigma([C]) \ne\emptyset Σ ([ C ]) = ∅ holds for every equivalence class [ C ] ∈ C ( S ) / ∼ [C] \in\mathcal{C}(S)/\sim [ C ] ∈ C ( S ) / ∼ ) and consider a variable assignment that satisfies Constraints (BND), (SUM), and (BGT). We now construct a solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ as follows. Consider an equivalence class [ C ] [C] [ C ] of C ( S ) / ∼ \mathcal{C}(S)/\sim C ( S ) / ∼ and all the connected components C 1 , … , C n [ C ] ∈ S ∩ [ C ] C_1,\ldots,C_{n_{[C]}} \in S \cap[C] C 1 , … , C n [ C ] ∈ S ∩ [ C ] of the same component type (ordered according to their occurrence along ≺ \prec ≺ ). Moreover, consider an arbitrary order of the valid page assignments σ 1 , … , σ k \sigma_1,\ldots,\sigma_k σ 1 , … , σ k of Σ ( [ C ] ) \Sigma([C]) Σ ([ C ]) ; note that k ≥ 1 k \ge1 k ≥ 1 holds by assumption. For the first x [ C ] , σ 1 x_{[C],\sigma_1} x [ C ] , σ 1 connected components C 1 , … , C x [ C ] , σ 1 C_1,\ldots,C_{x_{[C],\sigma_1}} C 1 , … , C x [ C ] , σ 1 , we set σ ( e ) = σ 1 ( ξ i ( e ) ) \sigma(e)=\sigma_1(\xi_i(e)) σ ( e ) = σ 1 ( ξ i ( e )) (for the color-preserving isomorphism ξ i : C i → C \xi_i:C_i \to C ξ i : C i → C ) for every edge e ∈ V ( C i ) e \in V(C_i) e ∈ V ( C i ) , 1 ≤ i ≤ x [ C ] , σ 1 1 \le i \le x_{[C],\sigma_1} 1 ≤ i ≤ x [ C ] , σ 1 . For the next x [ C ] , σ 2 x_{[C],\sigma_2} x [ C ] , σ 2 connected components, we set σ ( e ) = σ 2 ( ξ i ( e ) ) \sigma(e)=\sigma_2(\xi_i(e)) σ ( e ) = σ 2 ( ξ i ( e )) for every edge e ∈ V ( C i ) e \in V(C_i) e ∈ V ( C i ) , x [ C ] , σ 1 + 1 ≤ i ≤ x [ C ] , σ 1 + x [ C ] , σ 2 x_{[C],\sigma_1}+1 \le i \le x_{[C],\sigma_1}+x_{[C],\sigma_2} x [ C ] , σ 1 + 1 ≤ i ≤ x [ C ] , σ 1 + x [ C ] , σ 2 . We continue this process until we have considered all k k k valid page assignments of [ C ] [C] [ C ] . Note that this assignment is well-defined as we satisfy Constraints (BND) and (SUM). We repeat this step for every equivalence class [ C ] [C] [ C ] of C ( S ) / ∼ \mathcal{C}(S)/\sim C ( S ) / ∼ to eventually obtain ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ . To see that ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution, observe, on the one hand, that it is a valid ℓ \ell ℓ -page stack layout since we only use valid page assignments and every equivalence class [ C ] ∈ C ( S ) / ∼ [C] \in\mathcal{C}(S)/\sim [ C ] ∈ C ( S ) / ∼ admits at least one such page assignment, i.e., Σ ( [ C ] ) ≠ ∅ \Sigma([C]) \ne\emptyset Σ ([ C ]) = ∅ . Moreover, two edges from different connected components cannot cross by the definition of connected components in S S S . On the other hand, ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is admissible as the variable assignment satisfies Constraint (BGT). Thus, ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution.
The theorem follows by combining Claim 15 with the running time bound.
Theorem 14 immediately implies:
Corollary 16. Fixed Order Capacitated 2-Page Stack Layout is FPT in the number of colors χ \chi χ and the maximum size γ \gamma γ of a connected component of S S S .
Fixed Order Queue Layouts
In this section, we investigate queue layouts with fixed spine order ≺ \prec ≺ . It is well-known that an ℓ \ell ℓ -page queue layout with spine order ≺ \prec ≺ exists if and only if ≺ \prec ≺ does not induce an ( ℓ + 1 ) (\ell+ 1) ( ℓ + 1 ) -rainbow, i.e., a set of ℓ + 1 \ell+ 1 ℓ + 1 pairwise nesting edges [29 ] . Heath and Rosenberg [29 ] provided an efficient algorithm to construct such a queue layout (if it exists). However, in their algorithm they employ a greedy-like strategy and assign the edges to the first page in which they do not nest any other edge. The presence of our budgets invalidates such a strategy, and we show that deciding existence of a solution is already NP-complete for monochromatic graphs, i.e., where all edges have the same color, when ℓ \ell ℓ is part of the input. Before we establish said result, we analyze the complexity of our problem when ℓ ∈ { 2 , 3 } \ell\in\{2, 3\} ℓ ∈ { 2 , 3 } .
Instances with Two or Three Pages
We first consider FoCapQl when restricted to instances with two pages, i.e., ℓ = 2 \ell= 2 ℓ = 2 . In particular, we show that the problem of finding an admissible 2-page queue layout is NP-complete, even if every connected component in Q \mathcal{Q} Q has constant size. Afterwards, we present with Theorem 20 an FPT-algorithm parameterized by the number of connected components of the conflict graph Q \mathcal{Q} Q for the case ℓ = 2 \ell= 2 ℓ = 2 . Finally, we show in Theorem 21 that the aforementioned FPT-algorithm cannot be lifted to instances with ℓ = 3 \ell= 3 ℓ = 3 .
Hardness for Two Pages. We start by establishing hardness for two pages even if every connected component in Q \mathcal{Q} Q has at most five vertices. Observe that Theorem 4 is the counterpart to this result for FoCap2PSl. Moreover, the overall proof idea and the gadgets that we employ are very similar; the main part that differs between the two reductions is the linear order ≺ \prec ≺ . For the sake of completeness, we provide in the following all formal arguments to establish the claimed hardness but focus on the part that differs between the two reductions.
For the following discussion, let φ \varphi φ be an instance of the NP-complete problem Monotone Not All Equal 3Sat-E4 [14 ] ; see again § 3.2 for its definition.
Variable Gadget. Let x ∈ X x \in X x ∈ X be a variable of φ \varphi φ . As in the construction for Theorem 4 , the variable gadget for x x x consists of a selecting edge s x t x s_x t_x s x t x , a dummy edge u x v x u_x v_x u x v x , and four variable edges a x b x i a_x b_x^i a x b x i , i = 1 , 2 , 3 , 4 i = 1, 2, 3, 4 i = 1 , 2 , 3 , 4 . The variable edges receive the color col ( x ) \operatorname{col}(x) col ( x ) , the remaining two edges receive the color d x ≠ col ( x ) d_x \ne\operatorname{col}(x) d x = col ( x ) . While the budget for these colors is the same as in § 3.2 , i.e., b 1 ( d x ) = b 2 ( d x ) = 1 b_1(d_x) = b_2(d_x) = 1 b 1 ( d x ) = b 2 ( d x ) = 1 and b 1 ( col ( x ) ) = b 2 ( col ( x ) ) = 4 b_1(\operatorname{col}(x)) = b_2(\operatorname{col}(x)) = 4 b 1 ( col ( x )) = b 2 ( col ( x )) = 4 , the order of the edges' endpoints differs. More concretely, we use the order u x ≺ v x ≺ s x ≺ a x ≺ b x 1 ≺ b x 2 ≺ b x 3 ≺ b x 4 ≺ t x u_x \prec v_x \prec s_x \prec a_x \prec b_x^1 \prec b_x^2 \prec b_x^3 \prec b_x^4 \prec t_x u x ≺ v x ≺ s x ≺ a x ≺ b x 1 ≺ b x 2 ≺ b x 3 ≺ b x 4 ≺ t x ; see also Figure 8 a. Due to the budget and the placement of the endpoints (note that the selecting edge nests all variable edges), we can again make the following observation.
Figure 8. Gadgets representing (a) the variable x x x in its true state and (b) the clause c = ( x ∨ y ∨ z ) c = (x \vee y \vee z) c = ( x ∨ y ∨ z ) where x x x and z z z are set to true and y y y to false in the reduction for Theorem 19 .
Observation 17. In every admissible 2-page queue layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ of the variable gadget for a variable x ∈ X x\in X x ∈ X we have σ ( s x t x ) ≠ σ ( u x v x ) = σ ( a x i b x i ) \sigma(s_xt_x)\ne\sigma(u_xv_x)=\sigma(a_x^ib_x^i) σ ( s x t x ) = σ ( u x v x ) = σ ( a x i b x i ) for every i = 1 , 2 , 3 , 4 i=1,2,3,4 i = 1 , 2 , 3 , 4 .
Clause Gadget. Let c = ( x ∨ y ∨ z ) ∈ C c=(x\lor y\lor z)\in C c = ( x ∨ y ∨ z ) ∈ C be a clause of φ \varphi φ for some x , y , z ∈ X x,y,z\in X x , y , z ∈ X ; recall that φ \varphi φ is monotone, i.e., every clause contains only positive literals. Similar to the variable gadget, we also use for the clause gadget the same set of colored edges as in § 3.2 but place their endpoints differently on the spine ≺ \prec ≺ . More formally, the clause gadget has three literal edges a x c b x c a_x^cb_x^c a x c b x c , a y c b y c a_y^cb_y^c a y c b y c , and a z c b z c a_z^cb_z^c a z c b z c , each of which inherits the color of the respective variable gadget, i.e., δ ( a q c b q c ) = col ( q ) \delta(a_q^cb_q^c)=\operatorname{col}(q) δ ( a q c b q c ) = col ( q ) for q ∈ { x , y , z } q\in\{x,y,z\} q ∈ { x , y , z } . Moreover, the gadget has four validator edges u x c v x c u_x^cv_x^c u x c v x c , u y c v y c u_y^cv_y^c u y c v y c , u z c v z c u_z^cv_z^c u z c v z c , and u ⊤ c v ⊤ c u_\top^cv_\top^c u ⊤ c v ⊤ c which have the color col ( c ) \operatorname{col}(c) col ( c ) . We set the budget b 1 ( col ( c ) ) = b 2 ( col ( c ) ) = 2 b_1(\operatorname{col}(c))=b_2(\operatorname{col}(c))=2 b 1 ( col ( c )) = b 2 ( col ( c )) = 2 and ensure that each literal edge is nested precisely by the corresponding validator edge, i.e., u x c ≺ a x c ≺ b x c ≺ v x c ≺ u y c ≺ a y c ≺ b y c ≺ v y c ≺ u z c ≺ a z c ≺ b z c ≺ v z c ≺ u ⊤ c ≺ v ⊤ c u_x^c\prec a_x^c\prec b_x^c\prec v_x^c\prec u_y^c\prec a_y^c\prec b_y^c\prec v_y^c\prec u_z^c\prec a_z^c\prec b_z^c\prec v_z^c\prec u_\top^c\prec v_\top^c u x c ≺ a x c ≺ b x c ≺ v x c ≺ u y c ≺ a y c ≺ b y c ≺ v y c ≺ u z c ≺ a z c ≺ b z c ≺ v z c ≺ u ⊤ c ≺ v ⊤ c ; see also Figure 8 b. We now show the following analogue to Lemma 3:
Lemma 18. Let ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ be an admissible 2-page queue layout of the constructed instance that contains the clause gadget for a clause c ∈ C c\in C c ∈ C with c = ( x ∨ y ∨ z ) c=(x\lor y\lor z) c = ( x ∨ y ∨ z ) . We have σ ( a q c b q c ) = σ ( s q t q ) \sigma(a_q^cb_q^c)=\sigma(s_qt_q) σ ( a q c b q c ) = σ ( s q t q ) for every q ∈ { x , y , z } q\in\{x,y,z\} q ∈ { x , y , z } . Moreover, there exist two literals p , q ∈ { x , y , z } p,q\in\{x,y,z\} p , q ∈ { x , y , z } such that σ ( a p c b p c ) ≠ σ ( a q c b q c ) \sigma(a_p^cb_p^c)\ne\sigma(a_q^cb_q^c) σ ( a p c b p c ) = σ ( a q c b q c ) .
Proof. Let c ∈ C c\in C c ∈ C be a clause of φ \varphi φ with c = ( x ∨ y ∨ z ) c=(x\lor y\lor z) c = ( x ∨ y ∨ z ) . The arguments for the first statement are analogous to those for Lemma 3 .
For the second statement, we observe that u q c ≺ a q c ≺ b q c ≺ v q c u_q^c\prec a_q^c\prec b_q^c\prec v_q^c u q c ≺ a q c ≺ b q c ≺ v q c implies σ ( a q c b q c ) ≠ σ ( u q c v q c ) \sigma(a_q^cb_q^c)\ne\sigma(u_q^cv_q^c) σ ( a q c b q c ) = σ ( u q c v q c ) for every q ∈ { x , y , z } q\in\{x,y,z\} q ∈ { x , y , z } . Thus, any solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ with σ ( a x c b x c ) = σ ( a y c b y c ) = σ ( a z c b z c ) \sigma(a_x^cb_x^c)=\sigma(a_y^cb_y^c)=\sigma(a_z^cb_z^c) σ ( a x c b x c ) = σ ( a y c b y c ) = σ ( a z c b z c ) must also have σ ( u x c v x c ) = σ ( u y c v y c ) = σ ( u z c v z c ) \sigma(u_x^cv_x^c)=\sigma(u_y^cv_y^c)=\sigma(u_z^cv_z^c) σ ( u x c v x c ) = σ ( u y c v y c ) = σ ( u z c v z c ) . Since these edges have color col ( c ) \operatorname{col}(c) col ( c ) we derive that ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ cannot be a solution since b 1 ( col ( c ) ) = b 2 ( col ( c ) ) = 2 < 3 b_1(\operatorname{col}(c))=b_2(\operatorname{col}(c))=2<3 b 1 ( col ( c )) = b 2 ( col ( c )) = 2 < 3 . Hence, if ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution, then σ ( a x c b x c ) = σ ( a y c b y c ) = σ ( a z c b z c ) \sigma(a_x^cb_x^c)=\sigma(a_y^cb_y^c)=\sigma(a_z^cb_z^c) σ ( a x c b x c ) = σ ( a y c b y c ) = σ ( a z c b z c ) cannot hold, and we can find p , q ∈ c p,q\in c p , q ∈ c that fulfills the second claim.
Putting Everything Together
For an instance φ \varphi φ of Monotone Not All Equal 3Sat-E4 with variables X = { x 1 , … , x η } X=\{x_1,\ldots,x_\eta\} X = { x 1 , … , x η } and clauses C = { c 1 , … , c μ } C=\{c_1,\ldots,c_\mu\} C = { c 1 , … , c μ } , we replace every variable and clause with its corresponding gadget and order them on the spine by their index (where variables precede the clauses). The following theorem establishes correctness of the reduction.
Theorem 19. Fixed Order Capacitated Queue Layout is NP-complete even when restricted to balanced and tight instances ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) (G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) with ℓ = 2 \ell=2 ℓ = 2 and where every connected component of Q ( G , ≺ ) Q(G,\prec) Q ( G , ≺ ) has at most five vertices.
Proof. Containment in NP is immediate and we proceed with showing NP-hardness. Let φ \varphi φ be an instance of Monotone Not All Equal 3Sat-E4 on η \eta η variables X X X and μ \mu μ clauses C C C . We construct the above-described instance I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I}=(G,\delta,\prec,\ell=2,b_1,b_2) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) of FO CapQL. A careful analysis of the gadgets shows that it can be constructed in O ( η + μ ) O(\eta+\mu) O ( η + μ ) time, has two pages, O ( η + μ ) O(\eta+\mu) O ( η + μ ) colors, and for each color c ∈ [ χ ] c\in[\chi] c ∈ [ χ ] it holds b 1 ( c ) = b 2 ( c ) = ∣ δ − 1 ( c ) ∣ / 2 b_1(c)=b_2(c)=|\delta^{-1}(c)|/2 b 1 ( c ) = b 2 ( c ) = ∣ δ − 1 ( c ) ∣/2 . For the same reason as for Theorem 4 , we can observe that the largest connected component of Q Q Q is induced by the variable gadgets and consists of five vertices; recall also Figure 8 . We conclude the proof by establishing correctness of the reduction.
( ⇒ ) (\Rightarrow) ( ⇒ ) Assume that φ \varphi φ admits a solution Ψ : X → { 0 , 1 } \Psi:X\to\{0,1\} Ψ : X → { 0 , 1 } . We now show that also I \mathcal{I} I admits a solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ . To this end, consider a variable x ∈ X x\in X x ∈ X and its corresponding variable gadget. As in the proof of Theorem 4 , we assign σ ( s x t x ) \sigma(s_xt_x) σ ( s x t x ) to the first page if and only if x x x is set to false. All other edges are assigned to the page p ∈ { 1 , 2 } ∖ { σ ( s x t x ) } p\in\{1,2\}\setminus\{\sigma(s_xt_x)\} p ∈ { 1 , 2 } ∖ { σ ( s x t x )} ; recall also Observation 17 . Since edges in the variable gadget are only in conflict with the selecting edge (if at all), this assignment does not introduce any nesting. Since the selecting and dummy edge are on different pages (and the only edges of color d x d_x d x ), we match the budget for d x d_x d x on both pages. For a clause c = ( x ∨ y ∨ z ) ∈ C c=(x\lor y\lor z)\in C c = ( x ∨ y ∨ z ) ∈ C , we assign the literal edge a q c b q c a_q^c b_q^c a q c b q c to the page σ ( s q t q ) \sigma(s_qt_q) σ ( s q t q ) for every q ∈ { x , y , z } q\in\{x,y,z\} q ∈ { x , y , z } . To prevent nesting, we set σ ( u q c v q c ) ≠ σ ( a q c b q c ) \sigma(u_q^c v_q^c)\ne\sigma(a_q^c b_q^c) σ ( u q c v q c ) = σ ( a q c b q c ) . Since Ψ \Psi Ψ witnesses the satisfiability of φ \varphi φ , there exists a unique variable q ∈ { x , y , z } q\in\{x,y,z\} q ∈ { x , y , z } whose truth assignment differs from the other two. We assign u q ⊤ v q ⊤ u_q^\top v_q^\top u q ⊤ v q ⊤ to the same page as u q c v q c u_q^c v_q^c u q c v q c , i.e., σ ( u q ⊤ v q ⊤ ) = σ ( u q c v q c ) \sigma(u_q^\top v_q^\top)=\sigma(u_q^c v_q^c) σ ( u q ⊤ v q ⊤ ) = σ ( u q c v q c ) . As u q ⊤ v q ⊤ u_q^\top v_q^\top u q ⊤ v q ⊤ is an isolated vertex in Q Q Q , this does not introduce any nesting. Moreover, each page contains precisely two edges of color col ( c ) \operatorname{col}(c) col ( c ) and we also have b 1 ( col ( c ) ) = b 2 ( col ( c ) ) = 2 b_1(\operatorname{col}(c))=b_2(\operatorname{col}(c))=2 b 1 ( col ( c )) = b 2 ( col ( c )) = 2 . To finally conclude that ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution to I \mathcal{I} I , we make the observation that in the variable gadget for any variable x ∈ X x\in X x ∈ X , all four edges a x i b x i a_x^i b_x^i a x i b x i , i = 1 , 2 , 3 , 4 i=1,2,3,4 i = 1 , 2 , 3 , 4 , are assigned to the same page, which is different from σ ( s x t x ) \sigma(s_xt_x) σ ( s x t x ) . For each of the four clauses c ∈ C c\in C c ∈ C that contain the variable x x x , we have σ ( s x t x ) = σ ( a x c b x c ) \sigma(s_xt_x)=\sigma(a_x^c b_x^c) σ ( s x t x ) = σ ( a x c b x c ) . Thus, every page contains exactly four edges of color col ( x ) \operatorname{col}(x) col ( x ) , which matches their budget.
(⇐) Assume that ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution for the instance I \mathcal{I} I of FoCapQl. We now construct a variable assignment Ψ : X → { 0 , 1 } \Psi:X\to\{0,1\} Ψ : X → { 0 , 1 } and consider a variable x ∈ X x\in X x ∈ X . We set x x x to true if and only if σ ( s x t x ) = 2 \sigma(s_xt_x)=2 σ ( s x t x ) = 2 . Consider an arbitrary clause c = ( x ∨ y ∨ z ) ∈ C c=(x\lor y\lor z)\in C c = ( x ∨ y ∨ z ) ∈ C . By Lemma 18 , we can find two literals p , q ∈ { x , y , z } p,q\in\{x,y,z\} p , q ∈ { x , y , z } such that σ ( s p t p ) = σ ( a p c b p c ) ≠ σ ( a q c b q c ) = σ ( s q t q ) \sigma(s_pt_p)=\sigma(a_p^c b_p^c)\ne\sigma(a_q^c b_q^c)=\sigma(s_qt_q) σ ( s p t p ) = σ ( a p c b p c ) = σ ( a q c b q c ) = σ ( s q t q ) . Thus, there are two variables p , q ∈ { x , y , z } p,q\in\{x,y,z\} p , q ∈ { x , y , z } such that Ψ ( p ) ≠ Ψ ( q ) \Psi(p)\ne\Psi(q) Ψ ( p ) = Ψ ( q ) , i.e., they witness that the clause c c c is satisfied under Ψ \Psi Ψ . Since c c c was selected arbitrarily, we conclude that Ψ \Psi Ψ is a solution to φ \varphi φ . ◀
FPT-Algorithm for Two Pages
Let I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I}=(G,\delta,\prec,\ell=2,b_1,b_2) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) be an instance of FoCapQl and note that ℓ = 2 \ell=2 ℓ = 2 , which implies m ∈ O ( n ) m\in O(n) m ∈ O ( n ) for positive instances [20 ] . As for Theorem 1 , from ℓ = 2 \ell=2 ℓ = 2 we can conclude that every connected component of the conflict graph Q ( G , ≺ ) Q(G,\prec) Q ( G , ≺ ) must be bipartite; edges are assigned to the same page if their corresponding vertices are in the same bipartition. If the number of connected components is bounded, we can branch over all valid page assignments. The proof of the following theorem is identical to Theorem 1 (by using Q Q Q instead of S S S ) and thus omitted.
Theorem 20. Fixed Order Capacitated Queue Layout with ℓ = 2 \ell=2 ℓ = 2 pages can be solved constructively in O ( 2 λ ⋅ ( n + χ ) + n 2 ) O(2^\lambda\cdot(n+\chi)+n^2) O ( 2 λ ⋅ ( n + χ ) + n 2 ) time (which is FPT in λ = ∣ C ( Q ( G , ≺ ) ) ∣ \lambda=|C(Q(G,\prec))| λ = ∣ C ( Q ( G , ≺ )) ∣ ).
Hardness for Three Pages
We now show that we cannot generalize Theorem 20 to more than two pages. More concretely, we show that FoCapQl is NP-complete for instances ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) (G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) with ℓ = 3 \ell=3 ℓ = 3 and where Q Q Q is connected. This rules out an XP-algorithm with respect to the number of pages ℓ \ell ℓ and the number of connected components λ \lambda λ .
Theorem 21. Fixed Order Capacitated Queue Layout is NP-complete even when restricted to instances ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) (G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) with ℓ = 3 \ell=3 ℓ = 3 and where Q ( G , ≺ ) Q(G,\prec) Q ( G , ≺ ) is connected.
Proof. We focus on NP-hardness since membership in NP is immediate. Let I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) \mathcal{I}=(G,\delta,\prec,\ell=2,b_1,b_2) I = ( G , δ , ≺ , ℓ = 2 , b 1 , b 2 ) be an instance of FoCapQl with ℓ = 2 \ell=2 ℓ = 2 and where ∑ c ∈ [ χ ] ( b 1 ( c ) + b 2 ( c ) ) = ∣ E ∣ \sum_{c\in[\chi]}(b_1(c)+b_2(c))=|E| ∑ c ∈ [ χ ] ( b 1 ( c ) + b 2 ( c )) = ∣ E ∣ . Recall from Theorem 19 that this problem setting is already NP-complete. Let χ \chi χ be the number of colors in I \mathcal{I} I . We introduce an edge u v uv uv and set δ ( u v ) = χ + 1 \delta(uv)=\chi+1 δ ( uv ) = χ + 1 . Moreover, we prepend u u u to ≺ \prec ≺ and append v v v to ≺ \prec ≺ . More formally, the new spine order ≺ ′ \prec' ≺ ′ is obtained by taking the transitive closure of u ≺ ′ w ≺ ′ v u\prec' w\prec' v u ≺ ′ w ≺ ′ v for every w ∈ V ( G ) w\in V(G) w ∈ V ( G ) and a ≺ b a\prec b a ≺ b for every a , b ∈ V ( G ) a,b\in V(G) a , b ∈ V ( G ) with a ≺ b a\prec b a ≺ b . To fix the budgets b i ′ b_i' b i ′ , i = 1 , 2 , 3 i=1,2,3 i = 1 , 2 , 3 , we set b i ′ ( c ) = b i ( c ) b_i'(c)=b_i(c) b i ′ ( c ) = b i ( c ) for i = 1 , 2 i=1,2 i = 1 , 2 and b 3 ′ ( c ) = 0 b_3'(c)=0 b 3 ′ ( c ) = 0 for every c ∈ [ χ ] c\in[\chi] c ∈ [ χ ] . Furthermore, we set b 1 ′ ( χ + 1 ) = b 2 ′ ( χ + 1 ) = 0 b_1'(\chi+1)=b_2'(\chi+1)=0 b 1 ′ ( χ + 1 ) = b 2 ′ ( χ + 1 ) = 0 and b 3 ′ ( χ + 1 ) = 1 b_3'(\chi+1)=1 b 3 ′ ( χ + 1 ) = 1 . Let I ′ = ( G ′ , δ ′ , ≺ ′ , ℓ ′ = 3 , ( b i ′ ) i ∈ [ ℓ ′ ] ) \mathcal{I}'=(G',\delta',\prec',\ell'=3,(b_i')_{i\in[\ell']}) I ′ = ( G ′ , δ ′ , ≺ ′ , ℓ ′ = 3 , ( b i ′ ) i ∈ [ ℓ ′ ] ) be the resulting instance of FoCapQl. We can observe that it can be constructed in polynomial time. The edge u v uv uv nests all other edges and the corresponding vertex is, therefore, adjacent to every other vertex in Q ( G ′ , ≺ ′ ) Q(G',\prec') Q ( G ′ , ≺ ′ ) , i.e., Q ( G ′ , ≺ ′ ) Q(G',\prec') Q ( G ′ , ≺ ′ ) is connected. The instances I \mathcal{I} I and I ′ \mathcal{I}' I ′ are equivalent up to the edge u v uv uv , for which the budgets ensure that it must be assigned to the third page and no other edge can be assigned to that page. Consequently, I \mathcal{I} I is a positive instance if and only if I ′ \mathcal{I}' I ′ is, which completes the proof.
Hardness for Monochromatic Instances
With Theorem 19, we have shown that F o C a p Q L \mathrm{FoCapQL} FoCapQL is NP-complete even for fairly restricted instances. However, the hardness reduction employed in Theorem 19 constructs instances with a linear number of colors. Therefore, it is natural to ask for the complexity when parameterized by the number of colors χ \chi χ . In this section, we show that F o C a p Q L \mathrm{FoCapQL} FoCapQL remains NP-complete even when χ = 1 \chi= 1 χ = 1 , i.e., every edge of G G G has the same color, which we call monochromatic instances , and, as we see later, W[1 ] -hard with respect to ℓ \ell ℓ .2
Overview of the Reduction. We reduce from the problem Bin Packing defined as follows. Given a set S S S of η \eta η items, each item x ∈ S x \in S x ∈ S associated with a weight w ( x ) ∈ N w(x) \in\mathbb{N} w ( x ) ∈ N , and k k k bins of capacity B ∈ N B \in\mathbb{N} B ∈ N , can S S S be partitioned into k k k subsets T 1 , … , T k T_1,\ldots,T_k T 1 , … , T k such that ∑ x ∈ T i w ( x ) ≤ B \sum_{x\in T_i} w(x) \le B ∑ x ∈ T i w ( x ) ≤ B for every i ∈ [ k ] i \in[k] i ∈ [ k ] ? Bin Packing is known to be strongly NP-complete and thus we can assume that the weight of each item x ∈ S x \in S x ∈ S and the capacity B B B are polynomially bounded in η \eta η [26 ] . Moreover, Bin Packing remains NP-complete even if ∑ x ∈ S w ( x ) = k ⋅ B \sum_{x\in S} w(x) = k \cdot B ∑ x ∈ S w ( x ) = k ⋅ B , i.e., if every bin must be filled up to its capacity B B B since we can simply introduce sufficiently many dummy items of weight one. On a high-level, in our reduction we represent every bin by a page. Assigning edges to that page should correspond to placing the items in a bin. To ensure correctness, we encode every item x ∈ S x \in S x ∈ S with a gadget consisting of two components. The first component consists of k − 1 k - 1 k − 1 pairwise nesting edges, a ( k − 1 ) (k - 1) ( k − 1 ) -rainbow, which must, therefore, be distributed among k − 1 k - 1 k − 1 pages. The second component consists of a star that represents the weight of x x x . By placing it below the ( k − 1 ) (k - 1) ( k − 1 ) -rainbow, all edges of the star must be placed on the unique page that does not contain an edge of the rainbow. Since the instance is monochromatic, we cannot use colors to distinguish edges from the star, which should count towards our bin-capacity, from those of the rainbow, whose sole purpose is to ensure correctness of the reduction. To circumvent this limitation, we scale the weight of every item by a large number to make it distinguishable from the rainbow edges.
Item Gadget. Let x ∈ S x \in S x ∈ S be an item. The item gadget for x x x contains k − 1 k - 1 k − 1 rainbow edges s x i t x i s_x^i t_x^i s x i t x i , i ∈ [ k − 1 ] i \in[k - 1] i ∈ [ k − 1 ] , and we order their endpoints along ≺ \prec ≺ as follows. We set s x i ≺ t x j s_x^i \prec t_x^j s x i ≺ t x j for every i , j ∈ [ k − 1 ] i,j \in[k - 1] i , j ∈ [ k − 1 ] . Moreover, we set s x i ≺ s x i + 1 s_x^i \prec s_x^{i+1} s x i ≺ s x i + 1 and t x i + 1 ≺ t x i t_x^{i+1} \prec t_x^i t x i + 1 ≺ t x i for every i ∈ [ k − 2 ] i \in[k - 2] i ∈ [ k − 2 ] .
We define w ^ ( x ) : = k ⋅ η ⋅ w ( x ) \widehat{w}(x) := k \cdot\eta\cdot w(x) w ( x ) := k ⋅ η ⋅ w ( x ) to be the scaled weight of the item x x x . Observe that the scaled weight of x x x is still polynomially bounded in η \eta η . The value star of the item gadget is a star K 1 , w ^ ( x ) K_{1,\widehat{w}(x)} K 1 , w ( x ) with center u x u_x u x and leaves v x i v_x^i v x i , i ∈ [ w ^ ( x ) ] i \in[\widehat{w}(x)] i ∈ [ w ( x )] . We place the value star below the rainbow edges, i.e., set s x k ≺ u x ≺ v x 1 ≺ v x 2 ≺ ⋯ ≺ v x w ^ ( x ) ≺ t x k − 1 s_x^k \prec u_x \prec v_x^1 \prec v_x^2 \prec\cdots\prec v_x^{\widehat{w}(x)} \prec t_x^{k-1} s x k ≺ u x ≺ v x 1 ≺ v x 2 ≺ ⋯ ≺ v x w ( x ) ≺ t x k − 1 and take the transitive closure of this and the above-defined relations; see the blue edges in Figure 9 . Since the rainbow edges are pairwise nesting and each rainbow edge nests the value star, we observe:
Figure 9. The item gadget for an item x ∈ S x \in S x ∈ S and with k = 4 k=4 k = 4 . Although the constructed instance is monochromatic, we color edges from the rainbow and the item purple and blue, respectively.
Observation 22. In every k k k -page queue layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ of the item gadget for an item x ∈ S x \in S x ∈ S we have σ ( s i x t i x ) ≠ σ ( s j x t j x ) \sigma(s_i^x t_i^x) \ne\sigma(s_j^x t_j^x) σ ( s i x t i x ) = σ ( s j x t j x ) for every i , j ∈ [ k − 1 ] i,j \in[k-1] i , j ∈ [ k − 1 ] , i ≠ j i \ne j i = j . Moreover, we have σ ( s i x t i x ) ≠ σ ( u x v j x ) \sigma(s_i^x t_i^x) \ne\sigma(u_x v_j^x) σ ( s i x t i x ) = σ ( u x v j x ) for every i ∈ [ k − 1 ] i \in[k-1] i ∈ [ k − 1 ] and j ∈ [ w ^ ( x ) ] j \in[\widehat{w}(x)] j ∈ [ w ( x )] and thus σ ( u x v i x ) = σ ( u x v j x ) \sigma(u_x v_i^x)=\sigma(u_x v_j^x) σ ( u x v i x ) = σ ( u x v j x ) for every i , j ∈ [ w ^ ( x ) ] i,j \in[\widehat{w}(x)] i , j ∈ [ w ( x )] .
Assigning the value star to page p ∈ [ k ] p \in[k] p ∈ [ k ] should correspond to placing the item in the p p p th bin. Observation 22 ensures that this equivalence between the two problems is well-defined.
Putting Everything Together. With the item gadget at hand, we are now ready to describe the complete reduction. Let ( S , w , k , B ) (S,w,k,B) ( S , w , k , B ) be an instance of Bin Packing with items S = { x 1 , … , x η } S=\{x_1,\ldots,x_\eta\} S = { x 1 , … , x η } , η = ∣ S ∣ \eta=|S| η = ∣ S ∣ . For every item x i x_i x i , we construct the item gadget and order all item gadgets on the spine based on the index of the item they represent. Moreover, we introduce η − k \eta-k η − k dummy edges which will help us to satisfy the budget on every page. We place them at the end of the spine such that they are not in conflict with each other or any edge from an item gadget. Finally, we give every edge e e e the color δ ( e ) = 1 \delta(e)=1 δ ( e ) = 1 and set for each page p ∈ [ k ] p \in[k] p ∈ [ k ] the budget as b p ( 1 ) = k ⋅ η ⋅ B + ( η − 1 ) b_p(1)=k \cdot\eta\cdot B+(\eta-1) b p ( 1 ) = k ⋅ η ⋅ B + ( η − 1 ) . Figure 10 shows a small example of our reduction. We now establish its correctness.
Figure 10. The constructed instance of FoCapQL for an instance ( { x 1 , x 2 , x 3 , x 4 , x 5 } , w , 3 , 4 ) \left(\{x_1,x_2,x_3,x_4,x_5\},w,3,4\right) ( { x 1 , x 2 , x 3 , x 4 , x 5 } , w , 3 , 4 ) of Bin Packing with w ( x 1 ) = 3 w(x_1)=3 w ( x 1 ) = 3 , w ( x 2 ) = w ( x 3 ) = 2 w(x_2)=w(x_3)=2 w ( x 2 ) = w ( x 3 ) = 2 , w ( x 4 ) = 1 w(x_4)=1 w ( x 4 ) = 1 , and w ( x 5 ) = 4 w(x_5)=4 w ( x 5 ) = 4 . For illustration purposes, we color rainbow and item edges purple and blue, respectively. Each bold edge represents k ⋅ η = 15 k \cdot\eta=15 k ⋅ η = 15 edges. Gray bands indicate the different items and pages are stacked vertically.
Theorem 23. Fixed Order Capacitated Queue Layout is NP-complete even for instances that are balanced, tight, and monochromatic.
Proof. Let ( S = { x 1 , … , x η } , w , k , B ) (S=\{x_1,\ldots,x_\eta\},w,k,B) ( S = { x 1 , … , x η } , w , k , B ) be an instance of Bin Packing such that ∑ x ∈ S w ( x ) = k ⋅ B \sum_{x\in S}w(x)=k \cdot B ∑ x ∈ S w ( x ) = k ⋅ B and B B B and w ( x ) w(x) w ( x ) are polynomially bounded in η \eta η for every x ∈ S x \in S x ∈ S . In the following, we assume without loss of generality that η ≥ k ≥ 2 \eta\ge k \ge2 η ≥ k ≥ 2 (otherwise, we can return a trivial positive or negative instance of FoCapQL). Moreover, let I = ( G , δ , ≺ , k , ( b p ) p ∈ [ k ] ) \mathcal{I}=(G,\delta,\prec,k,(b_p)_{p\in[k]}) I = ( G , δ , ≺ , k , ( b p ) p ∈ [ k ] ) be the instance of FoCapQL that we construct. Note that I \mathcal{I} I can be constructed in polynomial time since w ( x ) w(x) w ( x ) is polynomially bounded in η \eta η for every x ∈ S x\in S x ∈ S . Moreover, we can observe that I \mathcal{I} I is monochromatic, and we have ℓ = k \ell=k ℓ = k and b p ( 1 ) = b q ( 1 ) b_p(1)=b_q(1) b p ( 1 ) = b q ( 1 ) for every two pages p , q ∈ [ ℓ ] p,q\in[\ell] p , q ∈ [ ℓ ] . It remains to show correctness of the reduction.
(⇒) Assume that ( S , w , k , B ) (S,w,k,B) ( S , w , k , B ) is a positive instance of Bin Packing and let T 1 , … , T k T_1,\ldots,T_k T 1 , … , T k be a partitioning of S S S that witnesses this. We construct a linear layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ of I \mathcal{I} I as follows. Consider a bin T i T_i T i , i ∈ [ k ] i\in[k] i ∈ [ k ] . Let x ∈ T i x\in T_i x ∈ T i be an item in the i i i th bin and consider the corresponding item gadget. First, we assign all edges of the star K 1 , w ^ ( x ) K_{1,\widehat{w}(x)} K 1 , w ( x ) to page i i i , i.e., we set σ ( u x v x j ) = i \sigma(u_xv_x^j)=i σ ( u x v x j ) = i , j ∈ [ w ^ ( x ) ] j\in[\widehat{w}(x)] j ∈ [ w ( x )] . Next, distribute the k − 1 k-1 k − 1 rainbow edges in the gadget among the remaining k − 1 k-1 k − 1 pages, i.e., for every page p ∈ [ k ] ∖ { i } p\in[k]\setminus\{i\} p ∈ [ k ] ∖ { i } there is precisely one q ∈ [ k − 1 ] q\in[k-1] q ∈ [ k − 1 ] such that σ ( s x q t x q ) = p \sigma(s_x^qt_x^q)=p σ ( s x q t x q ) = p . Observe that this resembles the necessary page assignment from Observation 22. In particular, no two rainbow edges from the gadget are assigned to the same page or to the page of the star K 1 , w ^ ( x ) K_{1,\widehat{w}(x)} K 1 , w ( x ) (which itself does not introduce a nesting). Since ∑ x ∈ S w ( x ) = k ⋅ B \sum_{x\in S}w(x)=k\cdot B ∑ x ∈ S w ( x ) = k ⋅ B and T 1 , … , T k T_1,\ldots,T_k T 1 , … , T k is a solution, we have ∑ x ∈ T i w ( x ) = B \sum_{x\in T_i}w(x)=B ∑ x ∈ T i w ( x ) = B . Overall, we have assigned ∑ x ∈ T i w ^ ( x ) = k ⋅ η ⋅ B \sum_{x\in T_i}\widehat{w}(x)=k\cdot\eta\cdot B ∑ x ∈ T i w ( x ) = k ⋅ η ⋅ B edges to page i i i so far. Doing the same procedure for the other bins T j T_j T j , j ≠ i j\ne i j = i , we assign η − ∣ T i ∣ \eta-|T_i| η − ∣ T i ∣ edges in addition to page i i i . These account for the items that are placed in some bin T j T_j T j , j ≠ i j\ne i j = i , for which we will assign one rainbow edge to page i i i . We “fill up” page i i i to the budget b i ( 1 ) b_i(1) b i ( 1 ) , by assigning ∣ T i ∣ − 1 |T_i|-1 ∣ T i ∣ − 1 dummy edges to page i i i ; we argue in the end that there are sufficiently many dummy edges. Furthermore, recall that they do not nest any other edge. We repeat these steps for every item in the bin T i T_i T i , and for every bin of the solution to eventually obtain a linear layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ . Thanks to the above arguments, ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is an admissible queue layout. It remains to argue that there are enough dummy edges to fill up every page. We assign k ⋅ η ⋅ B k\cdot\eta\cdot B k ⋅ η ⋅ B non-rainbow edges from the item gadgets to every page. Thus, every page “needs” η − 1 \eta-1 η − 1 additional edges. There are in total η ⋅ ( k − 1 ) \eta\cdot(k-1) η ⋅ ( k − 1 ) rainbow edges, and we need in total k ⋅ ( η − 1 ) k\cdot(\eta-1) k ⋅ ( η − 1 ) to fill up the page budgets. This gives an imbalance of precisely k ⋅ ( η − 1 ) − ( η ⋅ ( k − 1 ) ) = η − k k\cdot(\eta-1)-(\eta\cdot(k-1))=\eta-k k ⋅ ( η − 1 ) − ( η ⋅ ( k − 1 )) = η − k edges, which is the number of dummy edges. Combining all, we conclude that I \mathcal{I} I is a positive instance of FoCapQL.
(⇐) Assume that I \mathcal{I} I admits a solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ . We now construct a partitioning of S S S into k k k bins T 1 , … , T k T_1,\ldots,T_k T 1 , … , T k . Consider an item x ∈ S x\in S x ∈ S and the corresponding item gadget. Due to Observation 22, there exists a page i ∈ [ k ] i\in[k] i ∈ [ k ] that contains every edge of the star K 1 , w ^ ( x ) K_{1,\widehat{w}(x)} K 1 , w ( x ) . We place the item in the bin T i T_i T i and repeat this process for the remaining items of S S S . Towards arguing that T 1 , … , T k T_1,\ldots,T_k T 1 , … , T k is a solution of ( S , w , k , B ) (S,w,k,B) ( S , w , k , B ) we assume that it is not. Since we have ∑ x ∈ S w ( x ) = k ⋅ B \sum_{x\in S}w(x)=k\cdot B ∑ x ∈ S w ( x ) = k ⋅ B , this means there exists a bin T i T_i T i such that ∑ x ∈ T i w ( x ) ≠ B \sum_{x\in T_i}w(x)\ne B ∑ x ∈ T i w ( x ) = B . First, assume that ∑ x ∈ T i w ( x ) ≥ B + 1 > B \sum_{x\in T_i}w(x)\ge B+1>B ∑ x ∈ T i w ( x ) ≥ B + 1 > B . By construction, this implies that we have assigned at least ∑ x ∈ T i w ^ ( x ) \sum_{x\in T_i}\widehat{w}(x) ∑ x ∈ T i w ( x ) edges to page i i i . Observe that we have ∑ x ∈ T i w ^ ( x ) ≥ k ⋅ η ⋅ ( B + 1 ) \sum_{x\in T_i}\widehat{w}(x)\ge k\cdot\eta\cdot(B+1) ∑ x ∈ T i w ( x ) ≥ k ⋅ η ⋅ ( B + 1 ) . However, the budget of page i i i is b i ( 1 ) = k ⋅ η ⋅ B + ( η − 1 ) < k ⋅ η ⋅ B + k ⋅ η b_i(1)=k\cdot\eta\cdot B+(\eta-1)<k\cdot\eta\cdot B+k\cdot\eta b i ( 1 ) = k ⋅ η ⋅ B + ( η − 1 ) < k ⋅ η ⋅ B + k ⋅ η (recall that we have k ≥ 2 k\ge2 k ≥ 2 ). This contradicts the assumption that ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ is a solution. Hence, a bin T i T_i T i with ∑ x ∈ T i w ( x ) > B \sum_{x\in T_i}w(x)>B ∑ x ∈ T i w ( x ) > B cannot exist. Now, assume that there is a bin T i T_i T i with ∑ x ∈ T i w ( x ) < B \sum_{x\in T_i}w(x)<B ∑ x ∈ T i w ( x ) < B . From ∑ x ∈ S w ( x ) = k ⋅ B \sum_{x\in S}w(x)=k\cdot B ∑ x ∈ S w ( x ) = k ⋅ B and the pigeonhole principle, this means that there is a different bin T j T_j T j , j ∈ [ k ] j\in[k] j ∈ [ k ] , j ≠ i j\ne i j = i , such that ∑ x ∈ T j w ( x ) > B \sum_{x\in T_j}w(x)>B ∑ x ∈ T j w ( x ) > B . However, by the above reasoning this cannot be the case. Combining all, we conclude that T 1 , … , T k T_1,\ldots,T_k T 1 , … , T k is a solution of ( S , w , k , B ) (S,w,k,B) ( S , w , k , B ) .
Consequences of Theorem 23. We can observe that the hardness-construction behind Theorem 23 creates instances that have as many pages as the instance ( S , w , k , B ) (S,w,k,B) ( S , w , k , B ) of Bin Packing has bins, i.e., k k k . This, together with the fact that the hardness already applies for monochromatic instances, allows us to derive hardness results with respect to several parameter combinations, which we discuss in the following. First, note that unary Bin Packing is W[1 ] -hard with respect to the number of bins k k k [34 ] :
Corollary 24. Fixed Order Capacitated Queue Layout is W[1 ] -hard when parameterized by the number of pages ℓ \ell ℓ even when restricted to balanced and monochromatic instances.
Second, we can use the same “trick” as for Theorem 21 to turn the conflict graph Q Q Q into a connected graph. To this end, we add a new edge u v uv uv of color δ ( u v ) = 2 \delta(uv)=2 δ ( uv ) = 2 that spans the entire instance, i.e., which ensures that Q Q Q is connected. By adding a page k + 1 k+1 k + 1 and adjusting the budget of every page p ∈ [ k + 1 ] p \in[k+1] p ∈ [ k + 1 ] such that precisely the additional edge u v uv uv is placed on page k + 1 k+1 k + 1 , we preserve equivalence between the two instances:
Theorem 25. Fixed Order Capacitated Queue Layout is NP-complete even when restricted to tight instances ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) (G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) where χ = 2 \chi=2 χ = 2 and Q ( G , ≺ ) Q(G,\prec) Q ( G , ≺ ) is connected.
Proof. As already observed several times, NP-membership is immediate. Towards showing NP-hardness, recall first that FoCapQL is NP-complete even when restricted to monochromatic instances by Theorem 23 . Let I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) \mathcal{I}=(G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) be such a monochromatic instance. We now construct an instance I ′ = ( G ′ , δ ′ , ≺ ′ , ℓ ′ = ℓ + 1 , ( b i ′ ) i ∈ [ ℓ ′ ] ) \mathcal{I}'=(G',\delta',\prec',\ell'=\ell+1,(b'_i)_{i\in[\ell']}) I ′ = ( G ′ , δ ′ , ≺ ′ , ℓ ′ = ℓ + 1 , ( b i ′ ) i ∈ [ ℓ ′ ] ) of FoCapQL as follows. For G ′ G' G ′ , we take G G G and introduce two new vertices u u u and v v v which are adjacent. We set δ ′ ( u v ) = 2 \delta'(uv)=2 δ ′ ( uv ) = 2 and δ ′ ( e ) = δ ( e ) \delta'(e)=\delta(e) δ ′ ( e ) = δ ( e ) for all remaining edges of G ′ G' G ′ . The new spine order ≺ ′ \prec' ≺ ′ is obtained by taking the transitive closure of u ≺ ′ w ≺ ′ v u\prec' w\prec' v u ≺ ′ w ≺ ′ v for every w ∈ V ( G ) w\in V(G) w ∈ V ( G ) and a ≺ ′ b a\prec' b a ≺ ′ b for every a , b ∈ V ( G ) a,b\in V(G) a , b ∈ V ( G ) with $a\prec b. For the budgets, we set b p ′ ( 1 ) = b p ( 1 ) b'_p(1)=b_p(1) b p ′ ( 1 ) = b p ( 1 ) and b p ′ ( 2 ) = 0 b'_p(2)=0 b p ′ ( 2 ) = 0 for every page p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] . Moreover, we set b ℓ + 1 ′ ( 1 ) = 0 b'_{\ell+1}(1)=0 b ℓ + 1 ′ ( 1 ) = 0 and b ℓ + 1 ′ ( 2 ) = 1 b'_{\ell+1}(2)=1 b ℓ + 1 ′ ( 2 ) = 1 .
Since u v uv uv nests every edge e ∈ E ( G ) e\in E(G) e ∈ E ( G ) , Q ( G ′ , ≺ ′ ) Q(G',\prec') Q ( G ′ , ≺ ′ ) is connected. I ′ \mathcal{I}' I ′ can be constructed in polynomial time. Moreover, by the definition of the budgets b ′ b' b ′ , we can transform every solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ of I \mathcal{I} I to a solution ⟨ ≺ ′ , σ ′ ⟩ \langle\prec',\sigma'\rangle ⟨ ≺ ′ , σ ′ ⟩ of I ′ \mathcal{I}' I ′ by assigning the edge u v uv uv to page ℓ + 1 \ell+1 ℓ + 1 . Symmetrically, a solution ⟨ ≺ ′ , σ ′ ⟩ \langle\prec',\sigma'\rangle ⟨ ≺ ′ , σ ′ ⟩ of I ′ \mathcal{I}' I ′ can be transformed into a solution ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ of I \mathcal{I} I by dropping the edge u v uv uv , which shows correctness and completes the proof. ◀
Third, by applying (the reasoning that led to) Corollary 24 to Theorem 25 and observing that we only need one additional page to ensure that Q Q Q is connected, we can conclude:
Corollary 26. Fixed Order Capacitated Queue Layout is W[1 ] -hard when parameterized by the number of pages ℓ \ell ℓ even when restricted to instances ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) (G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) where χ = 2 \chi=2 χ = 2 and Q ( G , ≺ ) Q(G,\prec) Q ( G , ≺ ) is connected.
Parameterizing by the Number of Pages and Colors
In this section, we show that FoCapQL is in XP when parameterized by the number of pages ℓ \ell ℓ and the number of colors χ \chi χ . By Corollary 24 , this result is the “best possible” we can hope for. Moreover, FoCapQL is paraNP-hard when parameterized by ℓ \ell ℓ and χ \chi χ alone; recall Theorems 19 and 23 . On a high-level, we employ a dynamic program (DP), which considers the edges in lexicographic order < < < according to ≺ \prec ≺ , i.e., for two edges u v , x y ∈ E ( G ) uv,xy\in E(G) uv , x y ∈ E ( G ) with u ≺ v u\prec v u ≺ v and x ≺ y x\prec y x ≺ y we have u v < x y uv<xy uv < x y if and only if u ≺ x u\prec x u ≺ x , or u = x u=x u = x and v ≺ y v\prec y v ≺ y . When processing the next edge u v uv uv , we consider every possible page assignment for u v uv uv . Processing the edges in lexicographic order has the algorithmic advantage that we can easily prevent two nesting edges as the following lemma underlines; see also Figure 11 .
Figure 11. Visualization of Lemma 27. Observe that only the edges u v uv uv and x 1 y 1 x_1y_1 x 1 y 1 are nesting. The edges u v uv uv and u y 1 uy_1 u y 1 are not nesting although y 1 ≺ v y_1 \prec v y 1 ≺ v . Note that y 1 ≺ v y_1 \prec v y 1 ≺ v implies u y 1 < u v uy_1 < uv u y 1 < uv .
Lemma 27. Let u v , x y ∈ E uv,xy \in E uv , x y ∈ E be two edges such that u ≺ v u \prec v u ≺ v , x ≺ y x \prec y x ≺ y and u v < x y uv < xy uv < x y . The edges u v uv uv and x y xy x y are nesting if and only if y ≺ v y \prec v y ≺ v .
Proof. Let u v , x y ∈ E uv,xy \in E uv , x y ∈ E be two edges as in the statement.
( ⇒ ) (\Rightarrow) ( ⇒ ) Assume that the two edges are nesting, which means that we have u ≺ x ≺ y ≺ v u \prec x \prec y \prec v u ≺ x ≺ y ≺ v or x ≺ u ≺ v ≺ y x \prec u \prec v \prec y x ≺ u ≺ v ≺ y . Only the former is possible by u v < x y uv < xy uv < x y , which completes this direction.
( ⇐ ) (\Leftarrow) ( ⇐ ) Assume that we have y ≺ v y \prec v y ≺ v . From u v < x y uv < xy uv < x y we get that u ⪯ x u \preceq x u ⪯ x must hold. Observe that u = x u=x u = x is not possible since u = x u=x u = x and y ≺ v y \prec v y ≺ v would imply x y < u v xy < uv x y < uv . Thus, we have u ≺ x u \prec x u ≺ x and together with x ≺ y x \prec y x ≺ y and y ≺ v y \prec v y ≺ v , this implies u ≺ x ≺ y ≺ v u \prec x \prec y \prec v u ≺ x ≺ y ≺ v , i.e., the two edges nest.
:::
We can now present our XP-algorithm, which can be seen as a more involved variant of the classical polynomial-time algorithm for fixed-order queue layouts [29 ] .
Theorem 28. Fixed Order Capacitated Queue Layout can be solved constructively in O ( ℓ ⋅ ( m + 1 ) ( ℓ ⋅ χ ) + 1 ⋅ ( n + 1 ) ℓ + 1 ) O\left(\ell\cdot(m+1)^{(\ell\cdot\chi)+1}\cdot(n+1)^{\ell+1}\right) O ( ℓ ⋅ ( m + 1 ) ( ℓ ⋅ χ ) + 1 ⋅ ( n + 1 ) ℓ + 1 ) time (which is XP in ℓ + χ \ell+\chi ℓ + χ ).
Proof. For the following arguments, fix an instance I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) \mathcal{I}=(G,\delta,\prec,\ell,(b_p)_{p\in[\ell]}) I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) of FoCapQL. We first order the edges of G G G lexicographically according to ≺ \prec ≺ . This preprocessing step can be done in O ( m log m ) O(m\log m) O ( m log m ) time. Let < < < denote the resulting order of the edges. For ease of presentation, we re-index the edges E = { e 1 , … , e m } E=\{e_1,\ldots,e_m\} E = { e 1 , … , e m } of G G G according to < < < , i.e., for every two edges e i , e j ∈ E e_i,e_j\in E e i , e j ∈ E we have e i < e j e_i<e_j e i < e j if and only if i < j i<j i < j . Furthermore, we index the vertices V = { v 1 , … , v n } V=\{v_1,\ldots,v_n\} V = { v 1 , … , v n } of G G G according to ≺ \prec ≺ , i.e., for every two vertices v i , v j ∈ V v_i,v_j\in V v i , v j ∈ V we have i < j i<j i < j if and only if v i ≺ v j v_i\prec v_j v i ≺ v j . Call this first step the preprocessing step .
The Algorithm. We employ a dynamic programming (DP) approach that considers the edges according to the lexicographic order < < < and evaluates all potential page assignments for each new edge. Thanks to Lemma 27 it is sufficient to store for each page, in addition to the number of edges on that page of each color, the rightmost vertex which is incident to an edge on that page. More formally, we consider states , which are defined by an edge e i ∈ E e_i\in E e i ∈ E , a number x p c ∈ [ m ] 0 x_p^c\in[m]_0 x p c ∈ [ m ] 0 for every page p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] and color c ∈ [ χ ] c\in[\chi] c ∈ [ χ ] , and up to one vertex v p ∈ V ∪ { ⊥ } v_p\in V\cup\{\perp\} v p ∈ V ∪ { ⊥ } for every page p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] . For a state I I I , we use e ( I ) e(I) e ( I ) to address the edge e i e_i e i , x ( I , p , c ) x(I,p,c) x ( I , p , c ) to address x p c x_p^c x p c for p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] and c ∈ [ χ ] c\in[\chi] c ∈ [ χ ] , and v ( I , p ) v(I,p) v ( I , p ) to address the vertex v p v_p v p for p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] or ⊥ \perp ⊥ if there is no such vertex v p v_p v p . Let G i = ( V , E i ) G_i=(V,E_i) G i = ( V , E i ) , where E i = { e 1 , … , e i } E_i=\{e_1,\ldots,e_i\} E i = { e 1 , … , e i } . We call a state I I I with e ( I ) = e i e(I)=e_i e ( I ) = e i feasible if and only if there exists an ℓ \ell ℓ -page queue layout ⟨ ≺ , σ ⟩ \langle\prec,\sigma\rangle ⟨ ≺ , σ ⟩ of G i G_i G i such that there are precisely x ( I , p , c ) x(I,p,c) x ( I , p , c ) edges of color c c c assigned to page p p p , for every c ∈ [ χ ] c\in[\chi] c ∈ [ χ ] and p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] , and v ( I , p ) v(I,p) v ( I , p ) is the rightmost vertex which is incident to an edge on page p p p , for every p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] . If no edge is assigned to a page p p p , then we require v ( I , p ) = ⊥ v(I,p)=\perp v ( I , p ) =⊥ . In our algorithm, we maintain a binary DP-table D D D which should store, for every state I I I , whether it is feasible.
Consider a state I I I . We now describe how to compute D [ I ] D[I] D [ I ] , assuming that D [ I ′ ] D[I'] D [ I ′ ] has already been computed for every state I ′ I' I ′ where e ( I ′ ) = e j e(I')=e_j e ( I ′ ) = e j , e ( I ) = e i e(I)=e_i e ( I ) = e i , and j < i j<i j < i . First, we consider the base case where e ( I ) = e 1 = u v e(I)=e_1=uv e ( I ) = e 1 = uv , u ≺ v u\prec v u ≺ v . We set D [ I ] = 1 D[I]=1 D [ I ] = 1 if and only if there exists a page p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] such that
เงินไทยฟรี (1) เงินไทยฟรี \tag*{(1)} เงินไทยฟรี (1)
B1. x ( I , p , δ ( e 1 ) ) = 1 x(I,p,\delta(e_1))=1 x ( I , p , δ ( e 1 )) = 1 ,
B2. x ( I , p , c ) = 0 x(I,p,c)=0 x ( I , p , c ) = 0 for every color c ∈ [ χ ] ∖ { δ ( e 1 ) } c\in[\chi]\setminus\{\delta(e_1)\} c ∈ [ χ ] ∖ { δ ( e 1 )} ,
B3. x ( I , q , c ) = 0 x(I,q,c)=0 x ( I , q , c ) = 0 for every page q ∈ [ ℓ ] ∖ { p } q\in[\ell]\setminus\{p\} q ∈ [ ℓ ] ∖ { p } and color c ∈ [ χ ] c\in[\chi] c ∈ [ χ ] ,
B4. v ( I , p ) = v v(I,p)=v v ( I , p ) = v , and
B5. v ( I , q ) = ⊥ v(I,q)=\perp v ( I , q ) =⊥ for every page q ∈ [ ℓ ] ∖ { p } q\in[\ell]\setminus\{p\} q ∈ [ ℓ ] ∖ { p } .
Observe that the above conditions encode the assignment of the edge e 1 e_1 e 1 to the page p p p .
Now consider the general case with e ( I ) = e i = u v e(I)=e_i=uv e ( I ) = e i = uv , u ≺ v u\prec v u ≺ v , for some i > 1 i>1 i > 1 . We set D [ I ] = 1 D[I]=1 D [ I ] = 1 if and only if there exists a state I ′ I' I ′ with e ( I ′ ) = e i − 1 e(I')=e_{i-1} e ( I ′ ) = e i − 1 , D [ I ′ ] = 1 D[I']=1 D [ I ′ ] = 1 , and a page p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] such that all of the following conditions are satisfied.
G1. x ( I , p , δ ( e i ) ) = x ( I ′ , p , δ ( e i ) ) + 1 x(I,p,\delta(e_i))=x(I',p,\delta(e_i))+1 x ( I , p , δ ( e i )) = x ( I ′ , p , δ ( e i )) + 1 ,
G2. x ( I , p , c ) = x ( I ′ , p , c ) x(I,p,c)=x(I',p,c) x ( I , p , c ) = x ( I ′ , p , c ) for every color c ∈ [ χ ] ∖ { δ ( e i ) } c\in[\chi]\setminus\{\delta(e_i)\} c ∈ [ χ ] ∖ { δ ( e i )} ,
G3. x ( I , q , c ) = x ( I ′ , q , c ) x(I,q,c)=x(I',q,c) x ( I , q , c ) = x ( I ′ , q , c ) for every page q ∈ [ ℓ ] ∖ { p } q\in[\ell]\setminus\{p\} q ∈ [ ℓ ] ∖ { p } and color c ∈ [ χ ] c\in[\chi] c ∈ [ χ ] ,
G4. v ( I ′ , p ) = ⊥ v(I',p)=\perp v ( I ′ , p ) =⊥ or v ( I ′ , p ) = w v(I',p)=w v ( I ′ , p ) = w for some w ∈ V w\in V w ∈ V with w ⪯ v w\preceq v w ⪯ v ,
G5. v ( I , p ) = v v(I,p)=v v ( I , p ) = v , and
G6. v ( I , q ) = v ( I ′ , q ) v(I,q)=v(I',q) v ( I , q ) = v ( I ′ , q ) for every page q ∈ [ ℓ ] ∖ { p } q\in[\ell]\setminus\{p\} q ∈ [ ℓ ] ∖ { p } .
As before, these conditions encode the assignment of the edge e i e_i e i to the page p p p . In particular, Condition G4 ensures that the edge e i e_i e i does not nest another edge on page p p p ; recall Lemma 27 .
We now show that the above conditions preserve feasibility of the states.
Claim 29. Let I I I be a state. We have D [ I ] = 1 D[I]=1 D [ I ] = 1 if and only if I I I is feasible.
Proof. We show the claim using induction on (the order of) e ( I ) e(I) e ( I ) .
As our base case, we consider states I I I with e ( I ) = e 1 e(I)=e_1 e ( I ) = e 1 . Recall for the following arguments Conditions B1–B5. Assume that I I I is feasible. Thus, by definition, there exists an ℓ \ell ℓ -page queue layout ⟨ ≺ , σ 1 ⟩ \langle\prec,\sigma_1\rangle ⟨ ≺ , σ 1 ⟩ of G 1 G_1 G 1 such that there are precisely x ( I , p , c ) x(I,p,c) x ( I , p , c ) edges of color c c c assigned to page p p p , for every c ∈ [ χ ] c\in[\chi] c ∈ [ χ ] and p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] , and v ( I , p ) v(I,p) v ( I , p ) is the rightmost vertex which is incident to an edge on page p p p , for every p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] . Since G 1 G_1 G 1 contains precisely the edge e 1 e_1 e 1 , the page p = σ 1 ( e 1 ) p=\sigma_1(e_1) p = σ 1 ( e 1 ) witnesses that all conditions are satisfied. Thus, we have D [ I ] = 1 D[I]=1 D [ I ] = 1 . Conversely, assume D [ I ] = 1 D[I]=1 D [ I ] = 1 . Let p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] be the page that satisfies Conditions B1–B5 and consider the linear layout ⟨ ≺ , σ 1 ⟩ \langle\prec,\sigma_1\rangle ⟨ ≺ , σ 1 ⟩ with σ 1 ( e 1 ) = p \sigma_1(e_1)=p σ 1 ( e 1 ) = p . Since G 1 G_1 G 1 contains precisely the edge e 1 e_1 e 1 , this layout witnesses the feasibility of I I I .
For the inductive step, we assume that the statement holds for all states I I I with e ( I ) = e j e(I)=e_j e ( I ) = e j for j < i j<i j < i . Recall for the following arguments Conditions G1–G6. Assume that I I I is feasible and consider the ℓ \ell ℓ -page queue layout ⟨ ≺ , σ i ⟩ \langle\prec,\sigma_i\rangle ⟨ ≺ , σ i ⟩ of G i G_i G i witnessing this. Observe that the layout ⟨ ≺ , σ i − 1 ⟩ \langle\prec,\sigma_{i-1}\rangle ⟨ ≺ , σ i − 1 ⟩ with σ i − 1 ( e j ) = σ i ( e j ) \sigma_{i-1}(e_j)=\sigma_i(e_j) σ i − 1 ( e j ) = σ i ( e j ) for all e j ∈ E e_j\in E e j ∈ E with j < i j<i j < i is an ℓ \ell ℓ -page queue layout of G i − { e i } = G i − 1 G_i-\{e_i\}=G_{i-1} G i − { e i } = G i − 1 . In particular, the layout witnesses the feasibility of the corresponding state I ′ I' I ′ . Observe that we consider I ′ I' I ′ when evaluating D [ I ] D[I] D [ I ] as e ( I ′ ) = e i − 1 e(I')=e_{i-1} e ( I ′ ) = e i − 1 . Moreover, in terms of the values x ( ⋅ , ⋅ , ⋅ ) x(\cdot,\cdot,\cdot) x ( ⋅ , ⋅ , ⋅ ) , the two states differ precisely in x ( ⋅ , σ i ( e i ) , δ ( e i ) ) x(\cdot,\sigma_i(e_i),\delta(e_i)) x ( ⋅ , σ i ( e i ) , δ ( e i )) , and we have x ( I , σ i ( e i ) , δ ( e i ) ) = x ( I ′ , σ i ( e i ) , δ ( e i ) ) + 1 x(I,\sigma_i(e_i),\delta(e_i))=x(I',\sigma_i(e_i),\delta(e_i))+1 x ( I , σ i ( e i ) , δ ( e i )) = x ( I ′ , σ i ( e i ) , δ ( e i )) + 1 . Regarding the v ( ⋅ , ⋅ ) v(\cdot,\cdot) v ( ⋅ , ⋅ ) -values, the two states differ only on the page σ i ( e i ) \sigma_i(e_i) σ i ( e i ) . Since e j ∈ E e_j\in E e j ∈ E for every edge e j e_j e j of G i − 1 G_{i-1} G i − 1 , we have that v ( I ′ , σ i ( e i ) ) ⪯ v v(I',\sigma_i(e_i))\preceq v v ( I ′ , σ i ( e i )) ⪯ v for e i = u v e_i=uv e i = uv ; recall Lemma 27 . Consequently, we satisfy Conditions G1–G6 for state I ′ I' I ′ by choosing p = σ i ( e i ) p=\sigma_i(e_i) p = σ i ( e i ) and thus have D [ I ] = 1 D[I]=1 D [ I ] = 1 . Finally, assume D [ I ] = 1 D[I]=1 D [ I ] = 1 and consider the state I ′ I' I ′ and the page p ∈ [ ℓ ] p\in[\ell] p ∈ [ ℓ ] that we used to satisfy Conditions G1–G6. Since e ( I ′ ) = e i − 1 e(I')=e_{i-1} e ( I ′ ) = e i − 1 and D [ I ′ ] = 1 D[I']=1 D [ I ′ ] = 1 , I ′ I' I ′ is feasible by induction hypothesis. Consider the ℓ \ell ℓ -page queue layout ⟨ ≺ , σ i − 1 ⟩ \langle\prec,\sigma_{i-1}\rangle ⟨ ≺ , σ i − 1 ⟩ of G i − 1 G_{i-1} G i − 1 witnessing feasibility of I ′ I' I ′ and extend it by assigning the edge e i e_i e i to page p p p . We observe that the resulting layout ⟨ ≺ , σ i ⟩ \langle\prec,\sigma_i\rangle ⟨ ≺ , σ i ⟩ is an ℓ \ell ℓ -page queue layout of G i − 1 + { e i } = G i G_{i-1}+\{e_i\}=G_i G i − 1 + { e i } = G i . To see why this is the case, assume that two edges nest on some page and observe that e i e_i e i must be one of them. Let the other edge be e j = x y e_j=xy e j = x y with x ≺ y x\prec y x ≺ y . Since we consider the edges in lexicographic order, we have e j < e i e_j<e_i e j < e i . Thus, we have x ≺ u ≺ v ≺ y x\prec u\prec v\prec y x ≺ u ≺ v ≺ y (u ≺ x ≺ y ≺ v u\prec x\prec y\prec v u ≺ x ≺ y ≺ v would imply e i ≺ e j e_i \prec e_j e i ≺ e j . Since D [ I ] = 1 D[I] = 1 D [ I ] = 1 , I I I satisfies Condition G4. This implies v ( I ′ , σ i ( e i ) ) = ⊥ v(I', \sigma_i(e_i)) = \bot v ( I ′ , σ i ( e i )) = ⊥ or v ( I ′ , σ i ( e i ) ) = w v(I', \sigma_i(e_i)) = w v ( I ′ , σ i ( e i )) = w for some w ∈ V w \in V w ∈ V with w ≺ v w \prec v w ≺ v . However, this contradicts the above-established order x ≺ u ≺ v ≺ y x \prec u \prec v \prec y x ≺ u ≺ v ≺ y as the endpoint of the edge e j e_j e j on page σ i ( e i ) \sigma_i(e_i) σ i ( e i ) is to the right of v v v . Thus, e j e_j e j and e i e_i e i cannot nest and ⟨ ≺ , σ i ⟩ \langle\prec, \sigma_i\rangle ⟨ ≺ , σ i ⟩ is an ℓ \ell ℓ -page queue layout of G i G_i G i . The remaining conditions ensure consistency between the two states. Hence, ⟨ ≺ , σ i ⟩ \langle\prec, \sigma_i\rangle ⟨ ≺ , σ i ⟩ witnesses feasibility of I I I .
Once the DP-table D D D has been computed, we evaluate every state I I I with e ( I ) = e m e(I) = e_m e ( I ) = e m and D [ I ] = 1 D[I] = 1 D [ I ] = 1 and check whether it adheres to our budget constraints, i.e., whether we have x ( I , p , c ) ≤ b p ( c ) x(I,p,c) \le b_p(c) x ( I , p , c ) ≤ b p ( c ) for every page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] and color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] . If we can find such a state, then we can conclude, by Claim 29 , that I I I is a positive instance. On the other hand, if I I I is a positive instance, the corresponding solution witnesses feasibility for some state I I I with e ( I ) = e m e(I) = e_m e ( I ) = e m , which implies D [ I ] = 1 D[I] = 1 D [ I ] = 1 by Claim 29 . Call this last step the postprocessing step. Combining all, we conclude that our DP-algorithm is correct and we now argue its running time.
Running Time. We first bound the size of the DP-table D D D . The graph G G G contains m m m edges and the value x ( I , p , c ) x(I,p,c) x ( I , p , c ) ranges between 0 and m m m for every page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] and color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] . Moreover, there are n + 1 n + 1 n + 1 possible values for v ( I , p ) v(I,p) v ( I , p ) for every page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] ; recall the dummy value ⊥ \bot ⊥ . Hence, there are O ( m ⋅ ( m + 1 ) ℓ ⋅ χ ⋅ ( n + 1 ) ℓ ) O(m \cdot(m+1)^{\ell\cdot\chi} \cdot(n+1)^\ell) O ( m ⋅ ( m + 1 ) ℓ ⋅ χ ⋅ ( n + 1 ) ℓ ) different states I I I , which also bounds the size of D D D . Evaluating a single state I I I takes O ( ℓ ⋅ n ) O(\ell\cdot n) O ( ℓ ⋅ n ) time, since we just need to examine all potential page assignments for the edge e ( I ) e(I) e ( I ) and evaluate the resulting state I ′ I' I ′ , for which only the rightmost vertex is still unspecified. Thus, filling the entire table D D D takes O ( ℓ ⋅ n ⋅ m ⋅ ( m + 1 ) ℓ ⋅ χ ⋅ ( n + 1 ) ℓ ) ∈ O ( ℓ ⋅ ( m + 1 ) ( ℓ ⋅ χ ) + 1 ⋅ ( n + 1 ) ℓ + 1 ) O(\ell\cdot n \cdot m \cdot(m+1)^{\ell\cdot\chi} \cdot(n+1)^\ell) \in O(\ell\cdot(m+1)^{(\ell\cdot\chi)+1} \cdot(n+1)^{\ell+1}) O ( ℓ ⋅ n ⋅ m ⋅ ( m + 1 ) ℓ ⋅ χ ⋅ ( n + 1 ) ℓ ) ∈ O ( ℓ ⋅ ( m + 1 ) ( ℓ ⋅ χ ) + 1 ⋅ ( n + 1 ) ℓ + 1 ) time. Since this dominates the time for the pre- and postprocessing steps, this also bounds the overall running time of our algorithm. Finally, we can obtain an admissible ℓ \ell ℓ -page queue layout by standard backtracking techniques (if there exists one).
Towards Completing the Complexity Landscape
In this section, we consider the remaining parameter combinations depicted in Figure 2 . First, we parameterize by the number of pages ℓ \ell ℓ , the number of colors χ \chi χ , and the maximum size γ \gamma γ of a connected component in the conflict graph Q Q Q . There, we can apply the same proof strategy as for Theorem 14 (when considering nestings instead of crossings). More concretely, we partition the connected components of Q Q Q into g ( χ , γ ) g(\chi,\gamma) g ( χ , γ ) different types such that components of the same type are equal up to a (color-preserving) isomorphism. Then, we formulate an ILP with h ( ℓ , χ , γ ) h(\ell,\chi,\gamma) h ( ℓ , χ , γ ) variables that constrains the number of components of each type that can use the same page assignment. Together with Proposition 9, this implies:
Figure 2. Parameterized complexity of (a) FoCap2PSL (§ 3 ) and (b) FoCapQL (§ 4 ) when parameterized by the number of pages ℓ \ell ℓ , the number of colors χ \chi χ , the number of connected components λ \lambda λ in the conflict graph, and/or their maximum size γ \gamma γ . The result for FoCapQL marked with * applies only if ℓ = 2 \ell= 2 ℓ = 2 . Moreover, note that ℓ = 2 \ell= 2 ℓ = 2 holds for every instance of FoCap2PSL and, therefore, we omit the parameter in (a).
Theorem 30. Fixed Order Capacitated Queue Layout is FPT in the number of pages ℓ \ell ℓ , number of colors χ \chi χ , and the maximum size γ \gamma γ of a connected component of Q ( G , ≺ ) Q(G,\prec) Q ( G , ≺ ) .
Finally, we parameterize by the number λ \lambda λ of connected components in the conflict graph Q Q Q and their maximum size γ \gamma γ . Consider an instance I \mathcal{I} I of FoCapQL. Since Q Q Q contains one vertex for each edge of G G G and we can assume without loss of generality that there are no isolated vertices in G G G , we have n ≤ 2 m ≤ 2 ⋅ λ ⋅ γ n \le2m \le2 \cdot\lambda\cdot\gamma n ≤ 2 m ≤ 2 ⋅ λ ⋅ γ . With this we can show that we can restrict ourselves to a bounded number of pages and colors, i.e., obtain a kernel, which allows us to brute-force I \mathcal{I} I :
Theorem 31. Fixed Order Capacitated Queue Layout can be solved constructively in 2 O ( ( λ ⋅ γ ) 2 ⋅ log ( λ ⋅ γ ) ) + O ( ℓ ⋅ χ ) 2^{O((\lambda\cdot\gamma)^2 \cdot\log(\lambda\cdot\gamma))} + O(\ell\cdot\chi) 2 O (( λ ⋅ γ ) 2 ⋅ l o g ( λ ⋅ γ )) + O ( ℓ ⋅ χ ) time (which is FPT in the number λ \lambda λ of connected components of Q ( G , ≺ ) Q(G,\prec) Q ( G , ≺ ) and their maximum size γ \gamma γ ).
Proof. Let I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) \mathcal{I} = (G, \delta, \prec, \ell, (b_p)_{p \in[\ell]}) I = ( G , δ , ≺ , ℓ , ( b p ) p ∈ [ ℓ ] ) be an instance of FoCapQL. Consider the conflict graph Q Q Q . It has at most λ ⋅ γ \lambda\cdot\gamma λ ⋅ γ vertices and since it contains precisely one vertex for every edge of G G G , we get m ≤ λ ⋅ γ m \le\lambda\cdot\gamma m ≤ λ ⋅ γ . Moreover, we can assume without loss of generality that there are no isolated vertices in G G G , as they can be removed without affecting the existence of a solution. Thus, we have n ≤ 2 m ≤ 2 ⋅ λ ⋅ γ n \le2m \le2 \cdot\lambda\cdot\gamma n ≤ 2 m ≤ 2 ⋅ λ ⋅ γ .
Since m ≤ λ ⋅ γ m \le\lambda\cdot\gamma m ≤ λ ⋅ γ , we can also assume that χ ≤ λ ⋅ γ \chi\le\lambda\cdot\gamma χ ≤ λ ⋅ γ holds. Otherwise, we can remove unused colors and renumber them from 1 1 1 to λ ⋅ γ \lambda\cdot\gamma λ ⋅ γ to obtain an equivalent instance where the above inequality holds. By similar arguments, we can also assume that b p ( c ) ≤ m ≤ λ ⋅ γ b_p(c) \le m \le\lambda\cdot\gamma b p ( c ) ≤ m ≤ λ ⋅ γ holds for every page p ∈ [ ℓ ] p \in[\ell] p ∈ [ ℓ ] and color c ∈ [ χ ] c \in[\chi] c ∈ [ χ ] . Consequently, there are at most ( m + 1 ) χ (m + 1)^\chi ( m + 1 ) χ different budget functions b p b_p b p . If I \mathcal{I} I has more than m m m pages with the same budget vector b p b_p b p , then we can remove one page from the instance without affecting the existence of a solution. This is because, by the pigeonhole principle, in every solution one of these pages will remain empty so we can convert any solution into one where the “removed pages” are empty. Thus, it suffices to consider at most m ⋅ ( m + 1 ) χ m \cdot(m + 1)^\chi m ⋅ ( m + 1 ) χ different pages p p p and we can find them after a O ( ℓ ⋅ χ ) O(\ell\cdot\chi) O ( ℓ ⋅ χ ) -time preprocessing step.
This allows us to brute-force all possible page assignments, which are 2 O ( ( λ ⋅ γ ) 2 ⋅ log ( λ ⋅ γ ) ) 2^{O((\lambda\cdot\gamma)^2 \cdot\log(\lambda\cdot\gamma))} 2 O (( λ ⋅ γ ) 2 ⋅ l o g ( λ ⋅ γ )) many. For each page assignment σ \sigma σ , we can check in polynomial time (in m ≤ λ ⋅ γ m \le\lambda\cdot\gamma m ≤ λ ⋅ γ ) whether they correspond to a solution ⟨ ≺ , σ ⟩ \langle\prec, \sigma\rangle ⟨ ≺ , σ ⟩ . The statement now follows.
Generalizations and Concluding Remarks
In this paper, we have introduced the concept of a capacitated linear layout and studied the complexity of computing an ℓ \ell ℓ -page capacitated stack/queue layout with given spine order ≺ \prec ≺ . Although we only considered unweighted graphs in this paper, our algorithmic results can be extended to edge-weighted graphs (when the largest edge-weight is a parameter).
One prominent open question is settling the complexity of FoCapQL when parameterized by the number of colors and the size of the largest connected component in the conflict graph Q Q Q ; recall Figure 2 . Furthermore, recent work studied the parameterized complexity of computing an ℓ \ell ℓ -page stack and queue layout with respect to several graph parameters (even when ≺ \prec ≺ is not part of the input); see for example [17 ] . Extending these results to the capacitated setting is an interesting direction for future work. A further natural direction is other variants of capacitated linear layouts, such as capacitated mixed linear layouts.