1 Introduction

A simple drawing of a graph G (also known as good drawing or as simple topological graph in the literature) is a drawing D(G) of G in the plane such that every pair of edges shares at most one point that is either a proper crossing or a common endpoint. In particular, no tangencies between edges are allowed and edges must not contain any vertices in their relative interior. It is commonly assumed that no three edges intersect in the same point; the results in this paper are independent of this assumption. Simple drawings have received a great deal of attention in various areas of graph drawing, for example in connection with two long-standing open problems: the crossing number of the complete graph [37] and Conway’s thrackle conjecture [7].

In this work, we study the problem of inserting an edge into a simple drawing of a graph. Given a simple drawing D(G) of a graph \(G=(V,E)\) and an edge e of the complement \(\overline{G}\) of G we say that e can be inserted into D(G) if there exists a simple drawing of \(G' = (V,E\cup \{e\})\) that contains D(G) as a subdrawing.

A pseudoline arrangement is an arrangement of simple biinfinite arcs, called pseudolines, such that every pair of pseudolines intersects in a single point that is a proper crossing. Similarly, an arrangement of pseudocircles is an arrangement of simple closed curves, called pseudocircles, such that every pair of pseudocircles intersects in either zero or two points, where in the latter case, both intersection points are proper crossings. A simple drawing D(G) is called pseudolinear if the drawing of every edge can be extended to a pseudoline such that the extended drawing forms a pseudoline arrangement. Recently, Arroyo et al. showed that one can fully characterize these drawings by forbidden subdrawings and recognize them in polynomial time [3]. Likewise, D(G) is called pseudocircular if the drawing of every edge can be extended to a pseudocircle such that the extended drawing forms an arrangement of pseudocircles.

Pseudoline arrangements were introduced by Levi [32] in 1926 and have since been extensively studied; see for example [21]. One of the most fundamental results on pseudoline arrangements, nowadays well known as Levi’s Enlargement Lemma, stems from Levi’s original paper.Footnote 1 It states that, for any given pseudoline arrangement \(\mathcal L\) and any two points p and q not on the same pseudoline of \(\mathcal L\), it is always possible to insert a pseudoline through p and q into \(\mathcal L\) such that the resulting arrangement is again a valid pseudoline arrangement.

From Levi’s Enlargement Lemma, it immediately follows that given any pseudolinear drawing D(G) and any set \(E^*\) of edges from \(\overline{G}\), it is always possible to insert all edges from \(E^*\) into D(G) such that the resulting drawing is again pseudolinear. In contrast, if the input drawing D(G) is simple, Kynčl [30] showed that not every edge of \(\overline{G}\) can be added to D(G) such that the result is again a simple drawing, not even if G is a matching plus two isolated vertices which are the endpoints of the edge to be inserted [31]. The latter implies that an analogous statement to Levi’s Enlargement Lemma is not true for arrangements of pseudosegments (simple arcs that pairwise intersect at most once). Moreover, Arroyo et al. [4] showed that given a simple drawing D(G) and a set \(E^*\) of edges from \(\overline{G}\), it is NP-complete to decide whether \(E^*\) can be inserted into D(G) (such that the resulting drawing is again simple). However, the cardinality of \(E^*\) required for their hardness proof is linear in the size of the constructed graph. The main open problem posed in [4] is the complexity of deciding whether one single given edge e of \(\overline{G}\) can be inserted into D(G).

In this work, we show that this decision problem is NP-complete, even if G is a matching plus two isolated vertices which are the endpoints of e. This implies that, given an arrangement \(\mathcal S\) of pseudosegments and two points p and q not on the same pseudosegment, it is NP-complete to decide whether it is possible to insert a pseudosegment from p to q into \(\mathcal S\) such that the resulting arrangement is again a valid arrangement of pseudosegments (Sect. 2). On the positive side, we observe that the decision problem is fixed-parameter tractable (FPT) in the number of crossings of the original drawing G (Sect. 5). This algorithm cannot be directly adapted to obtain an FPT-algorithm only with respect to the number of newly created crossings. Very recently, an overlapping set of authors showed an FPT-algorithm for this problem that is tight under the Exponential Time Hypothesis [22]. Using a different approach that requires invoking Courcelle’s theorem [16], the authors present an FPT-algorithm for inserting a bounded number of edges with a bounded number of new crossings into a simple drawing G.

Snoeyink and Hershberger [39] showed the following analog to Levi’s Enlargement Lemma for arrangements of pseudocircles: For any arrangement \(\mathcal{A}\) of pseudocircles and any three points p, q, and r, not all of them on one pseudocircle of \(\mathcal{A}\), there exists a pseudocircle \(\Phi \) through p, q, and r such that \(\mathcal{A}\cup \{\Phi \}\) is again an arrangement of pseudocircles. Refining our hardness proof, we show that the edge-insertion decision problem remains NP-complete when D(G) is a pseudocircular drawing, regardless of whether the resulting drawing is required to be again pseudocircular or allowed to be any simple drawing. This holds even if we are in addition given an arrangement of pseudocircles extending D(G). On the positive side, we show that, given an arrangement \(\mathcal{A}\) of pseudocircles and a pseudosegment \(\sigma \), it can be decided in polynomial time whether there exists an extension \(\Phi _\sigma \) of \(\sigma \) to a simple closed curve such that \(\mathcal{A} \cup \{\Phi _\sigma \}\) is again an arrangement of pseudocircles (Sect. 4).

1.1 More Related Work

One of the implications of the results presented in this paper concerns so-called saturated drawings [31]. A simple drawing D(G) of a graph G is called saturated if no edge e from \(\overline{G}\) can be inserted into D(G). Kynčl et al. showed that there are saturated simple drawings whose number of edges is only linear in the number of vertices [31]. The currently best upper bound on the minimum number of edges in saturated simple drawings is 7n and has been shown by Hajnal et al. [25]. A natural question is to determine the complexity of deciding whether a simple drawing is saturated. Our hardness result implies that the straight-forward idea of testing whether D(G) is saturated by checking for every edge in \(\overline{G}\) whether it can be inserted into D(G) is not feasible unless \(\texttt {P} = \texttt {NP}\).

The problem of inserting an edge (or multiple edges or a star) into a planar graph has been extensively studied in the contexts of determining the crossing number of the resulting graph [9, 36] and of finding a drawing of the resulting graph in which the original planar graph is drawn crossing-free and the drawing of the resulting graph has as few crossings as possible [14, 15, 24, 35]. In relation to our work, a main difference is that we consider inserting edges into some given non-plane drawing of a graph.

Furthermore, the question considered in this paper is strongly related to work on extending partial representations of graphs. Here, we are usually given a representation of a part of the graph G and are asked to extend it into a full representation of G such that the partial representation is a sub-representation of the full one. Recent years have seen a plethora of results in this topic. For plane drawings Angelini et al. [1] showed that the problem can be solved in linear time, while Patrignani already proved earlier that the problem is NP-complete for plane straight-line drawings [34]. For level and upward planar graph drawings the problem was shown to be NP-complete [8, 17]. However, under certain restrictions on the graph and the drawing, the extension problems become tractable [8, 10, 17, 33]. Very recently, also orthogonal drawings have been considered [2]. Extension of other graph representations have been studied for several graph classes defined by intersection or visibility of geometric objects [11,12,13, 26,27,28,29]. Very recently, the extension problem was also considered for 1-plane drawings through the lens of parameterized complexity [19, 20].

A similar extension problem was studied when the graph class considered are trees. Here, we are also given a point-set P and ask if the given drawing can be extended using only points in P for vertex positions. Di Giacomo et al. [18] showed that this problem is polynomial time solvable if bends are allowed. Similarly to the case of planar graphs, Bagheri and Razzazi [6] showed that the problem is NP-complete when we require the extended drawings to be straight-line.

1.2 Outline

The remainder of our paper is organized as follows. In Sect. 2 we prove that, given a simple drawing D(G) of a graph G, it is NP-complete to decide whether a given edge e of \( \overline{G} \) can be inserted into D(G) . Furthermore, we discuss under which conditions the statement holds. Most notably, in Sect. 3, we show that the problem remains NP-hard even if the input drawing is pseudocircular. In contrast, we show in Sect. 4 that for a given arrangement \(\mathcal{A}\) of pseudocircles and a pseudosegment \(\sigma \), we can decide in polynomial time whether \( \sigma \) can be extended to simple closed curve \(\Phi _\sigma \) such that \(\mathcal{A} \cup \{\Phi _\sigma \}\) is again an arrangement of pseudocircles. Finally, in Sect. 5, we observe that the problem of deciding whether a given edge e of \( \overline{G} \) can be inserted into a simple drawing D(G) of a graph G is FPT in the number of crossings of D(G) .

2 Inserting One Edge into a Simple Drawing is Hard

In this section we prove the following theorem containing our main result:

Theorem 2.1

Given a simple drawing D(G) of a graph \( G = (V,E) \) and an edge uv of \(\overline{G}\), it is NP-complete to decide whether uv can be inserted into D(G) , even if \( V \setminus \{u,v\} \) induces a matching in G and u and v are isolated vertices.

It is straightforward to verify that the problem is in NP (see Arroyo et al. [4] for a combinatorial description of our problem using the dual of the planarization of the drawing). We show NP-hardness via a reduction from 3SAT. Let be a 3SAT-formula with variables \(x_1,\dots ,x_n\) and set of clauses \(\mathcal C=\{C_1,\dots ,C_m\}\). An occurrence of a variable \(x_i\) in a clause \(C_j\in {\mathcal {C}}\) is called a literal. For convenience, we assume that in , each clause has three (not necessarily different) literals. In a preprocessing step, we eliminate clauses with only positive or only negative literals via the transformation from Lemma 2.2.

Lemma 2.2

The following transformation of a clause with only positive or only negative literals, respectively, preserves the satisfiability of the clause (y is a new variable and \(\mathtt {false}\) is the constant value false):

Proof

We prove the statement for the case in which the original clause has three positive literals; the other case is analogous. Assume that \(x_i\) or \(x_j\) satisfies the original clause. Then it also satisfies clause (ii) and y can be set to \(\texttt {true}\) to satisfy clause (i). If \(x_k\) satisfies the original clause, then it also satisfies clause (i) and y can be set to \(\texttt {false}\) to satisfy clause (ii). If none of \(x_i\), \(x_j\), and \(x_k\) satisfy the original clause, then to satisfy clause (ii) we have to set y to \( \texttt {false} \), which implies that clause (i) is not satisfied. \(\square \)

After the preprocessing, we have a transformed 3SAT-formula where each clause is of one of the following four types. Type (i): two positive literals and one constant \(\texttt {false}\); type (ii): one negative and two positive literals; type (iii): one positive and two negative literals; and finally, type (iv): two negative literals and one constant \(\texttt {false}\).

Given a transformed 3SAT-formula with set of clauses \( \mathcal C = \{C_1, \ldots , C_m\} \), satisfiability of \(\phi \) will correspond to being able to insert a given edge uv into a simple drawing D of a matching constructed from the formula \(\phi \). The main idea of the reduction is that the variable and clause gadgets in D act as “barriers” inside a simple closed region R of D, in which we need to insert a simple arc \(\gamma \) from one side to the other to connect u and v. Crossing a barrier in some way imposes constraints on how or whether we can cross other barriers afterwards.

To simplify the description, we first focus our attention to the inside of the simple closed region R. We assume that \(\gamma \) cannot cross the boundary of R. In the following we use two lines, named \(\lambda \) and \(\mu \), to bound the regions in which a variable and clause gadget will be placed. Particularly, these lines will be identified with opposite segments on R’s boundary.

2.1 Variable Gadget

A variable gadget W is bounded from the left by a vertical line \( \lambda \) and from right by a vertical line \(\mu \). Additionally, it contains a horizontal segment \(\kappa \) between \(\lambda \) and \(\mu \), a set P of pairwise non-crossing arcs (parts of later-defined edges), each with one endpoint on \(\kappa \) and the other endpoint on \(\mu \), and a set N of pairwise non-crossing arcs, each with one endpoint on \(\kappa \) and the other endpoint on \(\lambda \). On \(\kappa \), all the endpoints of arcs in P lie above all the endpoints of arcs in N, implying that every arc in P crosses every arc in N. Finally, we choose two points u and v such that u is below all arcs in W and v is above them; see Fig. 1 for an illustration. The arcs in P and N correspond to positive and negative appearances of the variable, respectively.

Fig. 1
figure 1

Variable gadget. Orange arcs belong to N, green ones to P

Fig. 2
figure 2

Clause gadget

Lemma 2.3

Let W be a variable gadget. Any arc between the vertical lines \(\lambda \) and \(\mu \) that connects u and v crosses all arcs in P or all arcs in N.

Proof

Assume that there is an arc connecting u and v neither crossing all the arcs in P nor all the arcs in N. Hence, there are two arcs \(p\in P\) and \( n \in N \) such that this arc neither crosses p nor n. By the construction of the gadget, p and n cross. Thus, their union together with \( \lambda \) and \( \mu \) separates u from v. It follows that the arc has to cross p or n. \(\square \)

2.2 Clause Gadget

Similar to a variable gadget, a clause gadget K is bounded from the left and right by two vertical lines \(\lambda \) and \(\mu \), respectively. Additionally, it contains three horizontal arcs (parts of later-defined edges) \(\gamma _a\), \(\gamma _b\), and \( \gamma _c \), where the former two have one endpoint on \(\lambda \) and the latter has one endpoint on \(\mu \). On \(\lambda \), the endpoint of \(\gamma _a\) lies to the right of the one of \( \gamma _b \). The other endpoints of \( \gamma _a \), \( \gamma _b \), and \( \gamma _c \) are called a, b, and c, respectively. None of these three arcs cross. Moreover, K contains two points d and g and an edge dg that crosses \(\gamma _a\), \(\gamma _c\), and \(\gamma _b\) in that order when traversed from d to g. Notice that we do not require any specific rotation of the crossings of dg with \(\gamma _a\) and \(\gamma _b \) (where the rotation is the clockwise order of the endpoints of the crossing arcs). However, to simplify the description, we assume that the rotations of the crossings are as in Fig. 2. The rotation of the crossing of dg with \( \gamma _c \) is forced by the order of the crossings along dg. Finally, we again choose two points u and v such that u is below all arcs in K and v is above them; see Fig. 2 for an illustration.

Lemma 2.4

Let K be a clause gadget. Any arc uv between the vertical lines \( \lambda \) and \( \mu \) that connects u and v crosses either dg twice or at least one of the arcs \( \gamma _a \), \( \gamma _b \), and \( \gamma _c \).

Proof

Let \({\times }\) be the crossing point of \(\gamma _c\) and dg. This point splits the arc dg into two arcs \(d{\times }\) and \(g{\times }\). Assume that the arc uv does not cross the arcs \(\gamma _a\), \(\gamma _b\), and \(\gamma _c\). The union of \(\gamma _a\) and \(\gamma _c\) together with \(d{\times }\) and the lines \(\lambda \) and \(\mu \) separates u from v. Since the arcs \(\gamma _a\) and \(\gamma _c\) are not crossed by uv, uv must cross \(d{\times }\) in a point \({\times }'\). Analogously, the union of \(\gamma _b,\gamma _c\), together with \(g{\times }\) and the lines \(\lambda \) and \(\mu \) separates u from v. Thus, uv has to cross \(g\times \) in a point \({\times }''\ne {\times }'\) to avoid tangencies. This implies that uv crosses dg twice, a contradiction. \(\square \)

2.3 The Reduction

Let be a transformed 3SAT-formula with clause set \( {\mathcal {C}} = \{C_1, \ldots , C_m\} \) (each clause being of one of the four types identified above). To build our reduction we need one more gadget. First, we introduce the following simple drawing introduced by Kynčl et al. [31,  Fig. 11] and depicted in Fig. 3. Here, we denote this drawing by \(\circledcirc \). Following the notation by Kynčl et al., we denote its six arcs by \(a_1\), \(a_2\), \(a_3\), \(b_1\), \(b_2\), and \(b_3\); and its eight cells by X, \( A_1 \), \( A_2 \), \( A_3 \), \( B_1 \), \( B_2 \), \( B_3 \), and Y; see Fig. 3 for an illustration. The core property \( {\mathcal {P}} \) of \(\circledcirc \) is that it is not possible to insert an edge between a point in cell X and another point in cell Y such that the result is a simple drawing [31,  Lem. 15].

Fig. 3
figure 3

The simple drawing \(\circledcirc \) presented in [31]. It is not possible to insert an edge between a point in X and one in Y

For our reduction, we first choose two arbitrary points u and v in the cells X and \( B_2 \) and insert them as vertices into \(\circledcirc \). Let be the obtained drawing. Further, let \( b_2^* \) be the part of the arc \( b_2 \) between the crossing point of \( b_2 \) and \( a_2 \) and the crossing point of \( b_2 \) and \( b_3 \), see again Fig. 3.

Fig. 4
figure 4

A schematic overview of the edges in F (red and orange) and how they are combined with \(\circledcirc \)

Lemma 2.5

The edge uv cannot be inserted into without crossing \(b_2^* \).

Proof

Assume for contradiction that uv can be inserted not crossing \( b_2^* \) and let \(\gamma _{uv}\) be such an arc. Refer to Fig. 3. If \(\gamma _{uv}\) does not cross \(b_2\), then we would be able to prolong it and cross \(b_2\) to reach Y, a contradiction of property \(\mathcal {P}\). Thus, \(\gamma _{uv}\) crosses \(b_2\). Further, we may assume without loss of generality that \(\gamma _{uv}\) does not cross \(b_2\) inside \(A_2\) or \(B_1\), as otherwise it would be possible to modify \(\gamma _{uv}\) to not cross \(b_2\). Thus, \(\gamma _{uv}\) intersects \(b_2\) on the boundary of \(B_2\). Since \(\gamma _{uv}\) cannot intersect Y, this crossing must be on \(b_2^*\). \(\square \)

The final piece we need for our reduction is a set F of \( m^{I } + m^{IV } + 4 \) arcs that we insert into , where \( m^{I } \) is the number of clauses of type (i) and \(m^{IV }\) the number of clauses of type (iv). For an arc \( f \in F \) we will place one of its endpoints on a vertical line \( \kappa _F \) inside \(A_2\) and the other one inside \(B_2\); see Fig. 4 for an illustration. The only crossings of f with are with the arcs \(a_2\), \(a_1\), \(b_3\), and \(b_2\), in that order, when traversing f from its endpoint on \(\kappa _F\) to its endpoint in \( B_2 \). Furthermore, when f is traversed in that direction, it crosses from \(A_2\) to \(A_1\), from \(A_1\) to \(B_3\), from \(B_3\) to Y, and from Y to \( B_2 \).

Consider the \( m^{I } + m^{IV } + 4 \) endpoints on \( \kappa _F \) sorted from top to bottom. We denote by \(f_j\) the arc in F incident with the j-th such endpoint. When traversing \( b_2 \) from its endpoint in \( A_2 \) to its endpoint in \( B_1 \), the crossings of arcs in F with \( b_2 \) appear in the same order as their endpoints on \( \kappa _F \). More precisely, the crossings of \( b_2 \), when \(b_2\) is traversed in that direction, are with \(a_2\), \(a_1\), \(b_3\), \(f_1\), \(f_2\), ..., \( f_{|F|}\), and \(b_1\), in that order.

The arcs \(f_{m^{I } + 1}\), \(f_{m^{I } + 2}\), \(f_{m^{I } + 3}\), and \(f_{m^{I } + 4}\) will behave differently than the other arcs in F. In the following, we denote these four arcs by \(r_2\), \(r_1\), \(\ell _1\), and \(\ell _2\), respectively. There are only two crossings between arcs in F, namely, between \(r_1\) and \(r_2\), and between \(\ell _1\) and \(\ell _2\), and both these crossings are inside \(B_2\). These four crossing arcs divide \(B_2\) into three regions. Let R denote the region with \(b_2^*\) on its boundary; let \(R_r\) denote the (other) region incident with the crossing between \(r_1\) and \(r_2\); and let \(R_\ell \) denote the (other) region incident with the crossing between \(\ell _1\) and \(\ell _2\). Arcs \(r_1\), \(r_2\), \(\ell _1\), and \(\ell _2\) must be drawn such that the vertex v lies in R; see the red arcs in Fig. 4 for an illustration. The precise endpoints of the edges in \( F \setminus \{r_1,r_2,\ell _1,\ell _2\} \) will be fixed when we insert the clause gadgets.

Lemma 2.6

The edge uv cannot be inserted into without crossing every arc in F in \( A_1\) or \(B_3 \) (in the interior or common boundary of these cells).

Proof

Assume for contradiction that there is an arc \( f \in F \) such that uv does not cross f. From Lemma 2.5 we know that uv has to cross \( b_2^* \). Consider the region bounded by \( b_2^* \), \( b_3 \), f, and \( a_2 \). Observe that, since \( b_2^* \) is fully contained on the boundary of this region, uv has to cross at least one of the three other arcs as well. By assumption, uv does not cross f. Crossing \( b_3 \) is impossible by property \(\mathcal {P}\), as the part contained on this region’s boundary separates \( B_3 \) from Y. Finally, crossing the arc which is part of \( a_2 \) is not possible, since this would imply the existence of a point \( v' \) in \( A_2 \) such that uv passes through \( v' \) without having crossed \( a_2 \). Hence, we could prolong the arc \( uv' \) that is part of uv by crossing \( a_2 \) such that it reaches \( B_2 \) without crossing \( b_2^* \), a contradiction to Lemma 2.5. Thus, the statement follows. \(\square \)

Fig. 5
figure 5

Illustration of the reduction

It remains to insert inside R the clause and variable gadgets and precisely define the endpoints of arcs in \(F\setminus \{\ell _1,\ell _2,r_1,r_2\}\). For simplicity, we first insert the variable gadgets and then the clause gadgets. The idea is that each clause and variable gadget is inserted in R separating \( b_2^* \) from v. This is done by identifying the endpoints that were lying on \( \lambda \) or \( \mu \) with points on \( \ell _1 \), \( \ell _2 \), \( r_1 \), \( r_2 \), or \(b_2\). As a result, Lemmas 2.3 and 2.4 can be applied to the arc that we insert connecting u and v in the final drawing, since it has to cross \( b_2^* \) by Lemma 2.5.

We now insert the variable gadgets into R. Let \( W^{(i)} \) be the variable gadget corresponding to variable \(x_i\). For a gadget \( W^{(i)} \), the arcs in N are drawn such that the endpoints on \( \lambda \) lie on the part of \( \ell _1 \) that bounds R. The arcs in P are drawn similarly, but with the endpoints on \( \mu \) lying on the part of \( r_1 \) that bounds R. Moreover, we identify vertex v in the gadget with vertex v in . Gadgets corresponding to different variables are inserted without crossing each other. We now specify how they are inserted relative to each other. As we traverse \(\ell _1\) from its endpoint on \(\kappa _F\) to its endpoint in R, we encounter the endpoints of arcs in \( W^{(i)} \) before the endpoints of arcs in \( W^{(i+1)} \). Analogously, as we traverse \(r_1\) from its endpoint on \(\kappa _F\) to its endpoint in R, we encounter the endpoints of arcs in \( W^{(i)} \) before the endpoints of arcs in \( W^{(i+1)} \). See Fig. 5 for an illustration.

In a similar way we insert the clause gadgets. Let \( K^{(j)} \) be the clause gadget corresponding to clause \(C_j\). If \(C_j\) is of type (i), \(K^{(j)}\) is inserted such that the endpoints on \(\lambda \) lie on the part of \( \ell _2\) that bounds R. If \(C_j\) is the \(j'\)-th clause of type (i), we identify c with the endpoint of the arc \(f_{j'}\). Similarly, if \(C_j\) is of type (iv), \(K^{(j)}\) is inserted such that the endpoints on \(\lambda \) lie on the part of \(r_2\) that bounds R. If \(C_j\) is the \(j'\)-th clause of type (iv), we identify c with the endpoint of the arc \(f_{m^{I }+4+ j'}\). If \(C_j\) is of type (ii), \( K^{(j)} \) is inserted such that the endpoints on \(\lambda \) lie on the part of \( \ell _2\) that bounds R and the endpoint on \(\mu \) lies on the part of \( r_2\) that bounds R. Similarly, if \(C_j\) is of type (iii), \( K^{(j)} \) is inserted such that the endpoint on \(\mu \) lies on the part of \(\ell _2\) that bounds R and the endpoints on \(\lambda \) lie on the part of \( r_2\) that bounds R. The crossings in R of arcs from different clause gadgets are of arcs with an endpoint in \(r_2\) with arcs in \(\{f_j:1\le j \le m^{I }\}\).

