1 Introduction

A drawing of a graph maps each vertex to a distinct point in the plane, each edge to a Jordan curve connecting the points of its incident vertices but not containing the point of any other vertex, and two such Jordan curves have at most one common point. In the last few years, the focus in graph drawing has shifted from exploiting structural properties of planar graphs to addressing the question of how to produce well-structured (understandable) drawings in the presence of edge crossings, i.e., to the topic of beyond-planar graph classes. The primary approach here has been to define and study graph classes which allow some edge crossings, but restrict the crossings in various ways. Two commonly studied such graph classes are:

  1. 1.

    k-planar graphs, the graphs which can be drawn so that each edge (Jordan curve) is crossed by at most k other edges.

  2. 2.

    k-quasi-planar graphs, the graphs which can be drawn so that no k pairwise non-incident edges mutually cross.

Note that the 0-planar graphs and 2-quasi-planar graphs are precisely the planar graphs. Additionally, the 3-quasi-planar graphs are simply called quasi-planar.

In this paper we study these two families of classes of graphs by restricting the drawings so that the points are placed in convex position and edges mapped to line segments, i.e., we apply the above two generalizations of planar graphs to outerplanar graphs and study outer k-planarity and outer k-quasi-planarity. We consider balanced separators, treewidth, degeneracy (see paragraph “Concepts” below), coloring, edge density, and recognition for these classes.

Related work. Ringel [27] was the first to consider k-planar graphs by showing that 1-planar graphs are 7-colorable. This was later improved to 6-colorable by Borodin [8]. This is tight since \(K_6\) is 1-planar. Many additional results on 1-planarity can be found in a recent survey paper [21]. Generally, each n-vertex k-planar graph has at most \(4.108n\sqrt{k}\) edges [26] and treewidth \(O(\sqrt{kn})\) [14].

Outer k-planar graphs have been considered mostly for \(k \in \{0,1,2\}\). Of course, the outer 0-planar graphs are the classic outerplanar graphs which are well-known to be 2-degenerate and have treewidth at most 2. It was shown that essentially every graph property is testable on outerplanar graphs [5]. Outer 1-planar graphs are a simple subclass of planar graphs and can be recognized in linear time [4, 18]. Full outer 2-planar graphs, which form a subclass of outer 2-planar graphs, can been recognized in linear time [19]. General outer k-planar graphs were considered by Binucci et al. [7], who (among other results) showed that, for every k, there is a 2-tree which is not outer k-planar. Wood and Telle [30] considered a slight generalization of outer k-planar graphs in their work and showed that these graphs have treewidth O(k).

The k-quasi-planar graphs have been heavily studied from the perspective of edge density. The goal here is to settle a conjecture of Pach et al. [25] stating that every n-vertex k-quasi-planar graph has at most \(c_kn\) edges, where \(c_k\) is a constant depending only on k. This conjecture is true for \(k=3\) [2] and \(k=4\) [1]. The best known upper bound is \((n\log n )2^{\alpha (n)^{c_k}}\) [16], where \(\alpha \) is the inverse of the Ackermann function. Edge density was also considered in the “outer” setting: Capoyleas and Pach [9] showed that any k-quasi-planar graph has at most \(2(k-1)n - \left( {\begin{array}{c}2k-1\\ 2\end{array}}\right) \) edges, and that there are k-quasi-planar graphs meeting this bound. More recently, it was shown that the semi-bar k-visibility graphs are outer \((k+2)\)-quasi-planar [17]. However, the outer k-quasi-planar graph classes do not seem to have received much further attention.

The relationship between k-planar graphs and k-quasi-planar graphs was considered recently. While any k-planar graph is clearly \((k+2)\)-quasi-planar, Angelini et al. [3] showed that any k-planar graph is even \((k+1)\)-quasi-planar.

The convex (or 1-page book) crossing number of a graph [29] is the minimum number of crossings which occur in any convex drawing. This concept has been introduced several times (see [29] for more details). The convex crossing number is NP-complete to compute [23]. However, recently Bannister and Eppstein [6] used treewidth-based techniques (via extended monadic second order logic) to show that it can be computed in linear FPT time, i.e., \(O(f(c)\cdot n)\) time where c is the convex crossing number and f is a computable function. Thus, for any k, the outer k-crossing graphs can be recognized in time linear in \(n+m\).

Concepts. We briefly define the key graph theoretic concepts that we will study.

