On the Complexity of the Storyplan Problem

Motivated by dynamic graph visualization, we study the problem of representing a graph $G$ in the form of a \emph{storyplan}, that is, a sequence of frames with the following properties. Each frame is a planar drawing of the subgraph of $G$ induced by a suitably defined subset of its vertices. Between two consecutive frames, a new vertex appears while some other vertices may disappear, namely those whose incident edges have already been drawn in at least one frame. In a storyplan, each vertex appears and disappears exactly once. For a vertex (edge) visible in a sequence of consecutive frames, the point (curve) representing it does not change throughout the sequence. Note that the order in which the vertices of $G$ appear in the sequence of frames is a total order. In the \textsc{StoryPlan} problem, we are given a graph and we want to decide whether there exists a total order of its vertices for which a storyplan exists. We prove that the problem is NP-complete, and complement this hardness with two parameterized algorithms, one in the vertex cover number and one in the feedback edge set number of $G$. Also, we prove that partial $3$-trees always admit a storyplan, which can be computed in linear time. Finally, we show that the problem remains NP-complete in the case in which the total order of the vertices is given as part of the input and we have to choose how to draw the frames.


Introduction
The first element is a bijection τ : V → [n] that represents a total order of the vertices of G. For a vertex v ∈ V , let i v = τ (v) and let j v = max u∈N [v] τ (u), where N [v] is the set containing v and its neighbors. The lifespan of v is the interval [i v , j v ]. We say that v appears at step i v , is visible at step i for each i ∈ [i v , j v ], and disappears at step j v + 1. Note that a vertex does not disappear until all its neighbors have appeared. The second element of S is a sequence of drawings {D i } i∈ [n] , such that: (i) each drawing D i contains all vertices visible at step i, (ii) each drawing D i is planar, (iii) the point representing a vertex v is the same over all drawings that contain v (i.e., it does not change during the lifespan of v), and (iv) the curve representing an edge e is the same over all drawings that contain e. We introduce the StoryPlan problem. In what follows, each drawing D i of a storyplan S is called a frame of S. Also, we denote by |D i | the number of vertices of D i , while the width of S is w(S) = max i∈ [n] |D i | − 1 (we subtract one to align the definition with other width parameters). If G admits a storyplan, then the framewidth of G, denoted by fw(G), is the minimum width over all its storyplans; otherwise the framewidth of G is conventionally set to +∞. We will observe that the framewidth of G upper bounds its pathwidth [17], since each frame can be interpreted as a bag of a path decomposition with the addition of conditions (ii)-(iv).
Motivation and related work. Testing for the existence of a storyplan of a graph generalizes planarity and it is of theoretical interest as it combines classical width parameters of graphs with topological properties. From a more practical perspective, computing a storyplan (if any) of a graph G is a natural way to gradually visualize G in a story-like or small-multiples fashion, such that each single drawing is planar and the reader's mental map is preserved throughout the sequence of drawings (see, e.g., [9] for a similar approach). More in general, the problem of visualizing graphs that change over time has motivated a notable amount of literature in graph drawing and network visualization (see, e.g., [2,3,5,8,22,23]). While numerous dynamic graph visualization models have been proposed, two works are of particular interest for our research. The first one is the work by Borrazzo et al. [5], in which the following problem is introduced. A graph story is formed by a graph G, a total order of its vertices τ , and a positive integer W . The problem is to find a sequence of drawings {D i } i∈ [n] in which each D i contains all vertices v such that i − W < τ (v) ≤ i, and the position of a vertex is the same over all drawings it belongs to. Borrazzo et al. prove that any story of a path or a tree can be drawn on a 2W × 2W and on an (8W + 1) × (8W + 1) grid, respectively, so that all the drawings of the story are straight-line and planar. Note that having a fixed window of size W implies that at most O(W · n) edges of G can be represented, in particular, any edge whose endpoints are at distance larger than W in τ does not appear in any drawing. Having both a fixed order and a fixed lifespan are the key differences with our The Storyplan Problem 3 setting. In particular, unconstrained lifespans allow us to find stories in which all edges are drawn in at least one step, while planarity still guarantees that even large frames are readable. Besides such differences in the models, our focus is on the complexity of the decision problem, rather than on area bounds for specific graph families. The second work is by Da Lozzo and Rutter [8], who introduce stream planarity. Given a graph G, a total order τ of the edges of G, and a positive integer W , stream planarity asks for a sequence of drawings {D i } i∈ [n] in which each D i contains all edges e such that i − W < τ (e) ≤ i, and the subdrawing of the vertices and edges shared by D i and D i−1 is the same in both drawings. Da Lozzo and Rutter prove that there exists a constant value for W for which the stream planarity problem is NP-complete. They also study a variant where a backbone graph is given whose edges must stay in the drawing at each time step; for this variant they prove that the problem is NP-complete for all W ≥ 2 and can be solved in polynomial time when W = 1 or when the backbone graph is biconnected. The difference of stream planarity with our problem, besides the fact that edges are streamed rather than vertices, is again having a fixed order and a fixed lifespan.
Contribution. The main results in this paper can be summarized as follows.
-We show that StoryPlan is NP-complete (Section 3.1). As we reduce from One-In-Three 3SAT and we blow up the instance by a linear factor, it follows that there is no algorithm that solves StoryPlan in 2 o(n) time unless ETH fails. On the other hand, such a lower bound can be complemented with a simple algorithm running in 2 O(n log n) time. -Motivated by the above hardness, we study the parameterized complexity of StoryPlan and describe two fixed-parameter tractable algorithms. We first show that StoryPlan belongs to FPT when parameterized by the vertex cover number via the existence of a kernel, whose size is however superpolynomial (Section 3.2). We then prove that StoryPlan parameterized by the feedback edge set number (i.e., the minimum number of edges whose removal makes the graph acyclic) admits a kernel of linear size (Section 3.3). -In parameterized analysis, a central parameter to consider is treewidth. In this direction, finding a parameterized algorithm for StoryPlan appears to be an elusive task. However, we show that for partial 3-trees, a storyplan always exists and can be computed in linear time (Section 3.4). -Finally, we initiate the study of the complexity of a variant of StoryPlan in which the total order of the vertices is fixed in advance (but the vertex lifespan remains unconstrained). We prove NP-completeness for this problem via a reduction from Sunflower SEFE [20] (Section 4).
Some proofs are in the appendix and the corresponding statements are marked ( ).

