1 Introduction

Recently, there has been considerable interest in representing graphs with as few objects as possible. The idea behind this objective is to keep the visual complexity of a drawing low for the observer. The types of objects that have been used are straight-line segments [5, 8, 14, 15] and circular arcs [14, 16].

Chaplick et al. [3] considered covering straight-line drawings of graphs by lines or planes and defined the following new graph parameters. Let \(1 \le l < d\), and let G be a graph. The l-dimensional affine cover number of G in \(\mathbb R^d\), denoted by \(\rho ^l_d(G)\), is defined as the minimum number of l-dimensional planes in \(\mathbb R^d\) such that G has a crossing-free straight-line drawing that is contained in the union of these planes. The weak l-dimensional affine cover number of G in \(\mathbb R^d\), denoted by \(\pi ^l_d(G)\), is defined similarly to \(\rho ^l_d(G)\), but under the weaker restriction that only the vertices are contained in the union of the planes. Clearly, \(\pi ^l_d(G)\le \rho ^l_d(G)\), and if \(l'\le l\) and \(d'\le d\) then \(\pi ^l_d(G)\le \pi ^{l'}_{d'}(G)\) and \(\rho ^l_d(G)\le \rho ^{l'}_{d'}(G)\). It turns out that it suffices to study the parameters \(\rho ^1_2\), \(\rho ^1_3\), \(\rho ^2_3\), and \(\pi ^1_2\), \(\pi ^1_3\), \(\pi ^2_3\):

Theorem 1

(Collapse of the Affine Hierarchy [3]). For any integers \(1\le l<3\le d\) and for any graph G, it holds that \(\pi ^l_d(G)=\pi ^l_3(G)\) and \(\rho ^l_d(G)=\rho ^l_3(G)\).

Disproving a conjecture of Firman et al. [12], Eppstein [10] constructed planar, cubic, 3-connected, bipartite graphs on n vertices with \(\pi ^1_2(G) \ge n^{1/3}\). Answering a question of Chaplick et al. [3] he also constructed a family of subcubic series-parallel graphs with unbounded \(\pi ^1_2\)-value. Felsner [11] proved that, for every 4-connected plane triangulation G on n vertices, it holds that \(\pi ^1_2(G) \le \sqrt{2n}\). Chaplick et al. [4] also investigated the complexity of computing the affine cover numbers. Among others, they showed that in 3D, for \(l \in \{1,2\}\), it is NP-complete to decide whether \(\pi ^l_3 (G) \le 2\) for a given graph G. In 2D, the question has still been open, but a related question was raised by Dujmović et al. [7] already in 2004. They investigated so-called track layouts which are defined as follows. A graph admits a k-track layout if its vertices can be partitioned into k ordered independent subsets such that any pair of subsets induces a plane graph (w.r.t. the order of the subsets). The track number of a graph G, \({{\,\mathrm{tn}\,}}(G)\), is the smallest k such that G admits a k-track layout. See also [6] for some recent developments. Note that in general \(\pi ^1_2(G) \ne {{\,\mathrm{tn}\,}}(G)\); for example, \(\pi ^1_2(K_4)=2\), whereas \({{\,\mathrm{tn}\,}}(K_4)=4\). Note further that a 3-track layout is necessarily plane (which is not the case for k-track layouts with \(k>3\)). Dujmović posed the computational complexity of k-track layout as an open question.

While it is easy to decide efficiently whether a graph admits a 2-track layout, Bannister et al. [1] answered the open question of Dujmović et al. already for 3-track layouts in the affirmative. They first showed that a graph has a leveled planar drawing if and only if it is bipartite and has a 3-track layout. Combining this results with the NP-hardness of level planarity, proven by Heath and Rosenberg [13], immediately showed that it is NP-hard to decide whether a given graph has a 3-track layout. For \(k>3\), deciding the existence of a k-track layout is NP-hard, too, since it suffices to add to the given graph \(k-3\) new vertices each of which is incident to all original vertices of the graph [1].