A graph is d-degenerate when every subgraph of it has a vertex of degree at most d. This concept was introduced as a way to provide easy coloring bounds [22]. Namely, a d-degenerate graph can be inductively \(d+1\) colored by simply removing a vertex of degree at most d. A graph class is d-degenerate when every graph in the class is d-degenerate. Furthermore, a graph class which is hereditary (i.e., closed under taking subgraphs) is d-degenerate when every graph in that class has a vertex of degree at most d. Note that outerplanar graphs are 2-degenerate, and planar graphs are 5-degenerate.

A separation of a graph G is pair AB of subsets of V(G) such that \(A \cup B = V(G)\), and no edge of G has one end in \(A\setminus B\) and the other in \(B \setminus A\). The set \(A \cap B\) is called a separator and the size of the separation (AB) is \(|A \cap B|\). A separation (AB) of a graph G on n vertices is balanced if \(|A \setminus B| \le \frac{2n}{3}\) and \(|B \setminus A| \le \frac{2n}{3}\). The separation number of a graph G is the smallest number s such that every subgraph of G has a balanced separation of size at most s. The treewidth of a graph was introduced by Robertson and Seymour [28]; it is closely related to the separation number. Namely, any graph with treewidth t has separation number at most \(t+1\) and, as Dvořák and Norin [15] recently showed, any graph with separation number s has treewidth at most 105s. Graphs with bounded treewidth are well-known due to Courcelle’s Theorem (see Theorem 6) [10], i.e., having bounded treewidth means many problems can be solved efficiently.

The Exponential Time Hypothesis (ETH) [20] is a complexity theoretic assumption defined as follows. For \(k\ge 3\), let \(s_k=\inf \{\delta \) : there is an \(O(2^{\delta n})\)-time algorithm to solve k-SAT}. ETH states that for \(k \ge 3\), \(s_k >0\), e.g., there is no quasi-polynomial time Footnote 1 algorithm that solves 3-SAT. So, finding a problem that can be solved in quasi-polynomial time and is also NP-complete, would contradict ETH. In recent years, ETH has become a standard assumption from which many conditional lower bounds have been proven [12].

Contribution. In Sect. 2, we consider outer k-planar graphs. We show that they are \((\lfloor \sqrt{4k+1}\rfloor +1)\)-degenerate, and observe that the largest outer k-planar clique has size \((\lfloor \sqrt{4k+1}\rfloor +2)\), i.e., implying each outer k-planar graph can be \((\lfloor \sqrt{4k+1}\rfloor +2)\)-colored and this is tight. We further show that every outer k-planar graph has separation number at most \(2k+3\). For each fixed k, we use these balanced separators to obtain a quasi-polynomial time algorithm to test outer k-planarity, i.e., these recognition problems are not NP-hard unless ETH fails.

In Sect. 3, we consider outer k-quasi-planar graphs. Specifically, we discuss the edge-maximal graphs which have been considered previously under different names [9, 13, 24]. We also relate outer k-quasi-planar graphs to planar graphs.

Finally, in Sect. 4, we restrict outer k-planar and outer k-quasi-planar drawings to closed drawings, where the sequence of vertices on the outer boundary is a cycle. For each k, we express both closed outer k-planarity and closed outer k-quasi-planarity in extended monadic second-order logic. Thus, closed outer k-planarity is testable in \(O(f(k)\cdot n)\) time, for a computable function f.

2 Outer k-Planar Graphs

In this section we show that every outer k-planar graph is \(O(\sqrt{k})\)-degenerate and has separation number O(k). This provides tight bounds on the chromatic number, and allows for testing outer k-planarity in quasi-polynomial time.

Degeneracy. We show that every outer k-planar graph has a vertex of degree at most \(\sqrt{4k+1} + 1\). First we note the size of the largest outer k-planar clique and then we prove that each outer k-planar graph has a vertex matching the clique’s degree. This also tightly bounds the chromatic number in terms of k, i.e., Theorem 1 follows from Lemma 1 (proven in Appendix  B.1) and Lemma 2.

Lemma 1

Every outer k-planar clique has at most \(\lfloor \sqrt{4k+1}\rfloor + 2\) vertices.

Lemma 2

An outer k-planar graph can have maximum minimum degree at most \(\sqrt{4k+1} + 1\) and this bound is tight.

Proof

