1 Introduction

The input of a simultaneous embedding problem consists of several graphs \(G_1=(V,E_1),\dots ,G_k=(V,E_k)\) on the same vertex set. For a fixed drawing style \(\mathcal S\), the simultaneous embedding problem asks whether there exist drawings \(\varGamma _1,\dots ,\varGamma _k\) of \(G_1,\dots ,G_k\), respectively, in drawing style \(\mathcal S\) such that for any i and j the restrictions of \(\varGamma _i\) and \(\varGamma _j\) to \(G_i \cap G_j = (V,E_i \cap E_j)\) coincide.

The problem has been most widely studied in the setting of topological planar drawings, where vertices are represented as points and edges are represented as pairwise interior-disjoint Jordan arcs between their endpoints. This problem is called Simultaneous Embedding with Fixed Edges or SEFE- k for short, where k is the number of input graphs. It is known that SEFE- k is NP-complete for \(k \ge 3\), even in the restricted case of sunflower instances [25], where every pair of graphs shares the same set of edges, and even if such a set induces a star [3]. On the other hand, the complexity for \(k=2\) is still open. Recently, efficient algorithms for restricted instances have been presented, namely when (i) the shared graph \(G_\cap = G_1 \cap G_2\) is biconnected [4, 18] or a star-graph [4], (ii) \(G_\cap \) is a collection of disjoint cycles [12], (iii) every connected component of \(G_\cap \) is either subcubic or biconnected [10, 25], (iv) \(G_1\) and \(G_2\) are biconnected and \(G_\cap \) is connected [13], and (v) \(G_\cap \) is connected and the input graphs have maximum degree 5 [13]; see the survey by Bläsius et al. [11] for an overview.

For planar straight-line drawings, the simultaneous embedding problem is called Simultaneous Geometric Embedding and it is known to be NP-hard even for two graphs [17]. Besides simultaneous intersection representation for, e.g., interval graphs [13, 19] and permutation and chordal graphs [20], it is only recently that the simultaneous embedding paradigm has been applied to other fundamental planarity-related drawing styles, namely simultaneous level planar drawings [2] and RAC drawings [5, 7].

We continue this line of research by studying simultaneous embeddings in the planar orthogonal drawing style, where vertices are assigned to grid points and edges to paths on the grid connecting their endpoints [28]. In accordance with the existing naming scheme, we define \({\textsc {OrthoSEFE}\text {-}{k}} \) to be the problem of testing whether k input graphs \(\langle G_1,\dots ,G_k \rangle \) admit a simultaneous planar orthogonal drawing. If such a drawing exists, we call it an OrthoSEFE of \(\langle G_1,\dots , G_k \rangle \). Note that it is a necessary condition that each \(G_i\) has maximum degree 4 in order to obtain planar orthogonal drawings. Hence, in the remainder of the paper we assume that all instances have this property. For instances with this property, at least when the shared graph is connected, the problem SEFE-2 can be solved efficiently [13]. However, there are instances of \({\textsc {OrthoSEFE}\text {-}{2}} \) that admit a SEFE but not an OrthoSEFE; see Fig. 1(a).

Unless mentioned otherwise, all instances of \({\textsc {OrthoSEFE}\text {-}{k}} \) and SEFE-k we consider are sunflower. Notice that instances with \(k=2\) are always sunflower. Let \(\langle G_1=(V,E_1),G_2=(V,E_2) \rangle \) be an instance of \({\textsc {OrthoSEFE}\text {-}{2}} \). We define the shared graph (resp. the union graph) to be the graph \(G_\cap = (V, E_1 \cap E_2)\) (resp. \(G_\cup = (V, E_1 \cup E_2)\)) with the same vertex set as \(G_1\) and \(G_2\), whose edge set is the intersection (resp. the union) of the ones of \(G_1\) and \(G_2\). Also, we call the edges in \(E_1 \cap E_2\) the shared edges and we call the edges in \(E_1 \setminus E_2\) and in \(E_2 \setminus E_1\) the exclusive edges. The definitions of shared graph, shared edges, and exclusive edges naturally extend to sunflower instances for any value of k.

Fig. 1.
figure 1

(a) A negative instance of \({\textsc {OrthoSEFE}\text {-}{2}} \). Shared edges are black, while exclusive edges are red and blue. The red edges require \(270^\circ \) angles on different sides of C. Thus, the blue edge (uv) cannot be drawn. Note that the given drawing is a SEFE-2. (b) Examples of side assignments for the exclusive edges incident to degree-2 vertices of \(G_\cap \): orthogonality constraints are satisfied at \(v_4\) and \(v_5\), while they are violated at \(v_3\). (Color figure online)