We now specify how different clause gadgets are inserted relative to each other. As we traverse \(\ell _2\) from its endpoint on \(\kappa _F\) to its endpoint in R, we first encounter the endpoints of arcs corresponding to type (iii) clauses, followed by the ones corresponding to type (ii) clauses, and finally the ones corresponding to type (i) clauses. Analogously, as we traverse \(r_2\) from its endpoint on \(\kappa _F\) to its endpoint in R, we first encounter the endpoints of arcs corresponding to type (iv) clauses, followed by the ones corresponding to type (iii) clauses, and finally the ones corresponding to type (ii) clauses. Moreover, as we traverse \(\ell _2\) and \(r_2\) in the specified directions, the endpoints of arcs corresponding to the \(j'\)-th clause of a certain type are encountered before the endpoints of arcs corresponding to the \((j'-1)\)-st clause of this type. An illustration can be found in Fig. 5.

Finally, we connect arcs from variable and clause gadgets inside the regions \( R_\ell \) and \( R_r \). This is done such that if a literal in a clause is \(x_k\) then the corresponding arc in the clause gadget, that has an endpoint on \(\ell _2\), is connected with an arc in N of the gadget \(W^{(k)}\), that has an endpoint on \(\ell _1\). Thus, these connections can lie in \(R_\ell \). Analogously, if a literal in a clause is \(\lnot x_k\) then the corresponding arc in the clause gadget, that has an endpoint on \(r_2\), is connected with an arc in P of the gadget \(W^{(k)}\), that has an endpoint on \(r_1\). Thus, these connections can lie in \(R_r\). Since, without loss of generality, we can assume that \(R_\ell \) and \(R_r\) are convex regions and the endpoints we want to connect are pairwise distinct points on the boundaries of those regions, the connections can be drawn as straight-line segments. (For visual clarity in Fig. 5 and to argue pseudocircularity in Sect. 3, we draw these connections with one bend per arc.) Therefore, there is at most one crossing between each pair of connecting arcs.