Our contribution. We investigate several problems concerning the weak line cover number \(\pi _2^1(G)\) and the strong plane cover number \(\rho _3^2(G)\):

  • We settle the open question of Chaplick et al. [4, p. 268] by showing that it is NP-hard to test whether, for a given planar graph G, \(\pi ^1_2(G)=2\); see Sect. 2.

  • We show that \(G_d\), the universal stacked triangulation of depth d, (which has treewidth 3) has \(\pi ^1_2(G_d)=d+1=\log _3(2n_d-5)+1\), where \(n_d\) is the number of vertices of \(G_d\); see Sect. 3.

  • Eppstein has identified classes of treewidth-2 graphs with unbounded \(\pi ^1_2\)-value. We give an easy direct argument showing that some 2-tree \(H_d\) with \(n'_d\) vertices has \(\pi ^1_2(H_d)\in \varOmega (\log n'_d)\); see the full version [2].

  • Concerning 3D, we show that any n-vertex graph G with \(\rho ^2_3(G)=2\) has at most \(5n-19\) edges; see Sect. 4. This bound is tight.

2 Complexity of Computing Weak Line Covers in 2D

In this section we investigate the computational complexity of deciding whether a graph can be drawn on two lines.

Theorem 2

It is NP-hard to decide whether a given plane (or planar) graph G admits a drawing with \(\pi ^1_2(G)=2\).

Proof

Our proof is by reduction from the problem Level Planarity, which Heath and Rosenberg [13] proved to be NP-hard. The problem is defined as follows. A planar graph G is leveled-planar if its vertex set can be partitioned into sets \(V_1,\dots ,V_m\) such that G has a planar straight-line drawing where, for every \(i \in \{1,\dots ,m\}\), vertices in \(V_i\) lie on the vertical line \(\ell _i :y=i\) and each edge \(v_j v_k\) of G connects two vertices on consecutive lines (that is, \(|j-k|=1\)).