One main issue is to decide how degree-2 vertices of the shared graph are represented. Note that, in planar topological drawings, degree-2 vertices do not require any decisions as there exists only a single cyclic order of their incident edges. In the case of orthogonal drawings there are, however, two choices for a degree-2 vertex: It can either be drawn straight, i.e., it is incident to two angles of \(180^\circ \), or bent, i.e., it is incident to one angle of \(90^\circ \) and to one angle of \(270^\circ \). If v is a degree-2 vertex of the shared graph with neighbors u and w, and two exclusive edges \(e,e'\), say of \(G_1\), are incident to v and are embedded on the same side of the path uvw, then v must be bent, which in turn implies that also every exclusive edge of \(G_2\) incident to v has to be embedded on the same side of uvw as e and \(e'\). In this way, the two input graphs of \({\textsc {OrthoSEFE}\text {-}{2}} \) interact via the degree-2 vertices. It is the difficulty of controlling this interaction that marks the main difference between SEFE-k and \({\textsc {OrthoSEFE}\text {-}{k}} \). To study this interaction in isolation, we focus on instances of \({\textsc {OrthoSEFE}\text {-}{2}} \) where the shared graph is a cycle for most of the paper. Note that such instances are trivial yes-instances of SEFE-k (provided the input graphs are all planar).

Contributions and Outline. In Sect. 2, we provide our notation and we show that the existence of an OrthoSEFE of an instance of \({\textsc {OrthoSEFE}\text {-}{k}} \) can be described as a combinatorial embedding problem. In Sect. 3, we show that \({\textsc {OrthoSEFE}\text {-}{3}} \) is NP-complete even if the shared graph is a cycle, and that \({\textsc {OrthoSEFE}\text {-}{2}} \) is NP-complete even if the shared graph consists of a cycle plus some isolated vertices. This contrasts the situation of SEFE-k where these cases are polynomially solvable [4, 9, 18, 25]. In Sect. 4, we show that \({\textsc {OrthoSEFE}\text {-}{2}} \) is efficiently solvable if the shared graph is a cycle and the union graph has maximum degree 5. Finally, in Sect. 5, we extend this result to the case where the shared graph is biconnected (and the union graph still has maximum degree 5). Moreover, we show that any positive instance of \({\textsc {OrthoSEFE}\text {-}{k}} \) whose shared graph is biconnected admits an OrthoSEFE with at most three bends per edge. We close with some concluding remarks and open questions in Sect. 6.

Complete proofs can be found in the full version of the paper [1].

2 Preliminaries

We will extensively make use of the Not-All-Equal 3-Sat (Nae3Sat) problem [24, p.187]. An instance of Nae3Sat consists of a 3-CNF formula \(\phi \) with variables \(x_1,\ldots ,x_n\) and clauses \(c_1,\ldots ,c_m\). The task is to find a Nae truth assignment, i.e., a truth assignment such that each clause contains both a true and a false literal. Nae3Sat is known to be NP-complete [26]. The variable–clause graph is the bipartite graph whose vertices are the variables and the clauses, and whose edges represent the membership of a variable in a clause. The problem Planar Nae3Sat is the restriction of Nae3Sat to instances whose variable–clause graph is planar. Planar Nae3Sat can be solved efficiently [22, 27].

Embedding Constraints. Let \(\langle G_1^{}, \dots , G_k^{}\rangle \) be an \({\textsc {OrthoSEFE}\text {-}{k}} \) instance. A SEFE is a collection of embeddings \(\mathcal E_i\) for the \(G_i\) such that their restrictions on \(G_\cap \) are the same. Note that in the literature, a SEFE is often defined as a collection of drawings rather than a collection of embeddings. However, the two definitions are equivalent [21]. For a SEFE to be realizable as an OrthoSEFE it needs to satisfy two additional conditions. First, let v be a vertex of degree 2 in \(G_\cap \) with neighbors u and w. If in any embedding \(\mathcal E_i\) there exist two exclusive edges incident to v that are embedded on the same side of the path uvw, then any exclusive edge incident to v in any of the \(\mathcal E_j \ne \mathcal E_i\) must be embedded on the same side of the path uvw. Second, let v be a vertex of degree 3 in \(G_\cap \). All exclusive edges incident to v must appear between the same two edges of \(G_\cap \) around v. We call these the orthogonality constraints. See Fig. 1(b).

Theorem 1

An instance \(\langle G_1^{}, \dots , G_k^{}\rangle \) of \({\textsc {OrthoSEFE}\text {-}{k}} \) has an OrthoSEFE if and only if it admits a SEFE satisfying the orthogonality constraints.

For the case in which the shared graph is a cycle C, we give a simpler version of the constraints in Theorem 1, which will prove useful in the remainder of the paper. By the Jordan curve theorem, a planar drawing of cycle C divides the plane into a bounded and an unbounded region – the inside and the outside of C, which we call the sides of C. Now the problem is to assign the exclusive edges to either of the two sides of C so that the following two conditions are fulfilled.

Planarity Constraints. Two exclusive edges of the same graph must be drawn on different sides of C if their endvertices alternate along C.