Preliminaries and Basic Results
A drawing Γ of a graph G = (V, E) is a mapping of the vertices of V to points in the plane R 2 , and of the edges of E to Jordan arcs connecting their corresponding endpoints but not passing through any other vertex. Drawing Γ is planar if no edge is crossed. A graph is planar if it admits a planar drawing. A planar drawing of a planar graph G subdivides the plane into topologically connected regions, called faces. The infinite region is the outer face. A planar embedding E of G is an equivalence class of planar drawings that define the same set of faces and the same outer face. For any V ⊆ V , we denote by G[V ] the subgraph of G induced by the vertices of V and by Γ [V ] the subdrawing of Γ representing G[V ].
Connection with pathwidth. The next properties show some simple connections between storyplans and path decompositions [17].
Theorem 1 ( ). Let G = (V, E) be a graph, then pw(G) ≤ fw(G). Also, if G is planar then it always admits a storyplan, and in particular pw(G) = fw(G).
Since computing the pathwidth is NP-hard already for planar graphs of bounded degree [16], the next corollary immediately follows from Theorem 1.

Corollary 1.
Computing the framewidth of a graph is NP-hard for planar graphs of bounded degree.
Analogously, computing the pathwidth of a graph is FPT in the pathwidth [4], hence computing the framewidth of a planar graph is also FPT in the framewidth.
Complete bipartite graphs. It is not difficult to verify that if a graph admits a storyplan, then it does not contain K 5 as a subgraph. However, complete bipartite graphs always admit a storyplan and such storyplans have important properties. The next statement plays a central role in most of our proofs.
Lemma 1 ( ). Let K a,b = (A∪B, E) be a complete bipartite graph with a = |A|, b = |B|, and 3 ≤ b ≤ a. Let S = τ, {D i } i∈[a+b] be a storyplan of K a,b . Exactly one of A and B is such that all its vertices are visible at some i ∈ [a + b].
In view of Lemma 1, we have the following definition.
Definition 1. For a complete bipartite graph K a,b with 3 ≤ b ≤ a and a storyplan S of K a,b , we call fixed the partite set of K a,b whose vertices are all visible at some step of S, and flexible the other partite set.

Complexity of StoryPlan
In this section we prove that: StoryPlan is NP-complete and cannot be solved in 2 o(n) time unless ETH fails, but there is an algorithm running in 2 O(n log n) time (Section 3.1); StoryPlan is in FPT parameterized by vertex cover number or feedback edge set number (Sections 3.2 and 3.3); graphs of treewidth at most 3 always admit a storyplan, which can be computed in linear time (Section 3.4).
The Storyplan Problem

Hardness
We reduce from One-In-Three 3SAT, a variant of 3SAT which asks whether there is a satisfying assignment in which exactly one literal in each clause is true. Let ϕ be a 3SAT formula over N variables We construct an instance of StoryPlan, i.e., a graph G = (V, E), as follows; refer to Fig. 1 for an illustration. Variable gadget. Each variable x i is represented in G by a copy K(x i ) of K 3,3 (see Fig. 1(a)). Let A i and B i be the two partite sets of K(x i ), which we call the v-sides of K(x i ). A true (false) assignment of x i will correspond to set A i being flexible (fixed) in a putative storyplan of G (see Definition 1). Clause gadget. Consider a copy of K 2,2,2 = (U 1 ∪U 2 ∪U 3 , F ). An extended K 2,2,2 is the graph obtained from any such a copy by adding three vertices s 1 , s 2 , s 3 , such that these three vertices are pairwise adjacent, and each s j is adjacent to both vertices in U j , for j ∈ {1, 2, 3}. In the following, s 1 , s 2 , s 3 are the special vertices of the extended K 2,2,2 , while the other vertices are the simple vertices.
A clause C i is represented in G by an extended K 2,2,2 , denoted by K(C i ) (see Fig. 1(b)). In particular, we call each of the three sets of vertices U j ∪ {s j } a c-side of K(C i ). The idea is that K(C i ) admits a storyplan if and only if exactly one c-side is flexible (each c-side will be part of a K 3,3 , see the wire gadget below). Wire gadget. Refer to Fig. 1(c). Let x i be a variable having a literal l ij in a clause C j . Any such variable-clause incidence is represented in G by a set of three vertices, which we call the w-side W (l ij ). All vertices of W (l ij ) are connected to all vertices of one of the three c-sides of K(C j ), which we call U , such that the graph induced by W (l ij ) ∪ U in G contains a copy of K 3,3 . Also, each vertex of W (l ij ) is connected to all vertices of the v-side A i (B i ) if the literal is positive (negative), such that the graph induced by W (l ij ) ∪ A (W (l ij ) ∪ B) in G is a copy of K 3,3 . Also, note that each c-side of K(C j ) is adjacent to exactly one w-side.
Lemma 2 ( ). If graph G admits a storyplan then ϕ admits a satisfying assignment with exactly one true literal in each clause.
Proof (Sketch). Let S be a storyplan of G. For each variable gadget K(x i ) we assign the value true to x i if the v-side A i is flexible in S. Consider any literal l ij and the wire gadget W ij . If l ij is positive (negative), then A i (B i ) and W ij form a K 3,3 , hence by Lemma 1 the w-side W ij is fixed (flexible). Analogously, if we consider the clause gadget K(C j ), the c-side connected with W ij is flexible (fixed). Symmetrically, we assign the value false to x i if the v-side B i is instead flexible in S, and for any positive (negative) literal l ij , the w-side W ij is flexible (fixed), while the corresponding c-side of K(C j ) is fixed (flexible). In other words, the value of x i propagates consistently throughout all its literals. It remains to prove that, for any clause C j of ϕ, precisely one literal is true. Namely, we claim that exactly one c-side of K(C j ) is flexible, while the other two are fixed. At high level, we rely on the fact that an extended K 2,2,2 wants at least two c-sides to be fixed, while the special vertices force at least one c-side to be flexible.