Each connecting arc is concatenated with the arcs in a variable and in a clause gadget that it joins. These concatenated arcs are edges in our drawing that have one endpoint in a variable gadget and the other one in a clause gadget. By construction, each such edge corresponds to a literal in the formula \(\phi \) and each pair of them crosses at most once. Similarly, the arcs in \(F\setminus \{\ell _1, \ell _2, r_1, r_2\}\) have one endpoint in a clause gadget and also define edges in our final drawing that we denote by the same names as the corresponding arcs.

We now have all the pieces that constitute our final drawing. It consists of (i) the simple drawing ; (ii) the edges \(f_i\in F\) drawn as the described arcs (with their endpoints as vertices); (iii) the edges corresponding to literals (with their endpoints as vertices); and (iv) the edges dg in each clause gadget (with d and g as vertices). Observe that the constructed drawing is a simple drawing, as it is the drawing of a matching (plus the vertices u and v) and, by construction, any two edges cross at most once.

It remains to show that the presented construction is a valid reduction.

Lemma 2.7

The above construction is a polynomial time reduction from 3SAT to the problem of deciding whether an edge can be inserted into a simple drawing.

Proof

Given a 3SAT formula with clauses \( C_1, \ldots , C_m \) we construct a simple drawing D as described in Sect. 2 and aim to insert the edge uv into it. This construction can clearly be computed in polynomial time and space, since only the combinatorial description of the drawing is needed.