Assume that the outer k-planar graph has maximum minimum degree \(\delta \). Since we can create a clique with \(\lfloor \sqrt{4k+1}\rfloor + 2 \) vertices (see Lemma 1), \(\delta \ge \lfloor \sqrt{4k+1}\rfloor + 1\). Let us show that \(\delta \) cannot be larger than \(\sqrt{4k+1} + 1\).

Consider an edge ab that cuts \(l\in \mathbb {N}\) vertices of the graph to one side (not counting a and b), then there are at least \(\delta l - l(l+1)\) edges crossing the edge ab. We will now show by induction that if there existed an outer k-planar graph with minimum degree \(\delta \ge \sqrt{4k+1} + 2\), it would be too small to accommodate such a minimum degree vertex.

Any edge ab that cuts l vertices is crossed by at least \(\delta l - l(l+1)\) edges. Therefore, if \(\delta \ge \sqrt{4k+1} + 2\), there is \(l^*\) such that ab cannot cut \(l^* \ge \frac{1}{2} (\delta - 1 -\sqrt{(\delta -1)^2 -4(k+1)})\) vertices because then it is crossed by \(\delta l^* - l^*(l^*+1)\ge k+1\) edges. Take the smallest such \(l^*\) and let us show that there also cannot be an edge ab that cuts more than \(l^*\) vertices. As the induction hypothesis, assume that no edge ab cuts between \(l^*\) and l vertices inclusive. Thus, the minimum number of edges that cross ab is: \(\delta l - l(l+1) + 2(\sum _{j=1}^{l-l^*}j) > k\), where the last term accounts for the absent edges that cut more than \(l-l^*\) vertices. Now, if ab cuts \(l+1\) vertices, it is crossed by

$$\begin{aligned}&\ge \delta l - l(l+1) + 2(\textstyle \sum _{j=1}^{l-l^*}j) + \delta - 2(l+1)+ 2(l-l^*+1)\\&> k + \delta - 2(l+1) + 2(l-l^*+1) > k \end{aligned}$$

edges if \(\delta > 2l^*\).

Since for \(\delta > \sqrt{4k+1} + 2\) the inequality is always satisfied, there cannot be an edge that cuts more then \(l^* < \sqrt{4k+1}/2\) vertices in any outer k-planar graph with the maximum minimum degree \(\delta \ge \sqrt{4k+1} + 2\). But then, such a graph can have at most \(2l^* < \sqrt{4k+1}\) vertices, which is not enough to accommodate the minimum degree vertex required; a contradiction.    \(\square \)

Theorem 1

Each outer k-planar graph is \(\sqrt{4k+1} + 2\) colorable. This is tight.

Quasi-polynomial time recognition via balanced separators. We show that outer k-planar graphs have separation number at most \(2k+3\) (Theorem 2). Via a result of Dvořák and Norin [15], this implies they have O(k) treewidth. However, Proposition 8.5 of [30] implies that every outer k-planar graph has treewidth at most \(3k+11\), i.e., a better bound on the treewidth than applying the result of Dvořák and Norin to our separators. The treewidth \(3k+11\) bound also implies a separation number of \(3k+12\), but our bound is better. Our separators also allow outer k-planarity testing in quasi-polynomial time (Theorem 3).

Theorem 2

Each outer k-planar graph has separation number at most \(2k+3\).

Proof

Consider an outer k-planar drawing. If the graph has an edge that cuts \([\frac{n}{3}, \frac{2n}{3}]\) vertices to one side, we can use this edge to obtain a balanced separator of size at most \(k+2\), i.e., by choosing the endpoints of this edge and a vertex cover of the edges crossing it. So, suppose no such edge exists. Consider a pair of vertices (ab) such that the line ab divides the drawing into left and right sides having an almost equal number of vertices (with a difference at most one). If the edges which cross the line ab also mutually cross each other, there can be at most k of them. Thus, we again have a balanced separator of size at most \(k+2\). So, it remains to consider the case when we have a pair of edges that cross the line ab, but do not cross each other. We call such a pair of edges parallel. We now pick a pair of parallel edges in a specific way. Starting from b, let \(b_l\) be the first vertex along the boundary in clockwise direction such that there is an edge \(b_lb_l'\) that crosses the line ab. Symmetrically, starting from a, let \(a_r\) be the first vertex along the boundary in clockwise direction such that there is an edge \(a_ra_r'\) that crosses the line ab; see Fig. 1 (left). Note that the edges \(a_ra_r'\) and \(b_lb_l'\) are either identical or parallel. In the former case, we see that all other edges crossing the line ab must also cross the edge \(a_ra_r' = b_lb_l'\), and as such there are again at most k edges crossing the line ab. In the latter case, there are two subcases that we treat below. For two vertices u and v, let [uv] be the set of vertices that starts with u and, going clockwise, ends with v. Let \((u, v)=[u, v]\setminus \{u, v\}\).