Lemma 3 ( ).
If the formula ϕ admits a satisfying assignment with exactly one true literal in each clause, then graph G admits a storyplan.
Proof (Sketch). Given a satisfying assignment of ϕ with one true literal per clause, we can compute a storyplan S = τ, {D i } i∈ [n] of G. In what follows, when the order of a group of vertices is not specified, any relative order is valid.
. . . Consider a single variable gadget K(x i ). If x i is true in the satisfying assignment, then we let appear the three vertices of the v-side B i of K(x i ), that is, B i is the fixed side of K(x i ). If x i is false, we do the opposite, namely we let appear the three vertices of the v-side A i of K(x i ). This procedure is repeated for all variables in any order. For ease of presentation, we can imagine that all the drawn v-sides are horizontally aligned, as shown in Fig. 2. Thus, for the variable gadgets, it remains to draw their flexible v-sides.
Consider now a wire gadget W (l ij ). If x i is true and l ij is positive, then W (l ij ) must be fixed because it forms a K 3,3 with the v-side A i of K(x i ), which is flexible. Therefore we let appear the three vertices of W (l ij ). Similarly, if x i is false and l ij is negative, then W (l ij ) must be fixed, and we let appear the three Fig. 3. Proof of Lemma 3: drawing the vertices of the fixed w-sides.
vertices of W (l ij ). Again, this procedure is repeated for all wires in any order. For ease of presentation, we can imagine that all the drawn w-sides are arranged along a horizontal line slightly above the variable gadgets, as shown in Fig. 3. Thus, also for the wire gadgets, it remains to draw the flexible w-sides. We sketch the remaining part of the proof (see Appendix B.1). Flexible vsides can be drawn as in Fig. 4. Fig. 5 shows how to draw a clause gadget, ignoring the connections with the linked wire gadgets. Finally, in order to draw the flexible w-sides and their edges, and the edges between the fixed w-sides and the corresponding c-sides, we enclose all the wire and variable gadgets in a face of the current clause gadget where all vertices of the linked c-side are visible.
Theorem 2 ( ). The StoryPlan problem is NP-hard and it has no 2 o(n) time algorithm unless ETH fails.
The above lower bound for the running time of an algorithm solving Story-Plan can be easily complemented with a nearly tight upper bound. The proof of the next theorem also shows that StoryPlan belongs to NP. Namely, it gives a nondeterministic scheme to generate a set of candidate solutions, and then it shows how to check, in polynomial time, if a candidate solution is valid. However, it intertwines such process in order to obtain a lower time complexity.
Theorem 3 ( ). The StoryPlan problem is in NP. Also, given an n-vertex graph G, there is an algorithm that solves StoryPlan on G in 2 O(n log n) time.
Proof (Sketch). We first guess a total order of the vertices of G. This fixes for each i ∈ [n] the visible vertices. Next, for each i ∈ [n], we generate the possible planar embedddings (rather than planar drawings) of the graph induced by the vertices visible at step i, and discard any embedding E for which there is no planar embedding E generated at step i−1 (if i > 1) such that the restrictions of E and E to the common subgraph coincide. If the algorithm returns at least one planar embedding at step n, there is a sequence of planar embeddings in which common subgraphs share the same embedding, hence G admits a storyplan.

Parameterization by Vertex Cover Number
A vertex cover of a graph G = (V, E) is a set C ⊆ V such that every edge of E is incident to a vertex in C, and the vertex cover number of G is the minimum size of a vertex cover of G. We prove the following by means of kernelization.
Theorem 4 ( ). Let G = (V, E) be a graph with n vertices and vertex cover number κ = κ(G). Deciding whether G admits a storyplan, and computing one if any, can be done in Algorithm Description. Without loss of generality, we assume that the input graph G does not contain isolated vertices, as they do not affect the existence of a storyplan. Let C be a vertex cover of size This defines an equivalence relation on V \ C and in particular partitions V \ C into at most κ i=1 κ i = 2 κ − 1 < 2 κ distinct types. Denote by V U the set of vertices of type U . We define three reduction rules. R.1: If there exists a type U such that |U | = 1, then pick an arbitrary vertex x ∈ V U and remove it from G.

R.2:
If there exists a type U such that |U | = 2 and |V U | > 1, then pick an arbitrary vertex x ∈ V U and remove it from G.

R.3:
If there exists a type U such that |U | ≥ 3 and |V U | > 3, then pick an arbitrary vertex x ∈ V U and remove it from G. Lemma 4 ( ). Let G be the graph obtained from G by applying one of the reduction rules R.1-R.3. Then G admits a storyplan if and only if G does.
Proof (Sketch). For the nontrivial direction, suppose that G admits a storyplan S = τ , {D } i∈ [n ] , where n = n − 1. We can distinguish three cases based on the reduction rule applied to G. Here we only prove the simplest of the three cases, namely the case in which R.1 is applied. See Fig. 6 for an illustration. Let x be the vertex removed from G to obtain G and let v be its neighbor, whose we draw x in D iv sufficiently close to v such that edge xv can be drawn as a straight-line segment that does not intersect any other edge. We then set D i to be equal to the resulting drawing.
Based on Lemma 4, we can construct an equivalent instance of G of size O(2 κ ) and use it to conclude the proof of Theorem 4 (see Appendix B.2).