Assume uv can be inserted into D and let uv be the resulting arc. By Lemmas 2.5 and 2.6 we know that uv has to cross \( b_2^* \) and every arc in F. Let \( u^*\) be the point where uv crosses \( b_2^* \). Each clause and variable gadget separates \(u^*\) from v and thus, Lemmas 2.3 and 2.4 can be applied. This means that in a variable gadget \( W^{(i)} \) all arcs in P or all arcs in N are crossed. In the former case we assign to variable \(x_i\) the value true, and otherwise the value false. Assume that this truth assignment does not satisfy . Then there exists a clause \( C_j \) for which all three literals evaluate to \( \texttt {false} \). Consider the clause gadget \(K^{(j)}\). By Lemma 2.4 we must cross in it an edge corresponding to one of its literals. However, by Lemma 2.6 an edge corresponding to the constant value \(\texttt {false} \) cannot be crossed (again) in a clause gadget. By construction and the truth assignment of the variables, the edges corresponding to the other literals of \( C_j \) cannot be crossed either.

Conversely, assume we are given a satisfying assignment of . We then can insert uv into D as follows. Starting from u, edge uv crosses \(a_1\) to enter region \(A_1\), then crosses all arcs in F, and crosses \(b_2^*\) to enter R; see also the dotted line in Fig. 5. In each clause gadget, edge uv crosses one edge corresponding to a literal evaluating to true, none corresponding to a literal evaluating to false, and the edge dg in the gadget if necessary. By construction, this leaves in each variable gadget all arcs either in P or in N free to be crossed by uv. Moreover, this allows us to connect u and v without crossing any edge twice. \(\square \)

As our reduction from 3SAT constructs a simple drawing D(G) of a matching, the general problem is NP-hard even if G is as sparse as possible. We remark that if we do not require G to be a matching, our variable gadget can be simplified by identifying all the vertices on \(\kappa \) and removing the crossings between edges in N and P. Moreover, from the constructed drawing D(G), one can produce an equivalent instance that is connected: This is done by inserting an apex vertex into an arbitrary cell of the drawing, and then subdividing its incident edges so that the resulting drawing \(D^*\) is simple. If uv can be inserted into D(G) then it can be inserted also into \(D^*\). Finally, in the next section we show that the problem remains hard even when the input drawing D(G) is a pseudocircular drawing and we are in addition given an arrangement of pseudocircles extending D(G), regardless of whether the resulting drawing is required to be again pseudocircular or allowed be any simple drawing.