Orthogonality Constraints. Let \(v \in V\) be a vertex that is adjacent to two exclusive edges \(e_i\) and \(e'_i\) of the same graph \(G_i\), \(i \in \{1,\dots ,k\}\). If \(e_i\) and \(e'_i\) are on the same side of C, then all exclusive edges incident to v of all graphs \(G_1,\dots ,G_k\) must be on the same side as \(e_i\) and \(e'_i\).

Note that this is a reformulation of the general orthogonality constraints. Further, the orthogonality constraints also imply that if \(e_i\) and \(e_i'\) are on different sides of C, then for each graph \(G_j\) that contains two exclusive edges \(e_j\) and \(e_j'\) incident to v, with \(j \in \{1,\dots , k\}\), \(e_j\) and \(e_j'\) must be on different sides of C.

The next theorem follows from Theorem 1 and from the following two observations. First, for a sunflower instance \(\langle G_1^{}, \dots , G_k^{}\rangle \) whose shared graph is a cycle, any collection of embeddings is a SEFE [21]. Second, the planarity constraints are necessary and sufficient for the existence of an embedding of \(G_i\) [6].

Theorem 2

An instance of \({\textsc {OrthoSEFE}\text {-}{k}} \) whose shared graph is a cycle C has an OrthoSEFE if and only if there exists an assignment of the exclusive edges to the two sides of C satisfying the planarity and orthogonality constraints.

3 Hardness Results

We show that \({\textsc {OrthoSEFE}\text {-}{k}} \) is NP-complete for \(k \ge 3\) for instances with sunflower intersection even if the shared graph is a cycle, and for \(k=2\) even if the shared graph consists of a cycle and isolated vertices.

Theorem 3

\({\textsc {OrthoSEFE}\text {-}{k}} \) with \(k \ge 3\) is NP-complete, even for instances with sunflower intersection in which (i) the shared graph is a cycle and (ii) \(k-1\) of the input graphs are outerplanar and have maximum degree 3.

Fig. 2.
figure 2

(a) A clause gadget \(C_j\) (top) and a variable-clause gadget \(V_i^j\) (bottom); solid edges belong to the gadgets, dotted edges are optional, and dashed edges are transmission edges. (b) Illustration of instance \(\langle G_1,G_2,G_3\rangle \), focused on a clause \(c_4\). Black edges belong to the shared graph \(G_\cap \). The red, blue, and green edges are the exclusive edges of \(G_1\), \(G_2\), and \(G_3\), respectively. (Color figure online)

Proof sketch

The membership in NP directly follows from Theorem 2. To prove the NP-hardness, we show a polynomial-time reduction from the NP-complete problem Positive Exactly-Three Nae3Sat [23], which is the variant of Nae3Sat in which each clause consists of exactly three unnegated literals.

Let \(x_1,x_2,\dots ,x_n\) be the variables and let \(c_1,c_2,\dots ,c_m\) be the clauses of a 3-CNF formula \(\phi \) of Positive Exactly-Three Nae3Sat. We show how to construct an equivalent instance \(\langle G_1,G_2,G_3\rangle \) of \({\textsc {OrthoSEFE}\text {-}{3}} \) such that \(G_1\) and \(G_2\) are outerplanar graphs of maximum degree 3. We refer to the exclusive edges in \(G_1\), \(G_2\), and \(G_3\) as red, blue, and green, respectively; refer to Fig. 2.

For each clause \(c_j\), \(j=1,\dots ,m\), we create a clause gadget \(C^j\) as in Fig. 2(a) (top). For each variable \(x_i\), \(i=1,\dots ,n\), and each clause \(c_j\), \(j=1,\dots ,m\), we create a variable-clause gadget \(V_i^j\) as in Fig. 2(a) (bottom). Observe that the (dotted) green edge \(\{w_i^j,r_i^j\}\) in a variable-clause gadget is only part of \(V_i^j\) if \(x_i\) does not occur in \(c_j\). Otherwise, there is a green edge \(\{w_i^j,y_x^j\}\) connecting \(w_i^j\) to one of the three vertices \(y_a^j\), \(y_b^j\), or \(y_c^j\) (dashed stubs) in the clause gadget. Observe that these three variable-clause edges per clause can be realized in such a way that there exist no planarity constraints between pairs of them. In Fig. 2(b), the variable-clause gadgets \(V_1^4\), \(V_3^4\), \(V_4^4\) are incident to variable-clause edges, while \(V_2^4\) and \(V_5^4\) contain edges \(\{w_2^4,r_2^4\}\) and \(\{w_5^4,r_5^4\}\), respectively.

The gadgets are ordered as indicated in Fig. 2(b). The variable-clause gadgets \(V_i^j\), with \(i=1,\dots ,n\), always precede the clause gadget \(V^j\), for any \(j=1,\dots ,m\). Further, if j is odd, then the gadgets \(V_1^j,\dots ,V_n^j\) appear in this order, otherwise they appear in reversed order \(V_n^j,\dots ,V_1^j\). Finally, \(V_i^j\) and \(V_i^{j+1}\), for \(i=1,\dots ,n\) and \(j=1,\dots ,m-1\), are connected by an edge \(\{w_i^j,w_i^{j+1}\}\), which is blue if j is odd and red if j is even. We call these edges transmission edges.

Assume \(\langle G_1, G_2, G_3 \rangle \) admits an OrthoSEFE. Planarity constraints and orthogonality constraints guarantee three properties: (i) If the edge \(\{u_i^j,v_i^j\}\) is inside C, then so is \(\{u_i^{j+1},v_i^{j+1}\}\), \(i=1,\dots ,n\), \(j=1,\dots ,m-1\). This is due to the fact that, by the planarity constraints, the two green edges incident to \(w_i^j\) lie on the same side of C and hence, by the orthogonality constraints, the two transmission edges incident to \(w_i^j\) also lie on this side. We call \(\{u_i^1,v_i^1\}\) the truth edge of variable \(x_i\). (ii) Not all the three green edges \(a=\{\alpha ^j,\beta ^j\}\), \(b=\{\beta ^j,\gamma ^j\}\), and \(c=\{\gamma ^j,\delta ^j\}\) lie on the same side of C. Namely, the two red edges of the clause gadget \(C^j\) must lie on opposite sides of C because of the interplay between the planarity and the orthogonality constraints in the subgraph of \(C^j\) induced by the vertices between \(\beta ^j\) and \(\gamma ^j\). Hence, if edges a, b, and c lie on the same side of C, then the orthogonality constraints at either \(\beta ^j\) or \(\gamma ^j\) are not satisfied. (iii) For each clause \(c_j=(x_a,x_b,x_c)\), edge \(a=\{\alpha ^j,\beta ^j\}\) lies on the same side of C as the truth edge of \(x_a\). This is due to the planarity constraints between each of these two edges and the variable-clause edge \(\{w_a^j,y_a^j\}\). Analogously, edge b (edge c) lies on the same side as the truth edge of \(x_b\) (of \(x_c\)). Hence, setting \(x_i = \mathsf{true} \) (\(x_i = \mathsf{false} \)) if the truth edge of \(x_i\) is inside C (outside C) yields a Nae3Sat truth assignment that satisfies \(\phi \).

The proof for the other direction is based on the fact that assigning the truth edges to either of the two sides of C according to the Nae3Sat assignment of \(\phi \) also implies a unique side assignment for the remaining exclusive edges that satisfies all the orthogonality and the planarity constraints.

It is easy to see that \(G_1\) and \(G_2\) are outerplanar graphs with maximum degree 3, and that the reduction can be extended to any \(k>3\).    \(\square \)

In the following, we describe how to modify the construction in Theorem 3 to show hardness of \({\textsc {OrthoSEFE}\text {-}{2}} \). We keep only the edges of \(G_1\) and \(G_3\). Variable-clause gadgets and clause gadgets remain the same, as they are composed only of edges belonging to these two graphs. We replace each transmission edge in \(G_2\) by a transmission path composed of alternating green and red edges, starting and ending with a red edge. This transformation allows these paths to traverse the transmission edges of \(G_1\) and the variable-clause edges of \(G_3\) without introducing crossings between edges of the same color. It is easy to see that the properties described in the proof of Theorem 3 on the assignments of the exclusive edges to the two sides of C also hold in the constructed instance, where transmission paths take the role of the transmission edges.

Theorem 4

\({\textsc {OrthoSEFE}\text {-}{2}} \) is NP-complete, even for instances \(\langle G_1^{}, G_2^{}\rangle \) in which the shared graph consists of a cycle and a set of isolated vertices.

4 Shared Graph is a Cycle

In this section, we give a polynomial-time algorithm for instances of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph is a cycle and whose union graph has maximum degree 5 (Theorem 5). In order to obtain this result, we present an efficient algorithm for more restricted instances (Lemma 1) and give a series of transformations (Lemmas 23) to reduce any instance with the above properties to one that can be solved by the algorithm in Lemma 1.

Lemma 1

\({\textsc {OrthoSEFE}\text {-}{2}} \) is in P for instances \(\langle G_1^{}, G_2^{}\rangle \) such that the shared graph C is a cycle and \(G_1\) is an outerplanar graph with maximum degree 3.

Fig. 3.
figure 3

(a) Instance \(\langle G_1^{}, G_2^{}\rangle \) satisfying the properties of Lemma 1, where the edges in \(E_2\) belonging to the components \(\alpha \), \(\beta \), \(\gamma \), and \(\delta \) of H have different line styles. (b) Polygons for the components of H. (c) Graph \(\widetilde{G}\). (d) Variable–clause graph \(G_\phi \). (Color figure online)

Proof

The algorithm is based on a reduction to Planar Nae3Sat, which is in P [22, 27]. First note that, since \(G_1\) is outerplanar, there exist no two edges in \(E_1\) alternating along C. Hence, there are no planarity constraints for \(G_1\).

We now define an auxiliary graph H with vertex set \(E_2\setminus E_1\) and edges corresponding to pairs of edges alternating along C; see Fig. 3(a). W.l.o.g. we may assume that H is bipartite, since \(G_2\) would not meet the planarity constraints otherwise [6]. Let \(\mathcal B\) be the set of connected components of H, and for each component \(B\in \mathcal{B}\), fix a partition \(B_1,B_2\) of B into independent sets (possibly \(B_2=\emptyset \) in case of a singleton B). Note that in any inside/outside assignment of the exclusive edges of \(G_2\) that meets the planarity constraints, for every \(B\in \mathcal{B}\), all edges of \(B_1\) lie on one side of C and all edges of \(B_2\) lie on the other side.

Draw the cycle C as a circle in the plane. For a component \(B \in \mathcal{B}\), let \(P_B\) be the polygon inscribed into C whose corners are the endvertices in V of the edges in \(E_2\) corresponding to the vertices of B; refer to Fig. 3(b). If B only contains one vertex (i.e., one edge of \(G_2\)), we consider the digon \(P_B\) as the straight-line segment connecting the vertices of this edge. If B has at least two vertices, we let \(P_B\) be open along its sides, i.e., it will contain the corners and all inner points (in Fig. 3(b) we depict this by making the sides of \(P_B\) slightly concave). One can easily show that, for any two components \(B,D\in \mathcal{B}\), their polygons \(P_B,P_D\) may share only some of their corners, but no inner points. Hence, the graph \(\widetilde{G}\) obtained by placing a vertex \(x_B\) inside the polygon \(P_B\), for \(B \in \mathcal{B}\), making \(x_B\) adjacent to each corner of \(P_B\) and adding the edges \(E_1\), is planar; see Fig. 3(c).

We construct a formula \(\phi \) with variables \(x_B\), \(B \in \mathcal{B}\), such that \(\phi \) is Nae-satisfiable if and only if \(\langle G_1^{}, G_2^{}\rangle \) admits an inside/outside assignment meeting all planarity and orthogonality constraints. The encoding of the truth assignment will be such that \(x_B\) is true when the edges of \(B_1\) are inside C and the edges of \(B_2\) are outside, and \(x_B\) is false if the reverse holds. Every assignment satisfying the planarity constraints for \(G_2\) defines a truth-assignment in the above sense.

Let \(e=(v,w)\) be an exclusive edge of \(E_1\) and let \(e_v^1,e_v^2\) (\(e_w^1,e_w^2\)) be the exclusive edges of \(E_2\) incident to v (to w, respectively); we assume that all such four edges of \(E_2\) exist, the other cases being simpler. Let B(ui) be the component containing the edge \(e_u^i\), for \(u\in \{v,w\}\) and \(i \in \{1,2\}\). Define the literal \(\ell _u^i\) to be \(x_{B(u,i)}\) if \(e_u^i \in B_1(u,i)\) and \(\lnot x_{B(u,i)}\) if \(e_u^i\in B_2(u,i)\). With our interpretation of the truth assignment, an edge \(e_u^i\) is inside C if and only if \(\ell _u^i\) is true. Now, for the assignment to meet the orthogonality constraints, if \(\ell _v^1 = \ell _v^2\), say both are true, then e must be assigned inside C as well, which would cause a problem if and only if \(\ell _w^1 = \ell _w^2 = \mathsf{false}\). Hence, the orthogonality constraints are described by Nae-satisfiability of the clauses \(c_e = (\ell _v^1, \ell _v^2, \lnot \ell _w^1, \lnot \ell _w^2)\), for each \(e\in E_1\). To reduce to Nae3Sat, we introduce a new variable \(x_e\) for each edge \(e\in E_1 \setminus E_2\) and replace the clause \(c_e\) by two clauses \(c'_e=(\ell _v^1, \ell _v^2, x_e)\) and \(c''_e=(\lnot x_e, \lnot \ell _w^1, \lnot \ell _w^2)\). A planar drawing of the variable–clause graph \(G_\phi \) of the resulting formula \(\phi \) is obtained from the planar drawing \(\widetilde{\varGamma }\) of \(\widetilde{G}\) (see Figs. 3(c) and 3(d)) by (i) placing each variable \(x_B\), with \(B \in \mathcal{B}\), on the point where vertex \(x_B\) lies in \(\widetilde{\varGamma }\), (ii) placing each variable \(x_e\), with \(e \in E_1\), on any point of edge e in \(\widetilde{\varGamma }\), (iii) placing clauses \(c'_e\) and \(c''_e\), for each edge \(e=(v,w) \in E_1\), on the points where vertices v and w lie in \(\widetilde{\varGamma }\), respectively, and (iv) drawing the edges of \(G_\phi \) as the corresponding edges in \(\widetilde{\varGamma }\). This implies that \(G_\phi \) is planar and hence we can test the Nae-satisfiability of \(\phi \) in polynomial time [22, 27].    \(\square \)

The next two lemmas show that we can use Lemma 1 to test in polynomial time any instance of \({\textsc {OrthoSEFE}\text {-}{2}} \) such that \(G_\cap \) is a cycle and each vertex \(v \in V\) has degree at most 3 in either \(G_1\) or \(G_2\).

Lemma 2

Let \(\langle G_1^{}, G_2^{}\rangle \) be an instance of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph is a cycle and such that \(G_1\) has maximum degree 3. It is possible to construct in polynomial time an equivalent instance \(\langle G_1^{*}, G_2^{*}\rangle \) of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph is a cycle and such that \(G_1^*\) is outerplanar and has maximum degree 3.

Proof sketch

We construct an equivalent instance \(\langle G_1^{\prime }, G_2^{\prime }\rangle \) of \({\textsc {OrthoSEFE}\text {-}{2}} \) such that \(G_\cap ^\prime \) is a cycle, \(G_1^\prime \) has maximum degree 3, and the number of pairs of edges in \(G_1^\prime \) that alternate along \(G_\cap ^\prime \) is smaller than the number of pairs of edges in \(G_1\) that alternate along \(G_\cap \). Repeatedly applying this transformation yields an equivalent instance \(\langle G_1^{*}, G_2^{*}\rangle \) satisfying the requirements of the lemma.

Consider two edges \(e=(u,v)\) and \(f=(w,z)\) of \(G_1\) such that uwvz appear in this order along cycle \(G_\cap \) and such that the path \(P_{u,z}\) in \(G_\cap \) between u and z that contains v and w has minimal length. If \(G_1\) is not outerplanar, then the edges e and f always exist. Figure 4 illustrates the construction of \(\langle G_1^{\prime }, G_2^{\prime }\rangle \).

By the choice of e and f, and by the fact that \(G_1\) has maximum degree 3, there is no exclusive edge in \(G_1\) with one endpoint in the set \(H_2\) of vertices between w and v, and the other one not in \(H_2\). Further, observe that in an OrthoSEFE of \(\langle G_1^{\prime }, G_2^{\prime }\rangle \) edges f and \(f'\) (edges e and \(e'\)) must be on the same side. Further, e and f must be in different sides of \(G'_\cap \). It can be concluded that \(\langle G_1^{\prime }, G_2^{\prime }\rangle \) has an OrthoSEFE if and only if \(\langle G_1^{}, G_2^{}\rangle \) has an OrthoSEFE.    \(\square \)

The proof of the next lemma is based on the replacement illustrated in Fig. 5. Afterwards, we combine these results to present the main result of the section.

Fig. 4.
figure 4

Instances (left) \(\langle G_1^{}, G_2^{}\rangle \) and (right) \(\langle G_1^{\prime }, G_2^{\prime }\rangle \) for the proof of Lemma 2. Edges of \(G_\cap \) (\(G'_\cap \)) are black. Exclusive edges of \(G_1\) (\(G'_1\)) are red and those of \(G_2\) (\(G'_2\)) are blue. (Color figure online)

Fig. 5.
figure 5

Illustration of the transformation for the proof of Lemma 3 to reduce the number of vertices incident to two exclusive edges in \(G_1\). Edges \(e',f'\) of \(G_2\) and \(h'\) of \(G_1\) (right) take the role of edges ef of \(G_1\) and h of \(G_2\) (left), respectively. Thus, the orthogonality constraints at \(v'\) are equivalent to those at v. (Color figure online)

Lemma 3

Let \(\langle G_1^{}, G_2^{}\rangle \) be an instance of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph is a cycle and whose union graph has maximum degree 5. It is possible to construct in polynomial time an equivalent instance \(\langle G_1^{*}, G_2^{*}\rangle \) of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph is a cycle and such that graph \(G_1^*\) has maximum degree 3.

Theorem 5

\({\textsc {OrthoSEFE}\text {-}{2}} \) can be solved in polynomial time for instances whose shared graph is a cycle and whose union graph has maximum degree 5.

5 Shared Graph is Biconnected

We now study \({\textsc {OrthoSEFE}\text {-}{k}} \) for instances whose shared graph is biconnected. In Theorem 6, we give a polynomial-time Turing reduction from instances of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph is biconnected to instances whose shared graph is a cycle. In Theorem 7, we give an algorithm that, given a positive instance of \({\textsc {OrthoSEFE}\text {-}{k}} \) such that the shared graph is biconnected together with a SEFE satisfying the orthogonality constraints, constructs an OrthoSEFE with at most three bends per edge.

We start with the Turing reduction, i.e., we develop an algorithm that takes as input an instance \(\langle G_1^{}, G_2^{}\rangle \) of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph \(G_\cap = G_1 \cap G_2\) is biconnected and produces a set of O(n) instances \(\langle G_1^{1}, G_2^{1}\rangle \),...,\(\langle G_1^{h}, G_2^{h}\rangle \) of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graphs are cycles. The output is such that \(\langle G_1^{}, G_2^{}\rangle \) is a positive instance if and only if all instances \(\langle G_1^{i}, G_2^{i}\rangle \), \(i=1,\dots ,h\), are positive. The reduction is based on the SEFE testing algorithm for instances whose shared graph is biconnected by Bläsius et al. [9, 10], which can be seen as a generalized and unrooted version of the one by Angelini et al. [4].

We first describe a preprocessing step. Afterwards, we give an outline of the approach of Bläsius et al. [10] and present the Turing reduction in two steps. We assume familiarity with SPQR-trees [15, 16]; for formal definitions, see [1].

Lemma 4

Let \(\langle G_1^{}, G_2^{}\rangle \) be an instance of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph is biconnected. It is possible to construct in polynomial time an equivalent instance \(\langle G_1^{*}, G_2^{*}\rangle \) whose shared graph is biconnected and such that each endpoint of an exclusive edge has degree 2 in the shared graph.

We continue with a brief outline of the algorithm by Bläsius et al. [10]. First, the algorithm computes the SPQR-tree \(\mathcal T\) of the shared graph. To avoid special cases, \(\mathcal T\) is augmented by adding S-nodes with only two virtual edges such that each P-node and each R-node is adjacent only to S-nodes and Q-nodes. Then, necessary conditions on the embeddings of P-nodes and R-nodes are fixed up to a flip following some necessary conditions. Afterwards, by traversing all S-nodes, a global 2SAT formula is produced whose satisfying assignments correspond to choices of the flips that result in a SEFE. We refine this approach and show that we can choose the flips independently for each S-node, which allows us to reduce each of them to a separate instance, whose shared graph is a cycle.

We now describe the algorithm of Bläsius et al. [10] in more detail. Consider a node \(\mu \) of \(\mathcal T\). A part of \({{\mathrm{skel}}}(\mu )\) is either a vertex of \({{\mathrm{skel}}}(\mu )\) or a virtual edge of \({{\mathrm{skel}}}(\mu )\), which represents a subgraph of G. An exclusive edge e has an attachment in a part x of \({{\mathrm{skel}}}(\mu )\) if x is a vertex that is an endpoint of e or if x is a virtual edge whose corresponding subgraph contains an endpoint of e. An exclusive edge e of \(G_1\) or of \(G_2\) is important for \(\mu \) if its endpoints are in different parts of \({{\mathrm{skel}}}(\mu )\). It is not hard to see that, to obtain a SEFE, the embedding of the skeleton \({{\mathrm{skel}}}(\mu )\) of each node \(\mu \) has to be chosen such that for each exclusive edge e the parts containing the attachments of e share a face. It can be shown that any embedding choice for P-nodes and R-nodes that satisfies these conditions can, after possibly flipping it, be used to obtain a SEFE [4, Theorem 1]. The proof does not modify the order of exclusive edges around degree-2 vertices of \(G_\cap \), and therefore applies to \({\textsc {OrthoSEFE}\text {-}{2}} \) as well.

Now, let \(\mu \) be an S-node. Let \(\varepsilon \) be a virtual edge of \({{\mathrm{skel}}}(\mu )\), \(G_\varepsilon \) be the subgraph represented by \(\varepsilon \), and \(\nu \) be the corresponding neighbor of \(\mu \) in the SPQR-tree of G. An attachment of \(\nu \) with respect to \(\mu \) is an interior vertex of \(G_\varepsilon \) that is incident to an important edge e for \(\mu \). If \(\nu \) has such an attachment, then it is a P- or R-node. It is a necessary condition on the embedding of \(G_\varepsilon \) that each attachment x with respect to \(\mu \) must be incident to a face incident to the virtual edge \({{\mathrm{twin}}}(\varepsilon )\) of \({{\mathrm{skel}}}(\nu )\) representing \(\mu \), and that their clockwise circular order together with the poles of \(\varepsilon \) is fixed up to reversal [10, Lemma 8].

For the purpose of avoiding crossings in \({{\mathrm{skel}}}(\mu )\), we can thus replace each virtual edge \(\varepsilon \) that does not represent a Q-node by a cycle \(C_\varepsilon \) containing the attachments of \(\varepsilon \) with respect to \(\mu \) and the poles of \(\varepsilon \) in the order \(O_\varepsilon \). We keep only the important edges of \(\mu \). Altogether, this results in an instance \(\langle G_1^{\mu }, G_2^{\mu }\rangle \) of SEFE modeling the requirements for \({{\mathrm{skel}}}(\mu )\); see Figs. 6(a) and 6(b).

Fig. 6.
figure 6

(a) Skeleton of an S-node \(\mu \) in which the R-node \(\nu \) corresponding to the virtual edge \(\varepsilon = (u,v)\) is expanded to show its skeleton. (b) Replacing \(\varepsilon \) with cycle \(C_\varepsilon \). (c) Replacing \(C_\varepsilon \) with path \(P_\varepsilon \); vertices \(a_1,a_2,x_1,\dots ,x_4,b_1,b_2\) are green boxes. (Color figure online)

Lemma 5

Let \(\langle G_1^{}, G_2^{}\rangle \) be an instance of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph is biconnected. Then \(\langle G_1^{}, G_2^{}\rangle \) admits an OrthoSEFE if and only if all instances \(\langle G_1^{\mu }, G_2^{\mu }\rangle \) admit an OrthoSEFE.

Next, we transform a given instance \(\langle G_1^{\mu }, G_2^{\mu }\rangle \) of \({\textsc {OrthoSEFE}\text {-}{2}} \) as above into an equivalent instance \(\langle \overline{G_1^{\mu }}, \overline{G_2^{\mu }}\rangle \) whose shared graph is a cycle. Let \(C_{\varepsilon _i}\) be the cycles corresponding to the neighbor \(\nu _i\), \(i=1,\dots ,k\) of \(\mu \) in \(\langle G_1^{\mu }, G_2^{\mu }\rangle \). To obtain the instance \(\langle \overline{G_1^{\mu }}, \overline{G_2^{\mu }}\rangle \), we replace each cycle \(C_{\varepsilon _i}\) with poles u and v by a path \(P_{\varepsilon _i}\) from u to v that first contains two special vertices \(a_1,a_2\) followed by the clockwise path from u to v (excluding the endpoints), then four special vertices \(x_1,\dots ,x_4\), then the counterclockwise path from u to v (excluding the endpoints), and finally two special vertices \(b_1,b_2\) followed by v. In addition to the existing exclusive edges (note that we do not remove any vertices), we add to \(G_1\) the exclusive edges \((a_2,x_3)\), \((x_1,x_3)\), \((x_2,x_4)\), \((x_2,b_1)\), and to \(G_2\) the exclusive edges \((a_1,x_3)\) and \((x_2,b_2)\) to \(G_2\); see Fig. 6(c).

The above reduction together with the next lemma implies the main result.

Lemma 6

\(\langle G_1^{\mu }, G_2^{\mu }\rangle \) admits an OrthoSEFE if and only if \(\langle \overline{G_1^{\mu }}, \overline{G_2^{\mu }}\rangle \) does.

Theorem 6

\({\textsc {OrthoSEFE}\text {-}{2}} \) when the shared graph is biconnected is polynomial-time Turing reducible to \({\textsc {OrthoSEFE}\text {-}{2}} \) when the shared graph is a cycle. Also, the reduction does not increase the maximum degree of the union graph.

Corollary 1

\({\textsc {OrthoSEFE}\text {-}{2}} \) can be solved in polynomial time for instances whose shared graph is biconnected and whose union graph has maximum degree 5.

Observe that, from the previous results, it is not hard to also obtain a SEFE satisfying the orthogonality constraints, if it exists. We show how to construct an orthogonal geometric realizations of such a SEFE.

Theorem 7

Let \(\langle G_1^{}, \dots , G_k^{}\rangle \) be a positive instance of \({\textsc {OrthoSEFE}\text {-}{k}} \) whose shared graph is biconnected. Then, there exists an OrthoSEFE \(\langle \varGamma _1^{}, \varGamma _2^{}, \dots , \varGamma _k^{}\rangle \) of \(\langle G_1^{}, \dots , G_k^{}\rangle \) in which every edge has at most three bends.

Fig. 7.
figure 7

Constructing a drawing with at most three bends per edge. (Color figure online)

Proof sketch

We assume that a SEFE satisfying the orthogonality constraints is given. We adopt the method of Biedl and Kant [8]. We draw the vertices with increasing y-coordinates with respect to an s-t-ordering [14] \(v_1,\dots ,v_n\) on the shared graph. We choose the face to the left of \((v_1,v_n)\) as the outer face of the union graph. The edges will bend at most on y-coordinates near their incident vertices and are drawn vertically otherwise. Figure 7 indicates how the ports are assigned. We make sure that an edge may only leave a vertex to the bottom if it is incident to \(v_n\) or to a neighbor with a lower index. Thus, there are exactly three bends on \(\{v_1,v_n\}\). Any other edge \(\{v_i,v_j\}\), \(1 \le i < j \le n\) has at most one bend around \(v_i\) and at most two bends around \(v_j\).    \(\square \)

6 Conclusions and Future Work

In this work, we introduced and studied the problem \({\textsc {OrthoSEFE}\text {-}{k}} \) of realizing a SEFE in the orthogonal drawing style. While the problem is already NP-hard even for instances that can be efficiently tested for a SEFE, we presented a polynomial-time testing algorithm for instances consisting of two graphs whose shared graph is biconnected and whose union graph has maximum degree 5. We have also shown that any positive instance whose shared graph is biconnected can be realized with at most three bends per edge.

We conclude the paper by presenting a lemma that, together with Theorem 6, shows that it suffices to only focus on a restricted family of instances to solve the problem for all instances whose shared graph is biconnected.

Lemma 7

Let \(\langle G_1^{}, G_2^{}\rangle \) be an instance of \({\textsc {OrthoSEFE}\text {-}{2}} \) whose shared graph \(G_\cap \) is a cycle. An equivalent instance \(\langle G_1^{*}, G_2^{*}\rangle \) of \({\textsc {OrthoSEFE}\text {-}{2}} \) such that (i) the shared graph \(G_\cap ^*\) is a cycle, (ii) graph \(G_1^*\) is outerplanar, and (iii) no two degree-4 vertices in \(G_1^*\) are adjacent, can be constructed in polynomial time.