Parameterization by Feedback Edge Set
A feedback edge set of a graph G = (V, E) is a set F ⊆ E whose removal results in an acyclic graph, and the feedback edge set number of G is the minimum size of a feedback edge set of G. We prove the following.
Theorem 5. Let G be a graph with n vertices and feedback edge set of size ψ = ψ(G). Deciding whether G admits a storyplan, and computing one if any, Algorithm Description. A k-chain of G is a path with k + 2 vertices and such that its k inner vertices all have degree two. We define two reduction rules. R.A: If there exists a vertex of degree one, then remove it from G. R.B: If there exists a k-chain with k ≥ 3, then remove its inner vertices from G.
Based on the above reduction rules we can prove the following.

Partial 3-trees
A k-tree has a recursive definition: A complete graph with k vertices is a k-tree; for any k-tree H, the graph obtained from H by adding a new vertex v connected to a clique C of H of size k is a k-tree; C is the parent clique of v. A partial k-tree is a subgraph of a k-tree and partial k-trees are exactly the graphs of treewidth at most k. Since 2-trees are planar, they admit a storyplan by Theorem 1. We prove that the same holds for partial 3-trees (which may be not planar).
Theorem 6 ( ). Every partial 3-tree G with n vertices admits a storyplan, which can be computed in O(n) time.
Proof (Sketch). We shall assume that G is a (non-partial) 3-tree. Indeed, if G is a partial 3-tree, a supergraph of G that is a 3-tree always exists by definition. We now construct a specific tree decomposition T of G that will be used to compute its storyplan; refer to Fig. 7. For a definition of tree decomposition see [18]. The subgraph C µ induced by the vertices of each bag µ of T is the subgraph associated with µ and it is a 4-clique for each bag µ of T , except for the root ρ of T for which C ρ is the initial 3-cycle. The subgraph C µ contains four 3-cliques, three of them are active (this means that they can appear in some subgraph C ν associated with a child ν of µ) and one is non-active. The unique 3-clique in C ρ is active. Each bag µ of T has one child ν for each vertex v whose parent clique is an active 3-clique of µ. The 4-clique C ν consists of the parent clique C of v, vertex v, and the edges connecting v to C; C is non-active in ν, while the other three 3-cliques are active. For each bag µ distinct from ρ, we denote by v µ the vertex shared by the three active 3-cliques of C µ . We say that v µ is associated with µ. One easily verifies that T is a tree decomposition. Also, T has n − 2 bags: the root and a bag for each vertex of G that is not in the initial 3-cycle.
We now associate to each bag µ a subgraph G µ of G. For the root ρ, the subgraph G ρ is the initial 3-cycle. For a bag µ with parent λ, the subgraph G µ is obtained from G λ by connecting v µ to the vertices of its parent clique. Property 1. Every graph G µ is an embedded planar 3-tree such that the active 3-cliques of C µ are internal faces of G µ .
The proof of Property 1 is by induction on the length of the path from the root ρ to µ in T . The graph G ρ consists of a 3-cycle, which is the unique active 3-clique and which is both an internal and an external face. The graph G µ is obtained by adding the vertex v µ to G λ and connecting it to its parent clique C, which is active in C λ . By induction, C is an internal face of G λ and therefore, by placing v µ inside this face, we obtain an embedded planar 3-tree such that the active faces of C µ are the three faces created by the addition of v µ inside C.
Let µ = ρ be a bag of T ; the next property follows from the definition of T .
Property 2. The neighbors of v µ distinct from those of its parent clique are all vertices associated with bags of the subtree of T rooted at µ.
Let ρ = µ 1 , µ 2 , . . . , µ n−2 be an order of the bags of T according to a preorder visit of T . To create a storyplan of G, we define an ordering τ : v 1 , v 2 , . . . , v n of the vertices of G such that v 1 , v 2 , and v 3 are the vertices of the initial 3-cycle, and each v i with i > 3 is the vertex associated with µ i−2 .
Let G i be the graph induced by the vertices that are visible at step i, for i ≥ 3; by Property 2 the graph G i is a subgraph of G µi which, by Property 1 is an embedded planar 3-tree such that the three active 3-cliques of C µi are faces of G µi . To simplify the description we prove that there exists a storyplan S = τ, {D i } i∈ [n] , where each D i is a drawing of G µi . This implies that there exists a storyplan where each D i is a drawing of G i . Let µ j be the parent of µ i in T ; since the order τ corresponds to a preorder of the bags of T , we have j < i. Moreover, all bags µ k with j < k < i, if any, belong to the subtrees of µ j visited before µ i and for each such subtree T no other bag of T exists before µ j or after µ i . By Property 2 all the vertices associated with the bags µ k that belong to G µi−1 do not have any neighbor after v µi and therefore they can be removed. The removal of these vertices transforms G µi−1 into G µj (all the vertices associated with the bags µ k for j < k < i had been added to G µj that had never been changed). By Property 1 the active 3-cliques of G µj are faces of G µj . It follows that there exists a storyplan S = τ, {D i } i∈ [n] whose frames D i are as follows. D 1 is a planar drawing of a 3-cycle; given D i−1 of G µi−1 , a drawing D i of G µi can be computed by removing all vertices associated with the bags µ k for j < k < i, and adding v µi inside a face of D j .
The above storyplan can be computed in O(n) time, see Appendix B.4.
The Storyplan Problem