3 Inserting One Edge into a Pseudocircular Drawing is Still Hard

In this section, we show that the simple drawings produced by our reduction are actually pseudocircular. Hence we obtain the following corollary.

Corollary 3.1

Given a pseudocircular drawing D(G) of a graph \( G = (V,E) \) and an edge uv of \(\overline{G}\), it is NP-complete to decide whether uv can be inserted into D(G) , even if an arrangement of pseudocircles extending the drawing of the edges in D(G) is provided.

Proof

Let D be a drawing produced by our reduction from 3SAT. We divide the edges that correspond to literals of the input 3SAT-formula into the blue edges and the purple edges. The former correspond to positive literals and the latter to negative ones. Furthermore, we call the edges corresponding to constant false values the orange edges and the four edges \( r_1 \), \( r_2 \), \( \ell _1 \), and \( \ell _2 \) the red edges. For each clause gadget we find one edge that is not corresponding to a literal or constant false value; we call all these edges the black edges. Finally, we call the edges in the subdrawing \(\circledcirc \) in D the green edges.

To complete D into an arrangement of pseudocircles we have to close every blue, purple, black, orange, red, and green edge by a corresponding extension. For the six green edges this can be done as shown in Fig. 6a. The orange and red edges are partitioned into two groups. The first one contains \(r_1\), \(r_2\) and the orange edges corresponding to false values in clauses of type (i). The second one contains \(\ell _1,\ell _2\), and the orange edges corresponding to false values in clauses of type (iv). Inside the region R, for both groups the red and the orange extensions are drawn as parallel, pairwise non-intersecting curves between their endpoints in R and the boundary of the region \(A_2\); see Fig. 6b. Additionally, also inside R, for each group the extensions of the two red edges cross all the orange edges in the group. Moreover, the clause gadgets are essentially placed between the red extensions. Inside the region \( A_2 \), for each group the extensions of the two red edges cross and the orange extensions cross the red ones; see again Fig. 6b.

Fig. 6
figure 6

Extending the gadgets that form the frame of our reduction to an arrangement of pseudocircles

We close the black edges with black extensions by just connecting the endpoints of a black edge without producing any additional crossings with the edges of D, or with the extensions defined so far. It remains to extend the purple and the blue edges. An example of a fully extended drawing D can be seen in Fig. 7. The purple and blue extensions are essentially horizontally mirrored copies of their corresponding edges. In particular, two purple or blue extensions cross if and only if the corresponding purple or blue edges cross. Moreover, inside the region R, the purple and the blue extensions are drawn without crossings. As we traverse \(\ell _1\) from its endpoint in \(A_2\) to its endpoint in R, we encounter the (crossing points of) purple extensions of arcs in \( W^{(i)} \) after the blue arcs in \( W^{(i-1)} \) and before the blue arcs in \( W^{(i)}\). Analogously, as we traverse \(r_1\) from its endpoint in \(A_2\) to its endpoint in R, we encounter the (crossing points of) blue extensions of arcs in \( W^{(i)} \) after the purple arcs in \(W^{(i-1)}\) and before the purple arcs in \(W^{(i)}\). Furthermore, as we traverse \(\ell _2\) from its endpoint in \(A_2\) to its endpoint in R, we encounter the (crossing points of) purple extensions before the blue arcs. Similarly, as we traverse \(r_2\) from its endpoint in \(A_2\) to its endpoint in R, we encounter the (crossing points of) blue extensions before the purple arcs.

Let \(D^\circ \) be the arrangement of closed curves constructed from D. It remains to prove that \( D^\circ \) is an arrangement of pseudocircles. We consider the pseudocircles in \( D^\circ \) to have the same color as the edges and extensions that define them. We first show that we can deform the purple, blue, black, red, and orange pseudocircles in \( D^\circ \) such that they are all axis-aligned rectangles and the pairwise intersections are preserved. Then, to show that two of these rectangles cross at most twice we make use of the next observation:

Observation 3.2

Let \(\square _1\) and \(\square _2\) be two axis-aligned rectangles whose vertices lie in general position (no three are collinear). If the leftmost and rightmost points of the projection of \(\square _1 \cup \square _2\) into the horizontal (or vertical) axis correspond to different rectangles, then \(\square _1\) and \(\square _2\) cross in at most two points.

Fig. 7
figure 7

The drawing produced by our reduction is pseudocircular

We will show that all pseudocircles in \( D^\circ \) except the green ones can be deformed to axis-aligned rectangles while maintaining their intersections with other pseudocircles. We refer to Fig. 7.

By construction, the red and orange pseudocircles extending the edges in the group of red and orange ones that contains \( r_1 \) and \(r_2\) can be drawn directly as axis-aligned rectangles. See the the red and orange pseudocircles on the right side of Fig. 7. We deform (the bottom part of) the other orange and red pseudocircles such that the resulting pseudocircles are axis-aligned rectangles. This can easily be done by also deforming part of the subdrawing of \( D^\circ \).

The purple pseudocircles can be drawn directly as axis-aligned rectangles. A black pseudocircle \(\Phi \) extending a black edge e can trivially be drawn as an axis-aligned rectangle such that \(\Phi \) only crosses pseudocircles extending edges that cross e.

We now deform the blue pseudocircles. The blue extensions as described above can be drawn such that the resulting blue pseudocircles are axis-aligned polygons with one reflex corner (between \(\ell _1\) and \(r_1\)). For a blue pseudocircle \(\Phi \) drawn in this way, let the corner point be the reflex vertex of the polygon and let the horizontal and vertical sides incident with it be the horizontal corner-arc and the vertical corner-arc of \(\Phi \), respectively. To make a blue pseudocircle an axis-aligned rectangle, we deform it by moving its corner point; see Fig. 8. Obviously, this does not change the crossings with any green, black, red, or orange pseudocircle. Furthermore, it does not change the crossings with other blue pseudocircles as no new crossings are introduced and the crossings along the horizontal corner-arc are preserved. Finally, in the same way, this deformation preserves the crossings between the blue pseudocircle and purple ones along the vertical corner-arc.

Fig. 8
figure 8

Interactions between the blue and the purple pseudocircles

Consider the deformed drawing obtained from \( D^\circ \) maintaining all intersections. We now argue that each two pseudocircles cross either zero or two times in this deformed drawing and hence in \(D^\circ \). To show that no two blue (or no two purple) rectangles cross more than twice we consider their projection onto the vertical axis. Then, by construction, two rectangles cross if and only if the topmost and the bottommost points of the projection correspond to different rectangles; see Fig. 8a. Thus, by Observation 3.2, in case the two rectangles cross they cross twice. For a blue and a purple pseudocircle we find that their projection to the horizontal axis is always such that the left-most point belongs to the purple extension and the right-most point to the blue extension by construction; see Fig. 8b for an illustration. From Observation 3.2 it follows that each pair of blue and purple rectangles crosses at most twice.

In the same manner we can argue about the red and orange rectangles. By construction, two orange rectangles do not cross. A red and an orange rectangle are either disjoint (if they extend edges in different groups of red and orange ones) or the leftmost and rightmost points of their projection onto the horizontal axis correspond to different rectangles. Thus, from Observation 3.2 it follows that each pair of red and orange rectangles crosses at most twice. Similarly, given a red or orange rectangle and a purple or blue one, the leftmost and rightmost points of their projection onto the horizontal axis correspond to different rectangles. Thus, by Observation 3.2, they cross at most twice.