Chaplick et al. [3] have shown that every leveled-planar graph can be drawn on two lines. The converse, however, is not true. For example, \(K_4\) is not leveled-planar, but \(\pi ^1_2(K_4)=2\). Therefore, we modify the given graph in three ways. (a) We replace each edge of G by a \(K_{2,4}\)-gadget where the two nodes in one set of the bipartition replace the endpoints of the former edge; see Fig. 1a. (b) We add to the graph \(G'\) that resulted from the previous step a new subgraph \(G_0\) (two copies of \(K_4\) sharing exactly two vertices), which we connect by a path to a vertex on the outer face of G. (If the outer face is not fixed, we can try each vertex.) In Fig. 1b, \(G_0\) is yellow and the path is red. The length L of the path is any upper bound on the number of levels of \(G'\), e.g., the diameter of \(G'\) (plus 1). (c) We attach to \(G_0\) a triangulated spiral S (dark green in Fig. 1b). The spiral makes \(L+2\) right turns; its final vertex is identified with the outermost vertex of the previous turn. Hence, apart from its many triangular faces, the graph \(S+G_0\) has a large inner face F of degree \(2(L+2)\) and a quadrangular outer face. Let \(G''\) be the resulting graph. It remains to show that G is leveled-planar if and only if \(\pi _2^1(G'')=2\).

\(\Rightarrow \)”: Fix a leveled-planar drawing of G. By doubling the layers and using the new layers to place the large sides of \(K_{2,4}\)’s, one easily sees that \(G'\) is also leveled-planar, see Fig. 1a. As shown in Fig. 1b, the large inner face F of \(S+G_0\) can be drawn so that it partitions the halflines emanating from the origin into L levels. (It is no problem that consecutive levels are turned by \(90^\circ \).) Since we chose L large enough (in particular \(L \ge 2m-1\)), we can easily draw \(G'\) inside F. Note that the red path attached to \(G_0\) is long enough to reach any vertex on the outer face of \(G'\). Hence, \(\pi ^1_2(G'')=2\).

\(\Leftarrow \)”: Fix a drawing of \(G''\) on two lines. The two lines cannot be parallel since \(G''\) contains \(K_{2,4}\) and is not outer-planar; so after translation and/or skew we may assume that these two lines are the two coordinate axes. It is not hard to verify that \(G_0\) must be drawn such that the origin is in its interior, at the common edge of the two \(K_4\)’s. Furthermore, given this drawing of \(G_0\), the 3-connected spiral S must be drawn as in Fig. 1b. Due to planarity and the fact that \(G'\) is connected to \(G_0\) via the red path, \(G'\) can only be drawn in the interior of F. The drawing of \(S+G_0\) partitions the halflines emanating from the origin into levels, which we number \(1,2,\dots \) starting from the innermost level that contains a vertex of \(G'\). Inside this face, the only way to draw the \(K_{2,4}\)-gadgets is as in Fig. 1a, spanning three consecutive levels. This forces all vertices of G to be placed on the odd-numbered levels and the vertices in \(G'-G\) on the even-numbered levels. Now we can get a level assignment for G by reverting the transformation in Fig. 1a. Hence, G is leveled-planar.

This shows that our reduction is correct. It runs in polynomial time.    \(\square \)

Fig. 1.
figure 1

Our reduction from Level Planarity

3 Weak Line Covers of Planar 3-Trees in 2D

In this section we consider the weak line cover number \(\pi ^1_2\) for planar graphs, i.e., we are interested in crossing-free straight-line drawings with vertices located on a small collection of lines. Clearly \(\pi ^1_2(G)=1\) if and only if G is a forest of paths. The set of graphs with \(\pi ^1_2(G)=2\), however, is already surprisingly rich, it contains all trees, outerplanar graphs and subgraphs of grids [1, 10].

Stacked triangulations, a.k.a. planar 3-trees or Apollonian networks, are obtained from a triangle by repeatedly selecting a triangular face T and adding a new vertex (the vertex stacked inside T) inside T with edges to the vertices of T. This subdivides T into three smaller triangles, the children of T.

Fig. 2.
figure 2

A drawing of \(G_2\) that can be extended to a drawing of \(G_3\) on 5 parallel lines.

For \(d\ge 0\) let \(G_d\) be the universal stacked triangulation of depth d, defined as follows. The graph \(G_0\) is a triangle \(T_0\), and \(G_d\) (for \(d\ge 1\)) is obtained from \(G_{d-1}\) by adding a stack vertex in each bounded face of \(G_{d-1}\). Graph \(G_d\) has \(n_d=\frac{1}{2}(3^d+5)\) vertices and \(3^d\) bounded faces. We show that its weak line cover number is \(d+1=\log _3(2n_d-5)+1 \in \Theta (\log n_d)\). (A lower bound of d can also be found in Eppstein’s recent book [9, Thm. 16.13].)

Theorem 3

For \(d\ge 1\) it holds that \(\pi (G_d) = d+1\).

Proof

Here we prove only the lower bound; the construction for the upper bound is illustrated in Fig. 2 and given in the full version. Let \(\mathcal {L}\) be a family of lines covering the vertices of a drawing of \(G_d\). Let a, b, and c be the vertices of \(T_0\). We first argue that at least d lines are needed to cover \(V\setminus T_0\). Let \(x_1\) be stacked into \(T_0\). There is a line \(L_1\in \mathcal {L}\) covering \(x_1\). Note that \(L_1\) can intersect only two of the three child triangles of \(T_0\) (where “intersect” here means “in the interior”). Let \(T_1\) be a child triangle avoided by \(L_1\), and let \(x_2\) be the vertex stacked into \(T_1\). There is a line \(L_2\in \mathcal {L}\) covering \(x_2\). Let \(T_2\) be a child triangle of \(T_1\) avoided by \(L_2\). Iterating this yields d pairwise distinct lines in \(\mathcal {L}\).

To find one additional line in \(\mathcal {L}\), we distinguish some cases. If a line \(L\in \mathcal {L}\) covers two vertices of \(T_0\), then it covers no inner vertex, and we are done.

Assume some line \(L_a\in \mathcal {L}\) intersects \(x_1\) and one vertex of \(T_0\), say a. Let \(L_b\) and \(L_c\) be the lines intersecting b and c. The lines \(L_a\), \(L_b\), and \(L_c\) are pairwise different, else we are in the previous case. Of the three child triangles of \(T_0\), at most one is intersected by \(L_a\) and at most two each are intersected by \(L_b\) and \(L_c\). Therefore, some child triangle \(T_1\) of \(T_0\) is intersected by at most one of \(L_a\), \(L_b\), or \(L_c\). The graph \(G_{d-1}\) inside \(T_1\) requires at least \(d-1\) lines for its interior points, and at most one of those lines is \(L_a\), \(L_b\), or \(L_c\), so in total at least \(d+1\) lines are needed.

The argument is similar if no line covers two of a, b, c, and \(x_1\). The four distinct lines supporting a, b, c, and \(x_1\) then intersect at most two child triangles each. So one child triangle \(T_1\) is intersected by at most two of these lines. Combining the \(d-1\) lines needed for the interior of \(T_1\) with the two lines that do not intersect it, shows that \(d+1\) lines are needed.    \(\square \)

4 Maximal Graphs on Two Planes in 3D

We now switch to dimension \(d=3\) and the strong cover number. Obviously any graph G with a drawing that is covered by two planes has at most \(6n-12\) edges since it is the union of two planar graphs. Using maximality arguments and counting, we show that in fact G has at most \(5n-19\) edges if \(n\ge 7\). (The restriction \(n \ge 7\) is required since for \(n=3,4,5,6\) we can have 3, 6, 9, 12 edges.)

We argue first that our bound is tight. The spine is the intersection of two planes A and B. Put a path with \(n-4\) vertices on the spine. Add one vertex in each of the four halfplanes and connect each of these vertices to all vertices on the spine and to the vertex on the opposite halfplane. (We provide a figure in the full version.) This yields \(n-5\) edges on the path and \(2(n-4)+1\) edges in each of the two planes, so \(5n-19\) edges in total.

Theorem 4

Any graph G with \(\rho ^2_3(G)=2\) and \(n\ge 7\) vertices has at most \(5n-19\) edges.

Proof

Fix a drawing of G on planes A and B, inducing planar graphs \(G_A\) and \(G_B\) within those planes. Let \(G_A^+\) and \(G_B^+\) be the graphs obtained from \(G_A\) and \(G_B\) by adding any edge that can be inserted without crossing, within the same plane, and with at most one bend on the spine. Clearly it suffices to argue that \(G_A^+\) and \(G_B^+\) together have at most \(5n-19\) edges. Let s be the number of vertices on the spine, let a be the number of vertices of \(G_A^+\) not on the spine, and let b be the number of vertices of \(G_B^+\) not on the spine. Clearly, \(a+b+s=n\). We may assume \(a\le b\). We also assume that \(1\le s\le n-4\) and that at least one edge of \(G_A^+\) crosses the spine (so \(2\le a\le b\)); see the full version.

Let t be the number of edges drawn along the spine. These are the only edges that belong to \(G_A^+\) and \(G_B^+\). Since \(G_A^+\) and \(G_B^+\) have at least three vertices each, we can bound the number of edges of G, m(G), as follows:

$$\begin{aligned} m(G)&\le m(G_A^+) + m(G_B^+)-t \,\le \, 3(s+a)-6 + 3(s+b)-6 - t \\&= 3n-12 + 3s - t \,\le \, 4n-16+2s-t. \nonumber \end{aligned}$$
(1)

So we must show that \(2s-t\le n-3\). Let an internal gap be a line segment connecting two consecutive, non-adjacent vertices on the spine. There are \(s-t-1\) internal gaps. Let the external gap be the two infinite parts of the spine. Note that at least one edge of \(G_A^+\) must cross the external gap, because \(G_A^+\) has at least one vertex on each side of the gap, and we could connect the extreme such vertices (or re-route an existing edge) to cross the external gap, perhaps using a bend on the spine. We may further assume that even after such re-routing every internal gap is crossed by at least one edge of \(G_A^+\). Otherwise we could delete all edges of \(G_B^+\) passing through the gap, insert the edge between the spine vertices, and re-triangulate the drawing of \(G_B^+\) where we removed edges. This would remove an internal gap, but would not decrease the number of edges. Since no edge can cross two gaps, at least \(s-t\) edges of \(G_A^+\) cross gaps. These edges form a planar bipartite graph with at most a vertices; therefore \(s-t\le 2a-3\).Footnote 1 This yields \(2s-t \le s + 2a-3 \le s + a + b - 3 = n-3\) as desired.    \(\square \)

We conjecture that the following more general statement holds:

Any n-vertex graph G with \(\rho ^2_3(G)=k\) has at most \((2k+1)(n-2k)+k-1\) edges, for all large enough n.