Complexity with Fixed Order
In this section we study the StoryPlanFixedOrder variant of StoryPlan, defined below. This variant is closer to the setting studied in [5] and it models the case in which the way the graph changes over time is prescribed.
We prove that StoryPlanFixedOrder is NP-complete by reducing from Sunflower SEFE. Let G 1 , . . . , G k be k graphs on the same set V of vertices. A simultaneous embedding with fixed edges (SEFE) of G 1 , . . . , G k consists of k planar drawings Γ 1 , . . . , Γ k of G 1 , . . . , G k , respectively, such that each vertex is mapped to the same point in every drawing and each shared edge is represented by the same simple curve in all drawings sharing it. The SEFE problem asks whether k input graphs on the same set of vertices admit a SEFE, and it is NP-complete even when the pairwise intersection between any two input graphs is the same over all pairs of graphs [1,20]. This variant is called Sunflower SEFE, and the result in [1,20] proves NP-completeness already when k = 3.
Construction. Refer to Fig. 8 for an example. Let G 1 , G 2 , G 3 be an instance of Sunflower SEFE. Let V be the common vertex set of the three graphs, let E be the common edge set, and let E i be the exclusive edge set of G i for i = 1, 2, 3.
We construct an instance G, τ of StoryPlanFixedOrder as follows. Graph G contains all vertices in V and all edges in E. Also, for each edge e = uv in E i , it contains a vertex w i e , called a subdivion vertex of E i , and the edges uw i e and vw i e (i.e., it contains the edge e subdivided once). Moreover, for each vertex z, either a vertex in V or a subdivision vertex of an edge, G contains an additional vertex s z , called the spectator of z, and the edge zs z . To obtain the total order τ we group the vertices of G in a set of blocks B 1 , . . . , B 8 , and we order the blocks by increasing index, while vertices within the same block can be ordered arbitrarily. We denote by τ Proof (Sketch). At a high level, the total order τ is designed to show the three graphs one by one while keeping the common edge set visible. In particular, a spectator vertex s v forces vertex v to stay visible until s v appears, while a subdivision vertex w i e makes edge e visible only when G i must be drawn.