Given two rectangles, one of them black, their projection onto the horizontal or the vertical axis shows that either they do not cross or, by Observation 3.2, they cross at most twice. Finally, it is easy to verify that no red, orange, or green pseudocircle crosses a green pseudocircle more than twice. Since by construction no other pseudocircle crosses a green pseudocircle, we conclude that \( D^\circ \) is in fact an arrangement of pseudocircles. \(\square \)

4 Extending an Arrangement of Pseudocircles is Easy

Fig. 9
figure 9

Obstruction where all pseudocircles intersect \( \sigma \) twice

Fig. 10
figure 10

Obstruction where one pseudocircle intersects \( \sigma \) only once

In Sect. 2 we proved that deciding whether an edge can be inserted into a pseudocircular drawing such that the result is a simple (or a pseudocircular) drawing is hard. In this section we focus on extending arrangements of pseudocircles instead of drawings of graphs. Recall that in such an arrangement the restriction is that two pseudocircles can cross at most twice while in a simple drawing the restriction is that two edges share at most one point. The main difference in extending arrangements of pseudocircles and simple pseudocircular drawings is that in the latter the crossing possibilities are more restricted: the edge parts of two pseudocircles cannot cross twice.

Snoeyink and Hershberger [39] showed that given an arrangement \(\mathcal {A}\) of pseudocircles and three points, not all three on the same pseudocircle, one can find a pseudocircle \(\Phi \) through the three points such that \(\mathcal {A}\cup \{\Phi \}\) is again an arrangement of pseudocircles. Now, given any arrangement \(\mathcal {A}\) and a pseudosegment \(\sigma \) intersecting each pseudocircle in \(\mathcal{A}\) at most twice, it is not always possible to extend \(\sigma \) to a pseudocircle \(\Phi _\sigma \supset \sigma \) such that \(\mathcal{A}\cup \{\Phi _\sigma \}\) is again an arrangement of pseudocircles. Two examples are shown in Figs. 9 and 10. In both examples any pseudocircle \(\Phi _\sigma \) extending \(\sigma \) crosses one red or blue pseudocircle at least four times. We show in the following that the extension decision question can be answered in polynomial time:

Theorem 4.1

Given an arrangement \(\mathcal {A}\) of n pseudocircles and a pseudosegment \(\sigma \) intersecting each pseudocircle in \(\mathcal{A}\) at most twice, it can be decided in time polynomial in n whether there exists an extension of \(\sigma \) to a pseudocircle \(\Phi _\sigma \) such that that \(\mathcal{A}\cup \{\Phi _\sigma \}\) is an arrangement of pseudocircles.

An arrangement (of pseudocircles) partitions the plane into vertices (0-dimensional cells), edges (1-dimensional cells), and faces (2-dimensional cells). Since tangencies are not allowed, all vertices are proper crossings. Note that an arrangement of n pseudocircles has \(O(n^2)\) complexity. Two arrangements are combinatorially equivalent (or, isomorphic) if the corresponding cell complexes are isomorphic, that is, if there is an incidence- and dimension-preserving bijection between their cells. The extention problem does not depend on the particular geometry of the arrangement, only on the combinatorial equivalence class. Therefore, we can assume that the input is this combinatorial description (of polynomial size in n).

Proof of Theorem 4.1