Fig. 1.
figure 1

Left: the pair of parallel edges \(b_lb_l'\) and \(a_ra_r'\); center: case 1; right: case 2

Case 1. The edge \(b_lb_l'\) cuts \(\mu \le \frac{n}{3}\) vertices to the top; see Fig.  1 (center).

In this case, either \([b_l',b]\) or \([b,b_l]\) has \([\frac{n}{3}, \frac{n}{2}]\) vertices. We claim that neither the line \(bb_l\) nor the line \(bb_l'\) can be crossed more than k times. Namely, each edge that crosses the line \(bb_l\) also crosses the edge \(b_lb_l'\). Similarly, each edge that crosses the line \(bb_l'\) also crosses the edge \(b_lb_l'\). Thus, we have a separator of size at most \(k+2\), regardless of whether we choose \(bb_l\) or \(bb_l'\) to separate the graph. As we observed above, one of them is balanced.

Case 1 \('\). The edge \(a_ra_r'\) cuts at most \(\frac{n}{3}\) vertices to the bottom.

This is symmetric to case 1.

Case 2. The edge \(b_lb_l'\) cuts at most \(\frac{n}{3}\) vertices to the bottom, and the edge \(a_ra_r'\) cuts at most \(\frac{n}{3}\) vertices to the top; see Fig. 1 (right).

We show that we can always find a pair of parallel edges such that one cuts at most \(\frac{n}{3}\) vertices to the bottom and the other cuts at most \(\frac{n}{3}\) vertices to the top, and no edge between them is parallel to either of them. We call such a pair close. If there is an edge e between \(b_lb_l'\) and \(a_ra_r'\), we form a new pair by using e and \(a_ra_r'\) if e cuts at most \(\frac{n}{3}\) vertices to the bottom or by using e and \(b_lb_l'\) if e cuts at most \(\frac{n}{3}\) vertices to the top. By repeating this procedure, we always find a close pair. Hence, we can assume that \(b_lb_l'\) and \(a_ra_r'\) actually form a close pair. Let \(\alpha =|(a_r',a_r)|\), \(\beta =|(b_l', b_l)|\), \(\gamma =|(a_r,b_l')|\), and \(\delta =|(b_l,a_r')|\); see Fig. 1 (right).

Suppose that \(a_r' = b_l\) or \(a_r = b_l'\). We can now use both edges \(b_lb_l'\) and \(a_ra_r'\) (together with any edges crossing them) to obtain a separator of size at most \(2k+3\). The separator is balanced since \(\alpha +\beta \le \frac{2n}{3}\) and \(\gamma +\delta \le \frac{2n}{3}\).

So, now \(a_r,a_r',b_l,b_l'\) are all distinct. Note that \(\gamma , \delta \le \frac{n}{2}\) since each side of the line ab has at most \(\frac{n}{2}\) vertices. We separate the graph along the line \(b_la_r\). Namely, all the edges that cross this line must also cross \(b_lb_l'\) or \(a_r'a_r\). Therefore, we obtain a separator of size at most \(2k+2\).

To see that the separator is balanced, we consider two cases. If \(\delta \ge \frac{n}{3}\) (or \(\gamma \ge \frac{n}{3}\)), then \(\alpha +\beta +\gamma \le \frac{2n}{3}\) (or \(\alpha +\beta +\delta \le \frac{2n}{3}\)). Otherwise \(\delta <\frac{n}{3}\) and \(\gamma < \frac{n}{3}\). In this case \(\delta +\alpha \le \frac{2n}{3}\) and \(\gamma +\beta \le \frac{2n}{3}\). In both cases the separator is balanced.    \(\square \)

Theorem 3

For fixed k, testing the outer k-planarity of an n-vertex graph takes \(O(2^{\mathrm {polylog}\; n})\) time.

Fig. 2.
figure 2

Shapes of separators, special separator S in blue, regions in different colors (red, orange, and pink), components connected to blue vertices in green: (a) closest-parallels case; (b) single-edge case; (c) special case for single-edge separators. (Color figure online)

Proof

Our approach is to leverage the structure of the balanced separators as described in the proof of Theorem 2. Namely, we enumerate the sets which could correspond to such a separator, pick an appropriate outer k-planar drawing of these vertices and their edges, partition the components arising from this separator into regions, and recursively test the outer k-planarity of the regions.

To obtain quasi-polynomial runtime, we need to limit the number of components on which we branch. To do so, we group them into regions defined by special edges of the separators.

By the proof of Theorem 2, if our input graph has an outer k-planar drawing, there must be a separator which has one of the two shapes depicted in Fig. 2(a) and (b). Here we are not only interested in the up to \(2k+3\) vertices of the balanced separator, but actually the set S of up to \(4k+3\) vertices one obtains by taking both endpoints of the edges used to find the separator. Note: S is also a balanced separator. We use a brute force approach to find such an S. Namely, we first enumerate vertex sets of size up to \(4k+3\). We then consider two possibilities, i.e., whether this set can be drawn similar to one of the two shapes from Fig. 2. So, we now fix this set S. Note that since S has O(k) vertices, the subgraph \(G_S\) induced by S can have at most a function of k different outer k-planar drawings. Thus, we further fix a particular drawing of \(G_S\).

We now consider the two different shapes separately. In the first case, in S, we have three special vertices \(v, w_1\) and \(w_2\) and in the second case we will have two special vertices v and w. These vertices will be called boundary vertices and all other vertices in S will be called regional vertices. Note that, since we have a fixed drawing of \(G_S\), the regional vertices are partitioned into regions by the specially chosen boundary vertices. Now, from the structure of the separator which is guaranteed by the proof of Theorem 2, no component of \(G \setminus S\) can be adjacent to regional vertices which live in different regions with respect to the boundary vertices.

We first discuss the case of using \(G_S\) as depicted in Fig. 2(a). Here, we start by picking the three special vertices \(v, w_1\) and \(w_2\) from S to take the role as shown in Fig. 2(a). The following arguments regarding this shape of separator are symmetric with respect to the pair of opposing regions.

Notice that if there is a component connected to regional vertices of different regions, we can reject this configuration. From the proof of Theorem 2, we further observe that no component can be adjacent to all three boundary vertices. Namely, this would contradict the closeness of the parallel edges or it would contradict the members of the separator, i.e., it would imply an edge connecting distinct regions. We now consider the four possible different types of components \(c_1,c_2,c_3\) and \(c_4\) in Fig. 2(a) that can occur in a region neighboring \(w_1\). Components of type \(c_1\) are connected to (possibly many) regional vertices of the same region and may be connected to boundary vertices as well. In any valid drawing, they will end up in the same region as their regional vertices. Components of type \(c_2\) are not connected to any regional vertices and only connected to one of the three boundary vertices. Since they are not connected to regional vertices, they can not interfere with other parts of the drawing, so we can arbitrarily assign them to an adjacent region of their boundary vertex. Components that are connected to two boundary vertices appear at first to have two possible placements, e.g., as \(c_3\) or \(c_4\) in Fig. 2(a). However, \(c_4\) is not a valid placement for this type of component since it would contradict the fact that this separator arose from two close parallel edges as argued in the proof of Theorem 2. From the above discussion, we see that from a fixed configuration (i.e., set S, drawing of \(G_S\), and triple of boundary vertices), if the drawing of \(G_S\) has the shape depicted in Fig. 2(a), we can either reject the current configuration (based on having bad components), or we see that every component of \(G \setminus S\) is either attached to exactly one boundary vertex or it has a well-defined placement into the regions defined by the boundary vertices. For those components which are attached to exactly one boundary vertex, we observe that it suffices to recursively produce a drawing of that component together with its boundary vertex and to place this drawing next to the boundary vertex. For the other components, we partition them into their regions and recurse on the regions. This covers all cases for this separator shape.

The other shape of our separator can be seen in Fig. 2(b). Note that we now have two boundary vertices v and w and thus only have two regions. Again we see the two component types \(c_1\) and \(c_2\) and can handle them as above. We also have components connected to both v and w but no regional vertices. These components now truly have two different placement options \(c_3,c_4\). If we have an edge \(v_iw_i\) (as in Fig. 2(b)) of the separator that is not vw, we now observe that there cannot be more than k such components. Namely, in any drawing, for each component, there will be an edge connecting this component to either v or w which crosses \(v_iw_i\). Thus, we now enumerate all the different placements of these components as type \(c_3\) or \(c_4\) and recurse accordingly.

However, the separator may be exactly the pair (vw). Note that there are no components of type \(c_1\) and the components of type \(c_2\) can be handled as before. We will now argue that we can have at most a function of k different components of type \(c_3\) or \(c_4\) in a valid drawing. Consider the components of type \(c_3\) (the components of type \(c_4\) can be counted similarly). In a valid drawing, each type \(c_3\) component defines a sub-interval of the left region spanning from its highest to its lowest vertex such that these vertices are adjacent to one of v or w. Two such intervals relate in one of three ways: They overlap, they are disjoint, or one is contained in the other. We group components with either overlapping or disjoint intervals into layers. We depict this situation in Fig. 2(c) where, for simplicity, for every component we only draw its highest vertex and its lowest vertex and they are connected by one edge.

Let \(a_1b_1\) be the bottommost component of type \(c_3\) (i.e., \(a_1\) is the clockwise-first vertex from v in a component of type \(c_3\)). The first layer is defined as the component \(a_1b_1\) together with every component whose interval either overlaps or is disjoint from the interval of \(a_1b_1\). Now consider the green edge \(b_1w\) (see Fig. 2(c)), note we may have that this edge connects \(a_1\) to w instead. Now, for every component of this layer which is disjoint from the interval of \(a_1b_1\), this edge is crossed by at least one edge connecting it to v. Furthermore, for every component of this layer which overlaps the interval of \(a_1b_1\), there is an edge connecting \(b_1\) to either v or w which is crossed by at least one edge within that component. So in total, there can only be O(k) components in this first layer. New layers are defined by considering components whose intervals are contained in \(a_1b_1\). To limit the total number of layers, let \(a_\ell \) be the bottommost vertex of the first component of the deepest layer and consider the purple edge \(va_\ell \). This edge is crossed by some edge of every layer above it and as any edge can only have k crossings, there can only be O(k) different levels in total. This leaves us with a total of at most \(O(k^2)\) components per region and again we can enumerate their placements and recurse accordingly.

The above algorithm provides the following recurrence regarding its runtime. Namely, we let T(n) denote the runtime of our algorithm, and we can see that the following expression generously upper bounds its value. Here f(s) denotes the number of different outer k-planar drawings of a graph with s vertices.

$$ T(n) \le {\left\{ \begin{array}{ll} n^{O(k)} \cdot f(4k+3) \cdot n^3 \cdot n \cdot T(\frac{2n}{3}) &{} \text { for } n > 5k \\ f(n) &{} \text { otherwise}\\ \end{array}\right. } $$

Thus, the algorithm runs in quasi-polynomial time, i.e., \(2^{\text {poly}(\log n)}\).    \(\square \)

3 Outer k-Quasi-Planar Graphs

In this section we consider outer k-quasi-planar graphs. We first describe some classes of graphs which are outer 3-quasi-planar. We then discuss edge-maximal outer k-quasi-planar drawings.

Note, all sub-Hamiltonian planar graphs are outer 3-quasi-planar. One can also see which complete and bipartite complete graphs are outer 3-quasi-planar.

Proposition 1

The following graphs are outer 3-quasi-planar: (a) \(K_{4,4}\); (b) \(K_{5}\); (c) planar 3-tree with three complete levels; (d) square-grids of any size.

Proof

(a) and (b) are easily observed. (c) was experimentally verified by constructing a Boolean expression and using MiniSat to check it for satisfiability; see Appendix A. (d) follows from square-grids being sub-Hamiltonian.    \(\square \)

Correspondingly, we note complete and complete bipartite graphs which are not outer-quasi planar. Furthermore, not all planar graphs are outer quasi-planar, e.g., the vertex-minimal planar 3-tree in Fig. 3(a) is not outer quasi-planar, this was verified checking for satisfiability the corresponding Boolean expression; see Appendix A. A drawing of the graph in Fig. 3(b) was constructed by removing the blue vertex and drawing the remaining graph in an outer quasi-planar way.

Fig. 3.
figure 3

A vertex-minimal 23-vertex planar 3-tree which is not outer quasi-planar:(a) planar drawing; (b) deleting the blue vertex makes the drawing outer quasi-planar (Color figure online)

Proposition 2

The following graphs are not outer 3-quasi-planar: (a) \(K_{p,q}\), \(p\ge 3\), \(q \ge 5\); (b) \(K_{n}\), \(n\ge 6\); (c) planar 3-tree with four complete levels.

Together, Propositions 1 and 2 immediately yield the following.

Theorem 4

Planar graphs and outer 3-quasi-planar graphs are incomparable under containment.

Remark 1

For outer k-quasi-planar graphs (\(k > 3\)) containment questions become more intricate. Every planar graph is outer 5-quasi-planar because planar graphs have page number 4 [31]. We also know a planar graph that is not outer 3-quasi-planar. It is open whether every planar graph is outer 4-quasi-planar.

Maximal outer k-quasi-planar graphs. A drawing of an outer k-quasi-planar graph is called maximal if adding any edge to it destroys the outer k-quasi-planarity. We call an outer k-quasi-planar graph maximal if it has a maximal outer k-quasi-planar drawing. Recall that Capoyleas and Pach [9] showed the following upper bound on the edge density of outer k-quasi-planar graphs on n vertices: \( |E| \le 2(k-1)n - \left( {\begin{array}{c}2k-1\\ 2\end{array}}\right) \).

We prove (see Appendix B.2) that each maximal outer k-quasi-planar graph meets this bound. Our proof builds on the ideas of Capoyleas and Pach [9] and directly shows the result via an inductive argument. However, while preparing the camera-ready version of this paper, we learned of two other proofs of this result in the literature [13, 24]. We thank David Wood for pointing us to these results. Both papers prove a slightly stronger theorem (concerning edge flips) as their main result. Namely, for a drawing \(G=(V,E)\), an edge flip produces a new drawing \(G^*\) by replacing an edge \(e \in E\) with a new edge \(e^* \in \left( {\begin{array}{c}n\\ 2\end{array}}\right) \setminus E\). They [13, 24] show that, for every two maximal outer k-quasi-planar drawings \(G = (V,E)\) and \(G' = (V,E')\), there is a sequence of edge flips producing drawings \(G=G_1, G_2, \ldots , G_{t} = G'\) such that each \(G_i\) is a maximal k-quasi-planar drawing. Together with the tight example of Capoyleas and Pach [9], this implies the next theorem, and makes our proof fairly redundant.

Theorem 5

([13, 24]). Each maximal outer k-quasi-planar drawing \({G=(V,E)}\) has:

$$ |E| = {\left\{ \begin{array}{ll} \left( {\begin{array}{c}|V|\\ 2\end{array}}\right) &{} \text {if } |V| \le 2k-1,\\ 2(k-1)|V| - \left( {\begin{array}{c}2k-1\\ 2\end{array}}\right)&\text {if } |V| \ge 2k-1. \end{array}\right. } $$

4 Closed Convex Drawings in MSO\(_2\)

Here we express graph properties in extended monadic second-order logic (MSO\(_2\)). This subset of second-order logic is built from the following primitives.

  • variables for vertices, edges, sets of vertices, and sets of edges;

  • binary relations for: equality (\(=\)), membership in a set (\(\in \)), subset of a set (\(\subseteq \)), and edge–vertex incidence (I);

  • standard propositional logic operators: \(\lnot \), \(\wedge \), \(\vee \), \(\rightarrow \).

  • standard quantifiers (\(\forall ,\exists \)) which can be applied to all types of variables.

For a graph G and an MSO\(_2\) formula \(\phi \), we use \(G\, \models \, \phi \) to indicate that \(\phi \) can be satisfied by G in the obvious way. Properties expressed in this logic allow us to use the powerful algorithmic result of Courcelle stated next.

Theorem 6

([10, 11]). For any integer \(t \ge 0\) and any MSO\(_2\) formula \(\phi \) of length \(\ell \), an algorithm can be constructed which takes a graph G with treewidth at most t and decides in \(O(f(t,\ell )\cdot (n+m))\) time whether \(G \models \phi \) where the function f from this time bound is a computable function of t and \(\ell \).

Outer k-planar graphs are known to have treewidth O(k) (see Proposition 8.5 of [30]). So, expressing outer k-planarity by an MSO\(_2\) formula whose size is a function of k would mean that outer k-planarity could be tested in linear time. However, this task might be out of the scope of MSO\(_2\). The challenge in expressing outer k-planarity in MSO\(_2\) is that MSO\(_2\) does not allow quantification over sets of pairs of vertices which involve non-edges. Namely, it is unclear how to express a set of pairs that forms the circular order of vertices on the boundary of our convex drawing. However, if this circular order forms a Hamiltonian cycle in our graph, then we can indeed express this in MSO\(_2\). With the edge set of a Hamiltonian cycle of our graph in hand, we can then ask that this cycle was chosen in such a way that the other edges satisfy either k-planarity or k-quasi-planarity. With this motivation in mind, we define the classes closed outer k-planar and closed outer k-quasi-planar, where closed means that there is an appropriate convex drawing where the circular order forms a Hamiltonian cycle. Our main result here is stated next.

Theorem 7

Closed outer k-planarity and closed outer k-quasi-planarity can be expressed in MSO\(_2\). Thus, closed outer k-planarity can be tested in linear time.

The formulas for our graph properties are built using formulas for Hamiltonicity (Hamiltonian), partitioning of vertices into disjoint subsets (Vertex-Partition) and connected induced subgraphs on sets of vertices using only a subset of the edges (Connected). They can be found in Appendix C.

For a closed outer k-planar or closed outer k-quasi-planar graph G, we want to express that two edges e and \(e_i\) cross. To this end, we assume that there is a Hamiltonian cycle \(E^*\) of G that defines the outer face. We partition the vertices of G into three subsets C, A, and B, as follows: C is the set containing the endpoints of e, whereas A and B are connected subgraphs on the remaining vertices that use only edges of \(E^*\). In this way, we partition the vertices of G into two sets, one left and the other one right of e. For such a partition, \(e_i\) must cross e whenever \(e_i\) has one endpoint in A and one in B.

$$\begin{aligned}&\textsc {Crossing}(E^*,e,e_i)\equiv (\forall A,B,C) \big [ \big (\textsc {Vertex-Partition}(A,B,C)\\&\qquad \wedge (I(e,x) \leftrightarrow x \in C) \wedge \textsc {Connected}(A,E^*) \wedge \textsc {Connected}(B,E^*)\big )\\&\qquad \rightarrow (\exists a \in A)(\exists b \in B )[I(e_i,a) \wedge I(e_i,b)] \big ] \end{aligned}$$

Now we can describe the crossing patterns for closed outer k-planarity and closed outer k-quasi-planarity as follows:

$$\begin{aligned} \textsc {Closed Outer}\,\, k-\textsc {Planar}_G \equiv (\exists E^*)\Big [\textsc {Hamiltonian}(E^*) \wedge \end{aligned}$$
$$(\forall e) \Big [(\forall e_1,\dots ,e_{k+1}) \Big [ \Big (\bigwedge _{i=1}^{k+1} e_i \ne e \wedge \bigwedge _{i\ne j} e_i \ne e_j \Big ) \rightarrow \bigvee _{i=1}^{k+1} \lnot \textsc {Crossing}(E^*,e,e_i)\Big ] \Big ]\Big ]$$

Here we insist that G is Hamiltonian and that, for every edge e and any set of \(k+1\) distinct other edges, at least one among them does not cross e.

$$\begin{aligned} \textsc {Closed Outer}\,\, k-\textsc {Quasi-Planar}_G \equiv (\exists E^*)\Big [\textsc {Hamiltonian}(E^*)\wedge \end{aligned}$$
$$\begin{aligned} (\forall e_1,\dots ,e_k) \Big [ \Big ( \bigwedge _{i\ne j} e_i \ne e_j \Big ) \rightarrow \bigvee _{i\ne j} \lnot \textsc {Crossing}(E^*,e_i,e_j)\Big ]\Big ] \end{aligned}$$

Again, we insist that G is Hamiltonian and further that, for any set of k distinct edges, there is at least one pair among them that does not cross.

We conclude this section by mentioning an intermediate concept between closed outer k-planarity and outer k-planarity, i.e., full outer k-planarity [19]. The full outer k-planar graphs are defined as having a convex drawing which is k-planar and additionally there is no crossing on the outer boundary of the drawing. Hong and Nagamochi [19] gave a linear-time recognition algorithm for full outer 2-planar graphs. Clearly, the closed 2-planar graphs are a subclass of the full 2-planar graphs. So, one open question is whether one can generalize our MSO\(_2\) expressions of closed outer k-planarity and closed outer k-quasi-planarity to the full versions. If yes, this would provide linear-time recognition of full outer k-planar graphs for every k, including the full outer 2-planar case.