Discussion and Open Problems
Our work can stimulate further research based on several possible directions.
-It would be interesting to study further parameterizations of StoryPlan. Is StoryPlan parameterized by treewidth (pathwidth) in XP? In addition, we note that if the total order is fixed, then an FPT algorithm in the size of the largest frame (or the length of the longest lifespan) readily follows from the proof of Theorem 3. -Conditions (iii) and (iv) of the definition of a storyplan can be replaced by the existence of a sequence of planar embeddings in which common subgraphs keep the same embedding. This is not true if we study more geometric versions of the problem, in which for instance edges are straight-line segments and/or vertices are restricted on an integer grid of fixed size (as in [5]). -Condition (ii) of storyplan can be relaxed so to only allow specific crossing patterns [10,11], e.g., right-angle crossings or few crossings per edge.
and the pathwidth of G is the minimum width over all its path decompositions. In order to prove Theorem 1, we begin with the following lemma.
Lemma 6. Let G = (V, E) be a graph. If G admits a storyplan S = τ, {D i } i∈ [n] of width ω = w(S), then it admits a path decomposition of width at most ω.
Proof. It is easily seen that ω equals the vertex separation number of the total order τ . Namely, suppose for a contradiction that there exists an index i ∈ [n] such that there are at least ω + 1 vertices v with τ (v) ≤ i having a neighbor u such that τ (u) > i. Let u 1 be the one of such neighbors that appears first. All the at least ω + 1 vertices are still visible at step τ (u 1 ) and therefore the size of the frame at step τ (u 1 ) is at least ω + 2, thus contradicting the fact that S has with ω. On the other hand, a total order τ with vertex separation number ω implies the existence of a path decomposition of width at most ω [14].
Theorem 1 ( ). Let G = (V, E) be a graph, then pw(G) ≤ fw(G). Also, if G is planar then it always admits a storyplan, and in particular pw(G) = fw(G).
Proof. If G does not admit a storyplan, for any total order of its vertices, then pw(G) < fw(G) = +∞. Otherwise, pw(G) ≤ fw(G) by Lemma 6. If G is planar, we show that fw(G) ≤ pw(G). Namely, let {X i } i∈[h] be a path decomposition of G. Without loss of generality, we can assume that this path decomposition is nice (or normalized), i.e., X 1 contains exactly one vertex, and, for each bag X i with 1 < i ≤ h, there is a vertex v such that either X i = X i−1 ∪ {v} or X i = X i−1 \ {v}. Then we have that at each step at most one vertex is introduced in the decomposition, and hence we can associate each vertex v with an index l v such that l v = 1 if v is the first introduced vertex, and l v = l u + 1, where l u is the last vertex introduced before v, otherwise. We define a total order τ of V by setting τ (v) = l v . Let Γ be a planar drawing of G. Consider the set of n drawings such that D i corresponds to the subdrawing of Γ induced by the vertices that are visible at step i, for each i ∈ [n]. One immediately verifies that τ, {D i } i∈ [n] is a storyplan of G of width pw(G).
In order to prove Lemma 1, we first prove a few auxiliary lemmas. Proof. Let i be such that D i contains the largest number t of vertices of A over all frames of S. If t = a, we are done. If t < a, there exist two vertices u, v of A such that j u < i v . Note that all vertices in B are adjacent to u, and hence they all appear at some step smaller than or equal to j u . On the other hand, since all vertices in B are adjacent to v as well, they cannot disappear before i v + 1. It follows that all vertices of B are visible at step j u . Proof. The statement immediately follows from the fact any frame of S is planar and hence cannot contain K 3,3 as a subgraph.
We are now ready to prove Lemma 1. Observe that, since I is maximal, one vertex of A appears at s. Therefore, any vertex of B visible at a step smaller than s is visible also at step s. Similarly, by the maximality of I, one vertex of A disappears at step t + 1, therefore any vertex of B visible at a step greater than t is visible also at step t. Consequently, we can assume that j ∈ I, and we can conclude h ≤ 2 by Lemma 8. Proof. Let S = τ, {D i } i∈ [n] be a storyplan of G. For each variable gadget K(x i ) we assign the value true to x i if the v-side A i is flexible in S. Consider any literal l ij and the wire gadget W ij . If l ij is a positive (negative) literal, then A i (B i ) and W ij form a K 3,3 , hence by Lemma 1 the w-side W ij is fixed (flexible). Analogously, if we consider the clause gadget K(C j ), the c-side connected with W ij is flexible (fixed). Symmetrically, we assign the value false to x i if the vside B i is instead flexible in S, and for any positive (negative) literal l ij , the w-side W ij is flexible (fixed), while the corresponding c-side of K(C j ) is fixed (flexible). In other words, the value of x i propagates consistently throughout all its literals. It remains to prove that, for any clause C j of ϕ, precisely one literal is true for the constructed truth value assignment of {x i } i∈ [N ] . Namely, we claim that exactly one c-side of K(C j ) is flexible, while the other two are fixed. We first argue that not all c-sides can be fixed in S. Assume, for a contradiction, that they are. Let D h be the frame of S in which the last simple vertex v of K(C j ) appears. Observe that all other simple vertices are also visible at step h. Namely, let u = v be a simple vertex of K(C j ). Either u is adjacent to v or in the same c-side as v. Hence, since i u < h by assumption and since u cannot disappear until h + 1, it follows that u is visible at step h. It follows that D h contains a drawing of K 2,2,2 , which is a maximal planar graph and hence has a unique planar embedding up to the choice of the outer face. In particular, vertex v and the other vertex on the same c-side as v, which we call v , do not belong to the same face. Consider now the special vertex s adjacent to both v and v . Vertex s cannot be visible at step h, else D h would not be planar, as it would contain K 2,2,2 plus a subdivided edge between v and v . On the other hand, it cannot have disappeared already, since s and v are adjacent. Hence, s has not appeared yet. Similarly, no other special vertex is visible at step h, and since the special vertices are pairwise adjacent, it follows that none of them has appeared yet. Consequently, no vertex of K 2,2,2 can disappear until the first special vertex has appeared, which implies the existence of a frame that contains a planar drawing of K 2,2,2 plus a subdivided edge between two vertices in the same c-side, which contradicts the fact that the considered frame is planar.
We now rule out the case in which more than one c-side is flexible, which corresponds to a clause with more than one true literal. If a c-side is flexible, there can be no frame containing both its simple vertices. This follows from the fact that the special vertex is adjacent to both simple vertices, and hence there would be a frame containing all three vertices together, which is not possible since the c-side is flexible. On the other hand, when the last simple vertex appears, its four neighbors in K 2,2,2 are all visible, and hence at least two c-sides must be fixed.
Altogether, we have proved that at least two c-sides are fixed and that at least one c-side is flexible. Therefore, in each clause gadget, exactly one c-side if flexible, which corresponds to having exactly one true literal, as desired.
Lemma 3 ( ). If the formula ϕ admits a satisfying assignment with exactly one true literal in each clause, then graph G admits a storyplan.
Proof. We avoid repeating the initial part of the proof, which is reported in the main body of the paper. Observe that, after having drawn the fixed v-sides and w-sides, each flexible v-side can be drawn independently, by letting appear and disappear its three vertices one by one. When a vertex appears, its edges towards the fixed w-sides of its wire gadgets and the fixed v-side of its variable gadget form a star; see Fig. 4. To conclude the proof, we first draw the clause gadgets alone, and then we show how to integrate in the storyplan the flexible w-sides and their connections, as well as the connections of the fixed w-sides with the corresponding c-sides.
We now draw the clauses one by one. We begin by showing how to draw a single clause gadget K(C j ), ignoring the connections with the linked wire gadgets. Refer to Fig. 5 for an illustration. We first let appear the three special vertices of K(C j ) (Fig. 5(a)). Now we let appear the two simple vertices of a false literal, which we denote by l 1 for convenience ( Fig. 5(b)). Note that the whole c-side representing l 1 is visible. Right after, the special vertex connected to the two simple vertices can disappear. Next, we let appear the two simple vertices of the remaining false literal, called l 2 , hence again this c-side is entirely visible (Fig. 5(c)). Again this can be done without crossings, and the corresponding special vertex can disappear right after. Now we have a 4-cycle (with a light blue background in Fig. 5(c)) formed by the edges connecting the simple vertices drawn so far, and the special vertex of the missing literal lying in one of the two faces made by the cycle. We let one of the two simple vertices of the true literal appear (Fig. 5(d)), we draw its edges planarly, and afterwards we let it disappear and replace it with the last simple vertex (Fig. 5(e)). Once the last simple vertex has appeared, all vertices of the clause can disappear. Hence, the last c-side hasn't appeared together but instead acted as a flexible c-side.
Consider a wire gadget W (l ij ). Suppose first that l ij is false. Then we have seen that its c-side in K(C j ), say U , is fixed and hence W (l ij ) must be flexible. Note that both if l ij = l 1 (Fig. 10(a)) or l ij = l 2 ( Fig. 10(b)), in the frame in which the three vertices of U are visible there is a face whose boundary contains the three vertices of the corresponding c-side. We can assume that this face encloses the drawings of all the w-sides and v-sides that are currently visible. Hence the vertices of W (l ij ) can be drawn one by one in this face. If l ij is true, then its c-side U is flexible and hence W (l ij ) must be fixed. Again in the two frames in which the vertices of U appear (see Figs. 5(d) and 5(e)), the drawing of the clause has a face whose boundary contains the vertex of U visible in that frame. Again we can assume that this face encloses the drawings of all the wsides and v-sides that are currently visible, and therefore the vertices of U can be connected planarly both to its neighbors in K(C j ) and to its neighbors in W (l ij ) (see Fig. 11). By repeating this procedure for each clause we complete the storyplan.
Theorem 2 ( ). The StoryPlan problem is NP-hard and it has no 2 o(n) time algorithm unless ETH fails.
Proof. Constructing the graph G from the formula ϕ clearly takes polynomial time, and the correctness of the reduction follows from Lemmas 2 and 3. This proves that StoryPlan is NP-hard.
For the second part of the statement, observe that the Exponential Time Hypothesis (ETH), combined with the Sparsification Lemma, states that 3SAT formulas on N variables and M clauses cannot be solved in 2 o(N +M ) time, see [12,13]. On the other hand, there exists a polynomial-time reduction from 3SAT to One-In-Three 3SAT that transforms 3SAT instances with N + M variables and clauses into equivalent One-In-Three 3SAT instances with O(N + M ) variables and clauses [21]. Finally, starting from an instance of One-In-Three 3SAT, our reduction constructs a graph with n vertices and m edges such that m = O(n) and n+m = O(N +M ). Therefore, an algorithm solving StoryPlan in 2 o(n) time would contradict ETH.
Theorem 3 ( ). The StoryPlan problem is in NP. Also, given an n-vertex graph G, there is an algorithm that solves StoryPlan on G in 2 O(n log n) time.
Proof. The key observation to claim that the problem belongs to NP lies in the fact that, since we consider topological drawings in which edges are Jordan arcs, once a total order of the vertices is fixed, the existence of a storyplan is equivalent to the existence of a sequence of planar embeddings that are "consistent". Namely, for any two such planar embeddings, if they share a common subgraph, 22 C. Binucci et al. The Storyplan Problem then their restrictions to this subgraph must coincide. With this observation, we can guess a candidate solution and verify, in polynomial time, if it is valid. However, we intertwine the generation process of the solutions and their validity check in order to obtain a more efficient time complexity.
More formally, we proceed as follows. We first guess a linear order of the vertices of G. Note that there are n! ∈ 2 O(n log n) such orders. For each i ∈ [n], we identify the set of vertices V i visible at step i and the corresponding set of edges E i . By planarity, it must be |E i | ≤ 3|V i |−6, else we can immediately reject the instance. As already observed, we do not guess a drawing D i , but instead a planar embedding E i for graph G i = (V i , E i ).
If G i is connected, the planar embedding E i can be described by the circular order of the edges around each vertex, called rotation system, and by the choice of the outer face. Indeed, with this information, one can reconstruct the boundary of each face of G i (in linear time). If G is not connected, we also need the pairwise relative positions of distinct connected components (if more than one). Let C 1 , . . . , C q be the connected components of G i and let E i (C j ) be the restriction of E i to C j for each j ∈ [q]. The position system is a rooted tree whose vertices are the faces of the embeddings E i (C j ) for each j ∈ [q], and a node ν has a parent µ in this tree if and only if the face corresponding to ν contains the face corresponding to µ in its interior and µ is the outer face of its connected component.  O(n) .  O(n) , since it suffices to guess the parent of each node of the tree. Therefore, for each step i > 1, there are O(n 2 ) · n rot · n pos ⊆ n O(n) ⊆ 2 O(n log n) distinct embeddings that we can guess.
Once we have generated all planar embeddings for each i ∈ [n], we aim at finding a sequence (if any) of planar embeddings, one for each step i, in which common subgraphs have the same embedding throughout the sequence. Namely, for each i > 1 and for each planar embedding E i , we verify whether there is at least one planar embedding E i−1 such that the restrictions of E i and E i−1 to the common graph G i−1 ∩ G i are the same. If this is the case, we keep E i , else we discard it. The algorithm halts if the set of planar embeddings becomes empty, else it outputs at least one valid sequence. Overall, the procedure takes Proof. One direction is trivial, since it is easily seen that admitting a storyplan is a hereditary property. Suppose now that G admits a storyplan S = τ , {D } i∈ [n ] , where n = n − 1. We distinguish three cases based on the reduction rule applied to G. In each case, we denote by x the vertex removed from G to obtain G .
Case A (R.1). See Fig. 6 for an illustration. Let v be the neighbor of x in G, whose lifespan according to τ is [i v , j v ]. We compute τ from τ by inserting [n] from {D } i∈ [n ] as follows. For each i ≤ i v , we set D i = D i . For i = i v + 1, we draw x in D iv sufficiently close to v such that xv can be drawn as a straight-line segment that does not intersect any other edge. We then set D i to be equal to the resulting drawing. Finally, for each i > i v + 1, we set Case B (R.2). See Fig. 12 for an illustration. By assumption, G contains at least one vertex v = x of type U , whose lifespan according to τ is [i v , j v ]. We compute τ from τ by inserting x right after v; consequently, the lifespan of by drawing x sufficiently close to v and by drawing, for each neighbor w of x, the edge xw such that it follows the curve representing the edge vw.
Since vw does not cross any other edge and v has degree two, the same holds for xw. We then set D i to be equal to the resulting drawing. Similarly, for each i ≤ [i v + 2, j v + 1], we extend (if needed) the frame D i−1 by drawing any edge xw such that it follows the corresponding curve vw. Finally, for each i > j v + 1, we set D i = D i−1 .
Case C (R.3). Observe that, by assumption, the graph induced by the vertices of U ∪ V U contains a complete bipartite graph K a,b with a ≥ 3 and b ≥ 3, whose partite sets are U and V U . We distinguish two subcases based on whether U is the fixed set or the flexible set of K a,b .
Suppose first that U is the fixed set; see Fig. 13 for an illustration. Let I ∈ [n ] be the interval in which all vertices of U are visible. By assumption, G contains at least three vertices v j = x of V U , with j = 1, 2, 3. Observe that the lifespan of each vertex v j intersects I, therefore there are at least two vertices, say v 1 and v 2 , whose lifespans do not intersect, otherwise there would be a frame containing K 3,3 . Let [i 1 , j 1 ] and [i 2 , j 2 ] be the lifespan of v 1 and v 2 , respectively, and suppose (without loss of generality) that j 1 < i 2 . Observe that both j 1 and i 2 are in I. We compute τ from τ by inserting x right after v 1 disappears, such that its lifespan in τ is [j 1 + 1, j 1 + 1]. For each i ≤ j 1 , we set D i = D i . For i = j 1 + 1, we take D j1 and replace the drawing of v 1 with the drawing of x. Namely, we place x on the same point of v 1 and we draw each curve xw by following the curve v 1 w. Since v 1 w does not cross any other edge, the same holds for xw. The resulting drawing is D i . Finally, for each i > j 1 + 1, we set D i = D i−1 .
x Fig. 13. Illustration for Case C of the proof of Lemma 4, when U is the fixed set. Let v = x be the vertex of V U such that τ (v) = s. We compute τ from τ by inserting x right next v such that its lifespan in τ is [s + 1, t + 1]. For each i ≤ s, we set D i = D i . For i = s + 1, we extend D i by drawing x sufficiently close to v and by drawing, for each neighbor w of x, the edge xw such that it follows the curve representing the edge vw. Note that in each frame D i with i ∈ [s, t] there are at most two vertices of U , and that there are no edges between vertices of V U . Hence, similarly as in Case B, vertex v has degree two and the curve xw does not cross any other edge. We then set D i to be equal to the resulting drawing. Similarly, for each i ≤ [s + 2, t + 1], we extend (if needed) the frame D i−1 by drawing any edge xw such that it follows the corresponding curve vw. Finally, for each i > t + 1, we set D i = D i−1 .