Throughout this proof we write \( \overline{R} := \mathbb {R}^2 \setminus R \) for the complement of a set \( R \subseteq \mathbb {R}^2 \). By possibly transforming \(\mathcal {A}\) into an isomorphic arrangement while preserving the incidences of \(\sigma \), we can assume without loss of generality that an endpoint is incident with the unbounded cell and that the intersection points of \(\sigma \) with the pseudocircles in \(\mathcal {A}\) are all proper crossings. Further, by possibly transforming the arrangement again into an isomorphic one, we can assume that \(\sigma \) is a horizontal segment with the left endpoint incident with the unbounded cell. Let u and v be the left and right endpoints of \(\sigma \), respectively. Our algorithm aims to compute a pseudocircle \(\Phi _\sigma = \sigma \cup \sigma '\) such that \(\mathcal{A} \cup \{\Phi _\sigma \}\) is an arrangement of pseudocircles, or determine that no such \(\sigma '\) exists. We call \(\sigma '\) an extension of \(\sigma \).

We partition the set of pseudocircles of \(\mathcal {A}\) into three sets \(\mathcal {C}_0 \), \(\mathcal {C}_1\), and \(\mathcal {C}_2\), where for each \(i\in \{0,1,2\}\), \(\mathcal {C}_i\) is the set of pseudocircles in \(\mathcal {A}\) crossing \(\sigma \) exactly i times. Note that u lies outside all pseudocircles \(\phi \in \mathcal {A}\) while v lies outside of all \(\phi \in \mathcal {C}_0 \cup \mathcal {C}_2\) and inside all \(\phi \in \mathcal {C}_1\), that is, each \(\phi \in \mathcal {C}_1\) separates u and v. Further, an extension \(\sigma '\) must not cross any \(\phi \in \mathcal {C}_2\), it needs to cross every \(\phi \in \mathcal {C}_1\) exactly once, and it can cross each \(\phi \in \mathcal {C}_0\) either twice or not at all.

Fig. 11
figure 11

Algorithm extending \(\sigma \) to a pseudocircle \(\Phi _\sigma \)

The idea is to construct a finite sequence \(R_0\subset R_1\subset \ldots \) of closed subsets of \(\mathbb {R}^2\), each consisting of cells of \(\mathcal {A} \cup \sigma \) that cannot be reached by \(\sigma '\). Figure 11 illustrates this idea as well as various cases throughout the proof. Each set \(R_i\) will be a simply connected closed region of \(\mathbb {R}^2\) with both u and v on its boundary. Further, we will maintain the following invariant:

for each \(R_i\) and each \(\phi \in \mathcal {C}_0\), \({\text {int}}(\phi ) \cap \overline{R_i}\) is either a connected region or empty,

where \({\text {int}}(\phi )\) denotes the interior of the bounded area enclosed by \(\phi \). The construction will either end by determining that \(\sigma \) cannot be extended, or with a set \(R_m\) such that routing \(\sigma '\) closely along the boundary of \(R_m\) gives a valid extension of \(\sigma \).

Let \(R'_0\) be the union of \(\sigma \) and all the closed disks bounded by the pseudocircles in \(\mathcal {C}_2\) and consider the faces induced by \(R'_0\). Since u is incident with the unbounded cell of \(R'_0 \), and since \(\sigma '\) must not intersect the interior of \(R'_0\), \(\sigma '\) cannot reach any bounded face of \(R'_0 \). Let \(R_0\) be the closure of the union of these bounded faces and \(\sigma \). We may assume that \(v\in \partial R_0\), as otherwise no extension \(\sigma '\) exists and we are done.

To see that the invariant holds for \( R_0 \), assume that there exists a pseudocircle \(\phi \in \mathcal {C}_0\) such that \({\text {int}}(\phi )\cap \overline{R_0}\) is connected; see Fig. 12 for an illustration. Note that \({\text {int}}(\phi )\cap \overline{R_0}\) is connected if and only if \(R_0 \setminus {\text {int}}(\phi )\) is connected. As \(\phi \) does not intersect \(\sigma \), there exists a component D of \(R_0 \setminus {\text {int}}(\phi )\) that is disjoint from \(\sigma \). Further, as \({\text {int}}(\phi )\) is simply connected, \(D\cap \partial R_0\ne \emptyset \). Moreover, any point x on \(\partial D\cap \partial R_0\) lies on some pseudocircle \(\phi _x\in \mathcal {C}_2\). On the other hand, any path in \(R_0\) from a point of \(\sigma \) to x must enter and leave \({\text {int}}(\phi )\) and hence intersect \(\phi \) at least twice. As \(\phi _x\) intersects \(\sigma \) twice and lies in \(R_0\), we get that \(\phi _x\) intersects \(\phi \) in at least four points, a contradiction.

Fig. 12
figure 12

Proving that \(R_0\) fulfills the invariant

For the iterative step, consider the arrangement \(\mathcal {A}^{\phi }_i\) formed by \(\partial R_i\) and a pseudocircle \(\phi \in \mathcal {C}_0\cup \mathcal {C}_1\), and the cells of it that lie in \(\overline{R_i}\). If \(\phi \in \mathcal {C}_1\) and an extension \(\sigma '\) exists, then the only two such cells that can be intersected by \(\sigma '\) are the ones incident to u and v, respectively. Similarly, if \(\phi \in \mathcal {C}_0\), then \(\sigma '\) can only intersect the cell(s) incident to u and v, plus the (by the invariant) unique cell \({\text {int}}(\phi )\cap \overline{R_i}\). In both cases, all other cells of this arrangement should be added to the forbidden area. We denote all cells \(\mathcal {A}^{\phi }_i\cap \overline{R_i}\) that can possibly be intersected by \(\sigma '\) as reachable (by \(\sigma '\)) and all other cells as unreachable (by \(\sigma '\)).

Assume that there exists some pseudocircle \(\phi \in \mathcal {C}_0 \cup \mathcal {C}_1\) such that the arrangement \(\mathcal {A}^{\phi }_i\) of \(\phi \) and \(\partial R_i\) contains unreachable cells. Then we obtain \(R'_{i+1}\) by adding all those cells to \(R_i\). If v lies in a bounded region of \(\overline{R'_{i+1}}\), then no extension \(\sigma '\) exists and we are done. (Recall that by assumption u always lies in the unbounded region.) Otherwise, \(R_{i+1}=R'_{i+1}\) is a simply connected region that has both u and v on its boundary. It remains to show that the invariant is still maintained for \(R_{i+1}\).

Lemma 4.2

If \(R_i\) fulfills the invariant and u and v both lie in the unbounded region of \(\overline{R'_{i+1}}\) then \(R_{i+1}\) also fulfills the invariant.

Proof

Let \(\phi \in \mathcal {C}_0 \cup \mathcal {C}_1\) be the pseudocircle that causes the step from \(R_i\) to \(R_{i+1}\) and consider the arrangement \(\mathcal {A}^{\phi }_i\) of \(\phi \) and \(\partial R_i\) (which contains unreachable cells). Note that the boundaries of all cells of \(\mathcal {A}^{\phi }_i\) alternate between arcs of \(\phi \) and parts of \(\partial R_i\). Moreover, all cells of \(\mathcal {A}^{\phi }_i\) in \(R_{i+1}\setminus R_i\) are bounded.

We first consider the case that \(\phi \in \mathcal {C}_0\). It is illustrated in Fig. 13a. Suppose that there exists a pseudocircle \(\phi '\in \mathcal {C}_0\) for which \({\text {int}}(\phi ') \cap \overline{R_{i+1}}\) is disconnected while \({\text {int}}(\phi ') \cap \overline{R}_{i}\) is connected. Observe that \(\phi '\ne \phi \) because all the cells of \(\mathcal {A}^{\phi }_i\) that are added to \(R_i\) for obtaining \(R_{i+1}\) lie outside \(\phi \). Since \(R_i\) fulfills the invariant, each cell of \(\mathcal {A}^{\phi }_i\) in \(R_{i+1}\setminus R_i\) is bounded by a single arc of \(\phi \) and a single arc of \(\partial R_i\) and all those cells are pairwise disjoint. Hence there exists at least one such cell c that disconnects \({\text {int}}(\phi ') \cap \overline{R}_{i}\), and the boundary of c along \(\phi \) intersects \(\phi '\) (at least) twice. Recall that c is bounded and to the exterior of \(\phi \). If \(\phi '\) was only intersecting \(\phi \) at those two points, the boundary of \(\phi '\) outside c would be completely contained in \({\text {int}}(\phi )\), but then c would not disconnect \({\text {int}}(\phi ') \cap \overline{R}_{i}\). Thus, \(\phi \) must intersect \(\phi '\) in at least two more points, a contradiction.

Now consider the case \(\phi \in \mathcal {C}_1\). For an illustration consider Fig. 13b. Assume again that there exists a pseudocircle \(\phi '\in \mathcal {C}_0\) for which \({\text {int}}(\phi ')\cap \overline{R_{i+1}}\) is disconnected while \({\text {int}}(\phi ') \cap \overline{R}_{i}\) is connected. Consider again a cell c of \(\mathcal {A}^{\phi }_i\) that is part of \(R_{i+1} \setminus R_i\) and disconnects \({\text {int}}(\phi ') \cap \overline{R}_{i}\). The cell c must not contain any of u and v as otherwise it would not be in \(R_{i+1}\). Further, the cell c cannot separate u and v, as otherwise v would have been in a bounded region of \(R_{i+1}'\) and we would have stopped the process. As c disconnects \({\text {int}}(\phi ') \cap \overline{R}_{i}\), \(\phi \) intersects \(\phi '\) twice along the boundary of c (and hence outside \(R_i\)). As every pair of pseudocircles have at most two intersection points, \(\phi \) does not intersect \(\phi '\) in any other points. Especially, \(\phi \) does not intersect \(\phi '\) inside \(R_i\). Furthermore, \(\phi \) intersects \(\partial R_i\) in \({\text {int}}(\phi ')\) at least twice along \(\partial c\) (causing the disconnection of \({\text {int}}(\phi ')\cap \overline{R}_{i}\)) and \(\phi \) also intersects \(\partial R_i\) outside of \(\phi '\) (as it must intersect \(\sigma \) and \(\phi '\) cannot intersect \(\sigma \)). This last property implies that each component of \({\text {int}}(\phi ') \cap \overline{R_{i+1}}\) induced by c lies in a different reachable cell of \(\mathcal {A}^{\phi }_i\) that is neighboring to c via an arc of \(\phi \). However, as c does not separate u and v, at most one such cell can exist, a contradiction to \({\text {int}}(\phi ') \cap \overline{R_{i+1}}\) being disconnected. \(\square \)

Fig. 13
figure 13

Illustration of potentially separating cells in the proof of Lemma 4.2. The red arc and area belong to \( \phi ' \in {\mathcal {C}}_0 \), the blue striped area is the cell c, the blue curve is the pseudocircle \( \phi \in {\mathcal {C}}_0 \cup {\mathcal {C}}_1\)

Now assume that both u and v lie on the boundary of all sets \(R_i\) constructed in this way. Then the iterative process stops with a set \(R_m\) where for each \(\phi \in \mathcal {C}_0\cup \mathcal {C}_1\), all cells in the arrangement \(\mathcal {A}^{\phi }_m\) of \(\phi \) and \(\partial R_m\) that are contained in \(\overline{R_m}\) are reachable by \(\sigma '\). Note that \(m = O(n^2)\) as \({\mathcal {A}}\) has \(O(n^2)\) cells, in every iteration i at least one cell of \({\mathcal {A}}\) has been added to \(R_i\), and each cell of \(\mathcal {A}\) is added at most once. Consider a path P from u to v in \(\overline{R_m}\) that is routed closely along the boundary \(\partial R_m\) (note that there are two different such paths). Then for any \(\phi \in \mathcal {C}_1\), P intersects exactly two cells of \(\mathcal {A}^{\phi }_m\), namely, the ones incident to u and v, respectively. Hence P crosses \(\phi \) exactly once. Similarly, for any \(\phi \in \mathcal {C}_0\), the path P intersects at most three cells of \(\mathcal {A}^{\phi }_m\), namely, the one(s) incident to u and v plus possibly the cell \({\text {int}}(\phi ) \cap \overline{R_m}\), which is one cell by the invariant. Hence P crosses \(\phi \) at most twice. Thus \(\sigma '=P\) is a valid extension for \(\sigma \), which completes the correctness argument.

Note that computing \(R_0\) and \(\sigma '\) (in case that the algorithm didn’t terminate with a negative answer before) can be done in polynomial time. Also, for each \( R_i \) and each \(\phi \in \mathcal C_0\cup {\mathcal {C}}_1 \), the set of unreachable cells of \( \mathcal {A}^{\phi }_i \) can be determined in polynomial time. As we have \( O(n^2) \) iteration steps, we can hence compute \( R_{m} \) from \( R_0 \) (or determine that \( \sigma \) is not extendible) in polynomial time, which concludes the proof.\(\square \)

As an immediate consequence of Theorem 4.1 we have the following result:

Corollary 4.3

Given an arrangement \(\mathcal {A}\) pseudocircles and a pseudosegment \(\sigma \), it can be decided in polynomial time whether \(\sigma \) can be extended to a pseudocircle \(\Phi _\sigma \supset \sigma \) such that \(\mathcal{A} \cup \{\Phi _\sigma \}\) is an arrangement of pseudocircles.

5 An FPT-Algorithm for Bounded Number of Crossings

In this section we show that for drawings with a bounded number of crossings it can be decided in FPT-time whether an edge can be inserted. Given a simple drawing D(G) with k crossings, one can construct a kernel of size O(k) by exhaustively removing isolated vertices and uncrossed edges from D(G). For a simple drawing D(G) of a graph \(G =(V,E)\) and \(e\in E\), let be the subdrawing of D(G) without the drawing of e. Similarly, for an isolated vertex \(u\in V\), let be the subdrawing of D(G) without the drawing of u.

Observation 5.1

Given a simple drawing D(G) of a graph \( G = (V,E) \) and an isolated vertex \(w \in V\), an edge uv of \(\overline{G}\) can be inserted into D(G) if and only if uv can be inserted into .

By Observation 5.1 we get that isolated vertices can be disregarded in an algorithm that extends a simple drawing D(G) of a graph by one edge. The following lemma implies that the same is true for uncrossed edges in D(G).

Lemma 5.2

Given a simple drawing D(G) of a graph \( G = (V,E) \) and an edge \( e \in E \) that is uncrossed in D(G) , an edge uv of \(\overline{G}\) can be inserted into D(G) if and only if uv can be inserted into .

Proof

Since is a subdrawing of D(G), it is clear that if uv can be inserted into D(G) then it can be inserted into . Suppose that uv can be inserted into and let \(\gamma \) be a valid drawing of uv in , that is, one resulting in a simple drawing of \(G \setminus \{e\} \cup \{uv\}\). We orient \(\gamma \) from u to v. If \(\gamma \) is not a valid drawing of uv in D(G) then it must intersect e more than once in D(G) . We can modify \(\gamma \) such that it is routed close to e between its first and last intersection with e, producing at most one intersection; see Fig. 14 for an illustration. If e is not incident to u or v we are done. Else assume without loss of generality that e is incident to u and let \(\gamma '\) be the drawing of uv that was modified such that it has only one intersection with e. Recall that e is uncrossed in D(G). Hence, the intersection point \(\times \) of \(\gamma '\) with e and the point u lie on the boundary of one cell in D(G). Consequently, we can modify \(\gamma ' \) in such a way that it is routed closely to e from u to \({\times }\) on the side of e on which \(\gamma '\) continues to v without producing a crossing with any other edge in D(G) . Either modification only reduces crossings, but does not introduce new ones, hence we obtained a valid drawing of uv in D(G) as desired. \(\square \)

Fig. 14
figure 14

Rerouting uv when it crosses an otherwise uncrossed edge more than once

Equipped with Observation 5.1 and Lemma 5.2 we are ready to prove the main theorem of this section.

Theorem 5.3

Given a simple drawing D(G) of a graph \( G = (V,E) \) and an edge uv of \(\overline{G}\), there is an FPT-algorithm in the number k of crossings in D(G) for deciding whether uv can be inserted into D(G) .

Proof

Let \( G' \) be the subgraph of G remaining after exhaustively deleting uncrossed edges and isolated vertices distinct from u and v. Furthermore, let \( D'(G') \) be the corresponding subdrawing of D(G) . By assumption, there are at most 2k crossed edges in G. Hence \( G' \) has at most \( 4k + 2 \) vertices and 2k edges. Furthermore, by Observation 5.1 and Lemma 5.2 we can insert uv into D(G) if and only if it can be inserted into \( D'(G') \).

For solving the kernel instance of inserting uv into \(D'(G')\), we reformulate the problem of inserting an edge into a simple drawing as a problem in the dual graph of its planarization, as in [4]. In the planarization crossings are replaced by vertices resulting in a plane drawing. Given a simple drawing D(G) of a graph G, the dual graph \(G^*(D)\) is the plane dual of the planarization of D(G). Thus, every vertex in \(G^*(D)\) corresponds to a cell in D(G) and every edge in \(G^*(D)\) corresponds to a segment of an edge in D(G). We assign to each edge in D(G) a different color (label) and define a coloring \(\chi \) of the edges of \(G^*(D)\), where every edge in \(G^*(D)\) inherits the color of its primal edge in D(G). Given two vertices \(u,v\in V\), let \(G^*(D,\{u,v\})\) be the subgraph of \(G^*(D)\) obtained by removing from it the edges corresponding to segments of edges incident with u or to v. Let \(\chi '\) denote the coloring of the edges of \(G^*(D,\{u,v\})\) that coincides with \(\chi \) in every edge. The problem of extending D(G) with one edge uv is then equivalent to the problem of finding a path in \(G^{*}(D,\{u,v\})\) between a vertex corresponding to a cell incident with u and a vertex corresponding to a cell incident with v in which no color given by \(\chi \) is repeated (that is, the path is heterochromatic).

The number of segments of crossed edges in \(D'(G')\) is at most 4k. Thus, \(G^*(D',\{u,v\})\) has at most 4k edges (while the number of vertices might not be bounded by a function of k). There are O(n) cells in \(D'(G')\) with u or v on their boundary. Further, every cell in \(D'(G')\) has complexity O(k). Checking whether uv can be inserted into \(D'(G')\) can be done by (i) checking for each of the O(n) vertices in \(G^*(D',\{u,v\})\) whether both u and v are incident to the according cell in \(D'(G')\), and (ii) checking for each of the \(O(2^{4k})\) non-empty subsets of edges in \(G^*(D',\{u,v\})\) whether they form a valid heterochromatic path with endpoints incident to u and v, respectively. Altogether, this can be done (brute-force) in \(O(nk + k^2 2^{4k})\) time. \(\square \)

6 Conclusions

In this paper we showed that given a simple drawing D(G) of a graph G it is NP-hard to decide if a particular edge from the complement of G can be inserted into D(G) such that the result is a simple drawing. On the positive side, we showed that for a given pseudocircular arrangement \({\mathcal {A}}\) of pseudocircles and a pseudosegment \(\sigma \) it can be decided in polynomial time whether \(\sigma \) can be extended to a simple closed curve \(\Phi _\sigma \) such that \({\mathcal {A}} \cup \{\Phi _\sigma \}\) is again an arrangement of pseudocircles. Furthermore, we proved that the problem is FPT with respect to the number of crossings of D(G).

In the light of our results, checking whether a simple drawing D(G) is saturated by trying to insert every edge of the complement of G is hopeless (unless P \(= \texttt {NP}\)). Thus, it is an interesting open problem whether there is a polynomial algorithm for deciding if a simple drawing is saturated.