B.4 Missing Proofs for Section 3.4
Theorem 6 ( ). Every partial 3-tree G with n vertices admits a storyplan, which can be computed in O(n) time. 4 Fig. 15. The graph G * uf the 3-tree G of Figure 7; each vertex v of G * is labeled with the vertices of G whose representative vertex is v.
Proof. We avoid repeating the part of the proof described in the main body of the paper. We only prove that the described storyplan can be computed in linear time. If G is a partial 3-tree it can be augmented to a (non-partial) 3-tree in O(n) time [15]. The reverse of the order in which the vertices are added to construct G is called a perfect elimination ordering and can be computed in O(n) time [19]. Starting from this order we can compute T in O(n) time. The order τ can be computed in O(n) time by performing a preorder visit of T . During this visit we also compute some information that are useful to compute efficiently all the drawings {D i } i∈ [n] . First, we compute an embedded planar 3-tree G * that is a supergraph of each G i (refer to Figure 15). The idea to construct G * is to keep only one representative, for each set of vertices whose parent cliques have the same set of representatives. We construct G * starting with the initial 3-cycle (which is associated with the root); each vertex of this 3-cycle is its own representative. When we visit a bag µ, we consider the three representatives of the vertices of the parent clique C of v µ ; these three vertices can be obtained in O(1) time by storing for each vertex its representative. If a vertex v connected to the representative vertices of C already exists, we do not modify G * and store v as the representative vertex of v µ ; if no vertex has already been connected to the representative vertices of C, we add a new vertex v to G * connecting it to the representative vertices of C and, also in this case, we store v as the representative vertex of v µ . Since both cases can be handled in O(1) time, the overall construction of G * can be executed in O(n) time. Also, G * has O(n) vertices and edges. Second, we store for each i (with i = 1, 2, . . . , n) the list i of vertices that have to be removed when constructing D i from D i−1 . These vertices are all the vertices associated with the bags of T that are visited before µ i and after its parent µ j (this set of vertices may be empty) and they can be stored, in the reverse order of addition, while backtracking from µ i−1 during the preorder visit.
Once we have G * we can use any existing O(n)-time algorithm to compute a planar straight-line grid drawing D * of G * (for example the shift algorithm [7]). By the construction of G * , each drawing {D i } i∈ [n] is a sub-drawing of D * and therefore we can compute each D i by removing from D * the vertices and edges that do not belong to G i . In particular at each step i we can use the list i to find the vertices to be removed from D i−1 ; these vertices are removed in reverse order of addition and when a vertex is removed we also remove the three edges that connect it to its parent clique. Since each vertex and each edge is added once and removed once, the set {D i } i∈ [n] can be computed in O(n) time.

C Missing Proofs for Section 4
Theorem 7 ( ). The StoryPlanFixedOrder problem is NP-complete.
Proof. Suppose first that G 1 , G 2 , G 3 admit a SEFE Γ 1 , Γ 2 , Γ 3 . Let Γ be the drawing obtained as follows: (1) let Γ be the union of Γ 1 , Γ 2 , Γ 3 ; (ii) let Γ be the drawing obtained from Γ by subdividing all exclusive edges in E i for each i = 1, 2, 3 (the subdivision vertex can be placed at any point along the curve representing the edge); (iii) finally, let Γ be the drawing obtained from Γ by drawing for each vertex v its spectator s v sufficiently close such that the edge vs v can be realized as a straight-line segment that does not intersect any other edge. Then a storyplan τ, {D i } i∈ [n] can be obtained by setting each drawing D i equal to the subdrawing of Γ induced by the vertices visible at step i. By construction, the position of a vertex is the same over all frames that contain it. It remains to prove that each frame is planar.
-Each frame D i with i ∈ [τ − 1 , τ + 1 ] is a subdrawing of Γ [V ], which is planar because it contains only the edges that are part of the common intersection of G 1 , G 2 , G 3 .
-Each frame D i with i ∈ [τ − 2 , τ + 3 ] is planar because it is a subdrawing of Γ 1 in which each edge has been subdivided and the spectators of such subdivision vertices have been drawn without introducing crossings.
-Observe that in τ − 4 , all spectators of the subdivision vertices of E 1 disappear and hence the same holds for the subdivision vertices of E 1 . It follows that each frame D i with i ∈ [τ − 4 , τ + 5 ] is planar because it is a subdrawing of Γ 2 in which each edge has been subdivided and the spectators of such subdivision vertices have been drawn without introducing crossings. The same argument (with respect to E 3 ) can be used to prove the planarity of each frame D i with i ∈ [τ − 6 , τ + 7 ]. Suppose now that G, τ admits a storyplan τ, {D i } i∈ [n] . Then a SEFE Γ 1 , Γ 2 , Γ 3 of G 1 , G 2 , G 3 can be obtained as follows. Let Γ * 1 = The membership to NP follows the lines of Theorem 3, simply ignoring the initial guess of a total order, which is instead given as part of the input.