1 Introduction

Given a planar 4-graph G (i.e., a planar graph with vertex-degree at most four), a planar orthogonal drawing of G is a crossing-free drawing that maps each vertex of G to a distinct point of the plane and each edge of G to a polygonal chain consisting of horizontal and vertical segments [4, 12, 15, 17]. A bend is a point where a vertical and a horizontal segment of the same edge meet; see Fig. 1a, b, where bends are depicted as ‘\(\times \)’. Computing planar orthogonal drawings of planar graphs with the minimum number bends is one of the most studied problems in Graph Drawing. Garg and Tamassia [14] proved that this problem is NP-hard for general planar 4-graphs if the algorithm can freely choose the planar embedding; an O(n)-time algorithm exists for n-vertex planar 3-graphs [10] and an \(O(n^3 \log ^2 n)\)-time algorithm exists for n-vertex series–parallel 4-graphs [6].

If G is a plane 4-graph, i.e., it has a planar embedding that the drawing algorithm must preserve, the problem is polynomial-time solvable. A seminal paper by Tamassia [21] describes an \(O(n^2 \log n)\)-time algorithm based on an elegant min-cost flow-network model. Cornelsen and Karrenbauer [2] reduced the time complexity to \(O(n^{1.5})\), through a more efficient min-cost flow-network technique. Deciding whether there exists an (optimal) O(n)-time algorithm is a longstanding question that is still unanswered (see, e.g., [1, 4, 7]).

Fig. 1
figure 1

a A series–parallel graph G with a given planar embedding. b A bend-minimum orthogonal drawing H of G with 5 bends, represented by cross vertices. c The SPQ\(^*\)-tree T of G with reference edge \(e=(1,11)\); series and parallel compositions are represented by S- and P-nodes; a Q\(^*\)-node represents an edge or a series of edges; the root P\(^r\)-node is a parallel composition between e and the rest of the graph. d Three suboptimal orthogonal drawings obtained by distributing the same number of bends of the highlighted subgraph \(G_{\nu _3}\) in a different way

Contribution. In this paper we positively answer the question above for series–parallel graphs, which are a classical subject of investigation in Graph Drawing and Graph Algorithms (see, e.g., [4, 20, 22, 23]). Namely, we give an O(n)-time algorithm that receives as input an n-vertex plane series–parallel 4-graph G and that computes an embedding-preserving orthogonal drawing of G with the minimum number of bends. While O(n)-time algorithms that compute bend-minimum orthogonal drawings of plane graphs with maximum vertex-degree three are known (see, e.g., [17,18,19]), our result is the first linear-time algorithm for a graph family with vertices of degree four. Indeed, even for series–parallel plane graphs with degree-4 vertices, the most efficient solution known to date is the \(O(n^{1.5})\)-time algorithm by Cornelsen and Karrenbauer [2].

Different from the approach of Cornelsen and Karrenbauer we do not use network-flow techniques to minimize the number of bends. Instead, we rely on the observation that the bend-minimization problem for an orthogonal drawing of a plane graph G is equivalent to inserting in G the minimum number of subdivision vertices that make it rectilinear planar, i.e., drawable without bends. Following this idea, we first characterize those series–parallel graphs that are rectilinear planar. The characterization is expressed in terms of the “orthogonal spirality” for the triconnected components of G. Informally speaking, the orthogonal spirality of a component in an orthogonal drawing of G measures how much the component is “rolled-up” (see, e.g., [5, 9,10,11, 13]). We then consider the problem of efficiently adding the minimum number of subdivision vertices along the edges of those series–parallel graphs that are not rectilinear planar.

In a nutshell, our bend-minimization algorithm executes a post-order visit of a series–parallel decomposition tree T of the input graph G, also called SPQ\(^*\)-tree. Tree T represents the parallel and the series compositions that form G (see Fig. 1a, c, and refer to Sect. 2 for a formal definition of SPQ\(^*\)-trees). Suppose that \(\nu \) is a node of T and \(G_\nu \) its corresponding subgraph in G. When the algorithm visits \(\nu \), it must efficiently determine whether \(G_\nu \) is rectilinear planar and, if not, it must compute the minimum number of subdivision vertices needed to make it rectilinear planar; how to efficiently compute such a number is a first key ingredient of our approach.

A second key ingredient is proving that, when the algorithm processes a node \(\nu \) in the bottom-up visit, the addition of the minimum number of subdivision vertices that make \(G_\nu \) rectilinear planar leads to the optimum in terms of total number of bends.

As a third key ingredient, the algorithm needs to concisely describe the set of rectilinear drawings of \(G_\nu \) that can be obtained by distributing these subdivision vertices in all possible ways along the edges of \(G_\nu \), which gives rise to a combinatorial explosion of different possibilities. Indeed, different distributions of the same set of subdivision vertices along the edges of \(G_\nu \) can lead to orthogonal drawings of G that have different number of bends. For example, consider the highlighted subgraph \(G_{\nu _3}\) (associated with node \(\nu _3\) of T) in the graph of Fig. 1a. Any orthogonal drawing of \(G_{\nu _3}\) requires at least three bends (subdivision vertices); placing all of them on edge (2, 11) yields the optimal solution of Fig. 1b, which additionally requires two bends on edge (1, 11). Conversely, placing the three bends on a different subset of edges of \(G_{\nu _3}\) leads to (suboptimal) solutions with more bends; see Fig. 1d. To efficiently handle the combinatorially many distributions of the subdivision vertices along the edges of a subgraph \(G_\nu \), we succinctly encode in O(1) space the “orthogonal shapes” that \(G_\nu \) can have in a bend-minimum planar orthogonal drawing of G. This is done by looking at the set of possible orthogonal spirality values that \(G_\nu \) can take in such a drawing.

The remainder of the paper is organized as follows. Section 2 recalls basic definitions used throughout the paper. Section 3 strengthens a result given in [5] about the interchangeability of orthogonal representations with the same spirality. Section 4 characterizes those plane series–parallel graphs that are rectilinear planar. Section 5 gives an overview of our bend-minimization algorithm. Section 6 provides details about the bottom-up visit performed by the algorithm. Section 7 summarizes our main result. Concluding remarks and open problems are in Sect. 8.

Some of our proofs are based on case analyses; in some proofs, we moved part of the case analysis to the paper appendix, when the analysis of a case resulted similar to the analysis of a previous case; also, the appendix reports a glossary of the main symbols used throughout the paper.

2 Preliminaries

We assume familiarity with basic concepts of graph planarity and graph drawing [4, 15,16,17]. We only deal with connected graphs and we focus on orthogonal representations rather than orthogonal drawings. An orthogonal representation H of a planar graph G describes a class of equivalent planar orthogonal drawings of G in terms of planar embedding, ordered sequence of bends along the edges (i.e., sequence of left/right turns going from an end-vertex to the other) and clockwise sequence of geometric angles at each vertex, each angle formed by two (possibly coincident) consecutive edges around the vertex and expressed as a value in the set \(\{90^\circ ,180^\circ ,270^\circ ,360^\circ \}\) (angles of \(360^\circ \) occur only at degree-1 vertices). An orthogonal representation H of G can be described by a planar embedding of G plus an angle labeling specifying: (i) for each vertex v of G, the geometric angles at v; (ii) for each edge \(e=(u,v)\) of G, the ordered sequence of bends along e as a sequence of angles in the left face (and hence in the right face) of e while moving along e from u to v (each bend determines an angle of \(90^\circ \) in one of the two faces incident to e and an angle of \(270^\circ \) in the other face). It is well known (see, e.g., [3]) that an angle labeling of G describes a valid orthogonal representation if and only if the following properties hold: (H1) for each vertex v, the sum of the angles at v equals \(360^\circ \); (H2) for each face f, if \(N_a(f)\) is the number of \(a^\circ \) angles in f, we have \(N_{90}(f)-N_{270}(f)-2N_{360}(f)=4\) (resp. \(N_{90}(f)-N_{270}(f)-2N_{360(f)}=-4\)) if f is an internal face (resp. the external face).

Note that, since the set of faces of a plane graph G is a base for the set of simple cycles of G, Properties (H1) and (H2) together are equivalent to say that for every simple cycle C of G, the number of right turns minus the number of left turns, when walking clockwise around the boundary of C, is equal to four. Namely, if v is a vertex of C we count: a right turn at v if there is an angle of \(90^\circ \) at v inside C; a left turn at v if the sum of the angles at v inside C equals \(270^\circ \); two left turns at v if v has degree one. Also, a bend on an edge of C corresponds to a right (resp. left) turn if it determines an angle of \(90^\circ \) (resp., \(270^\circ \)) in C.

Given an orthogonal representation H of a plane graph G, a drawing of H (which corresponds to an orthogonal drawing of G) can be computed in linear time [21]. If H has no bend, H is a rectilinear representation.

Series–parallel graphs and decomposition trees. A two-terminal series–parallel graph G, also called series–parallel graph, has two distinct vertices s and t, called the source and the sink of G, respectively. A series–parallel graph can be inductively defined by, and naturally associated with, a decomposition tree T: (i) a single edge (st) is a series–parallel graph with source s and sink t, in which case T consists of a single Q-node, whose poles are s and t; (ii) given \(p \ge 2\) series–parallel graphs \(G_1, \dots , G_p\), each \(G_i\) with source \(s_i\) and sink \(t_i\) (\(i=1, \dots , p\)), a new series–parallel graph G can be obtained with any of these two operations:

- Series composition, which identifies \(t_i\) with \(s_{i+1}\) (\(i=1,\dots ,p-1\)); G has source \(s=s_1\) and sink \(t=t_p\). The composition is represented in T by an S-node, with poles \(s_1\) and \(t_p\), whose children are the roots of the decomposition trees \(T_i\) of \(G_i\) (\(i=1, \dots , p\)).

- Parallel composition, which identifies all sources \(s_i\) (resp. all sinks \(t_i\)) together (\(i=1, \dots , p\)); G has source \(s=s_i\) and sink \(t=t_i\). The composition is represented in T by a P-node, with poles are s and t, whose children are the roots of the decomposition trees \(T_i\) of \(G_i\) (\(i=1, \dots , p\)).

In our algorithm we do not distinguish between Q-nodes and S-nodes whose children are all Q-nodes. We just call any of these nodes a Q\(^*\)-node. In other words, a Q\(^*\)-node represents a series of edges. For a node \(\nu \) of T, the pertinent graph \(G_\nu \) of \(\nu \) is the subgraph of G formed by all edges associated with the Q\(^*\)-nodes in the subtree rooted at \(\nu \). We also call \(G_\nu \) a component of G.

Let G be a plane (two-terminal) series–parallel graph with vertex-degree at most four. Note that G is either biconnected or it can be made biconnected with the addition of a single dummy edge; in this latter case we assume that the planar embedding of G is such that the dummy edge can be added on the external face of G. For any edge \(e=(s,t)\) (possibly a dummy edge) on the external face, we can associate with G a decomposition tree T where the root is a P-node representing the parallel composition between e and the rest of the graph. Thus, the root of T is always a P-node with two children, one of which is a Q\(^*\)-node corresponding to e. It will be called the (unique) P\(^r\)-node of T, to distinguish it by the other P-nodes. Edge e is the reference edge of T, and T is the SPQ\(^*\)-tree of G with respect to e. Without loss of generality we assume that the external face of G is to the right of e while moving from s to t. Also, it is always possible to make T such that each (non-root) P-node has no P-node child and each S-node has no S-node child. Since G has vertex-degree at most four, a P-node has either two or three children. Finally, we assume that the left-to-right order of the children of a P-node reflects the left-to-right order that their corresponding components have in the planar embedding of G. See Fig. 1a, c. From now on we assume that T satisfies the properties above for an n-vertex biconnected series–parallel graph. Observe that the number of nodes of T is O(n).

Spirality of series–parallel graphs. Let G be a biconnected plane series–parallel graph and let T be an SPQ\(^*\)-tree with respect to a reference edge \(e=(s,t)\). Let H be an (embedding-preserving) orthogonal representation of G. Also, let \(\nu \) be a node of T with poles \(\{u,v\}\) and let \(H_\nu \) be the restriction of H to \(G_\nu \). We also say that \(H_\nu \) is a component of H. For each pole \(w \in \{u,v\}\), let \(\textrm{indeg} _\nu (w)\) and \(\textrm{outdeg} _\nu (w)\) be the degree of w inside and outside \(H_\nu \), respectively. Define two (possibly coincident) alias vertices of w, denoted by \(w'\) and \(w''\), as follows: (i) if \(\textrm{indeg} _\nu (w)=1\), then \(w'=w''=w\); (ii) if \(\textrm{indeg} _\nu (w)=\textrm{outdeg} _\nu (w)=2\), then \(w'\) and \(w''\) are dummy vertices, each splitting one of the two distinct edge segments incident to w outside \(H_\nu \); (iii) if \(\textrm{indeg} _\nu (w)>1\) and \(\textrm{outdeg} _\nu (w)=1\), then \(w'=w''\) is a dummy vertex that splits the edge segment incident to w outside \(H_\nu \).

Fig. 2
figure 2

The components associated with the P-nodes \(\nu _1\), \(\nu _3\), and \(\nu _5\), of the graph in Fig. 1. The alias vertices are the little squares along dashed edges. For each node \(\nu _i\), \(i\in \{1,3,5\}\), we report \(G_{\nu _i}\), \(H_{\nu _i}\), and the spirality \(\sigma _{\nu _i}\) of \(H_{\nu _i}\) in H. In particular, the P-component of \(\nu _3\), with poles \(\{u=2, v=11\}\), has spirality \(\frac{5}{2}\); the P-component of \(\nu _{5}\), with poles \(\{u=1, v=11\}\), has spirality 2

Let \(A^w\) be the set of distinct alias vertices of a pole w. Let \(P^{uv}\) be any simple path from u to v inside \(H_\nu \) and let \(u'\) and \(v'\) be an alias vertex of u and an alias vertex of v, respectively. The path \(S^{u'v'}\) obtained concatenating \((u',u)\), \(P^{uv}\), and \((v,v')\) is called a spine of \(H_\nu \). Denote by \(n(S^{u'v'})\) the number of right turns minus the number of left turns encountered along \(S^{u'v'}\) while moving from \(u'\) to \(v'\). The spirality \(\sigma (H_\nu )\) of \(H_\nu \) is introduced by Di Battista et al. [5] and it is defined based on the following cases (see also Fig. 2 for the spirality values of some P-components in the representation H of Fig. 1b):

  • \(A^u=\{u'\}\) and \(A^v=\{v'\}\); then \(\sigma (H_\nu ) = n(S^{u'v'})\).

  • \(A^u=\{u'\}\) and \(A^v=\{v',v''\}\); then \(\sigma (H_\nu ) = \frac{n(S^{u'v'}) + n(S^{u'v''})}{2}\).

  • \(A^u=\{u',u''\}\) and \(A^v=\{v'\}\); then \(\sigma (H_\nu ) = \frac{n(S^{u'v'}) + n(S^{u''v'})}{2}\).

  • \(A^u=\{u',u''\}\) and \(A^v=\{v',v''\}\); without loss of generality, assume that \((u,u')\) precedes \((u,u'')\) counterclockwise around u and that \((v,v')\) precedes \((v,v'')\) clockwise around v; then \(\sigma (H_\nu ) = \frac{n(S^{u'v'}) + n(S^{u''v''})}{2}\).

Di Battista et al. [5] show that the spirality of \(H_\nu \) does not vary with the choice of the path \(P^{uv}\). For brevity, in the following we often denote by \(\sigma _\nu \) the spirality of an orthogonal representation \(H_\nu \) of \(G_\nu \). If \(\nu \) is a Q\(^*\)-node or a P-node with three children, \(\sigma _\nu \) is always an integer. If \(\nu \) is an S-node or a P-node with two children, \(\sigma _\nu \) is either integer or semi-integer depending on whether the total number of alias vertices for the poles of \(\nu \) is even or odd. When we say that the spirality \(\sigma _\nu \) can take all values in an interval [ab], we mean that such values are either all the integer numbers or all the semi-integer numbers in [ab], depending on the cases described above for \(\nu \).

3 Substituting Orthogonal Components with the Same Spirality

Let G be a biconnected plane series–parallel graph and let T be an SPQ\(^*\)-tree of G with respect to a given reference edge. Di Battista et al. [5] prove that two distinct orthogonal representations of the same component \(G_\nu \) that have the same spirality are “interchangeable”, under some additional hypotheses. Roughly speaking, they prove that if a component \(H_\nu \) has a certain spirality in a given orthogonal representation H, it can be substituted with another representation \(H'_\nu \) having the same spirality, under the assumption that the angles at the poles of \(\nu \) that are outside \(G_\nu \) do not change. In this subsection we formalize the concept of substituting an orthogonal component with another one and give a stronger version of the result in [5], which proves the interchangeability of two orthogonal components that have the same spirality, regardless of their angles at the poles.

Let H and \(H'\) be two different orthogonal representations of G with the reference edge on the external face, and let \(H_\nu \) and \(H'_\nu \) be the restrictions of H and \(H'\) to \(G_\nu \), respectively. If \(\sigma (H_\nu )=\sigma (H'_\nu )\), the operation of substituting \(H_\nu \) with \(H'_\nu \) in H, denoted by \(\textrm{Sub} (H_\nu , H'_\nu )\), defines a new plane graph \(H''\) with an angle labeling, such that: (a) \(H''\) corresponds to a valid orthogonal representation of G; (b) the restriction of \(H''\) to \(G_\nu \) coincides with \(H'_\nu \); (c) the restriction of \(H''\) to \(G \setminus G_\nu \) stays as in H.

More formally, let u and v be the two poles of \(\nu \). The external boundary of \(H_\nu \) contains a left path \(p_l\) and a right path \(p_r\), such that \(p_l\) goes from u to v while traversing the external boundary of \(H_\nu \) clockwise and \(p_r\) goes from u to v while traversing the external boundary of \(H_\nu \) counterclockwise. Denote by \(f_l\) the face of H outside \(H_\nu \) and incident to \(p_l\), and denote by \(f_r\) the face of H outside \(H_\nu \) and incident to \(p_r\). Also, for each pole \(w \in \{u,v\}\) of \(\nu \), denote by \(a_{w,l}\) (resp. \(a_{w,r}\)) the angle at w in face \(f_l\) (resp. \(f_r\)) of H. Similarly, with respect to \(H'_\nu \) and \(H'\), define \(p'_l\), \(p'_r\), \(f'_l\), \(f'_r\), and \(a'_{w,l}\), \(a'_{w,r}\) for each pole \(w \in \{u,v\}\). The operation \(\textrm{Sub} (H_\nu , H'_\nu )\) defines \(H''\) as follows (schematic illustrations are given in Figs. 3, 4, 5):

  • The set of vertices and the set of edges of \(H''\) are the same as in G.

  • The planar embedding of \(H''\) is such that: all faces of H outside \(H_\nu \) and distinct from \(f_l\) and \(f_r\), as well as all faces of \(H'_\nu \), are also faces of \(H''\). Also, \(H''\) has two faces \(f''_l\) and \(f''_r\) obtained by replacing \(p_l\) with \(p'_l\) and \(p_r\) with \(p'_r\) in the boundary of \(f_l\) and \(f_r\), respectively.

  • The angle labeling of \(H''\) is such that: (i) all the angles at the vertices and along the edges of G not belonging to \(G_\nu \) are those in H; (ii) all the angles at the vertices of \(G_\nu \) distinct from u and v are those in \(H'_\nu \); (iii) all the angles along the edges of \(G_\nu \) are those in \(H'_\nu \); (iv) for each pole \(w \in \{u,v\}\) of \(\nu \), the angles at w that are outside \(G_\nu \) and that are neither in \(f''_l\) nor in \(f''_r\) are those in H; the angles at w that are inside \(G_\nu \) are those in \(H'_\nu \); the angle \(a''_{w,l}\) at w in \(f''_l\) and the angle \(a''_{w,r}\) at w in \(f''_r\) are such that \(a''_{w,l}=a_{w,l}\) and \(a''_{w,r}=a_{w,r}\) if \(\textrm{indeg} _\nu (w)=1\), while \(a''_{w,l}=a'_{w,l}\) and \(a''_{w,r}=a'_{w,r}\) if \(\textrm{indeg} _\nu (w)>1\).

The next theorem proves that \(H''\) is a valid orthogonal representation.

Theorem 1

Let G be a biconnected series–parallel 4-graph, T be an SPQ\(^*\)-tree of G with respect to a reference edge e, and \(\nu \) be a non-root node of T. Let H and \(H'\) be two different orthogonal representations of G with e on the external face, and let \(H_\nu \) and \(H'_\nu \) be the restrictions of H and \(H'\) to \(G_\nu \), respectively. If \(\sigma (H_\nu )=\sigma (H'_\nu )\) then the graph \(H''\) defined by \(\textrm{Sub} (H_\nu ,H'_\nu )\) is an orthogonal representation of G.

Proof

We have to show that the embedded labeled graph \(H''\) defined by \(\textrm{Sub} (H_\nu ,H'_\nu )\) satisfies Properties (H1) and (H2) of an orthogonal representation. Clearly, since H and \(H'\) are orthogonal representations, (H1) holds for all vertices of \(H''\) distinct from the poles \(\{u,v\}\) of \(G_\nu \); indeed, each vertex distinct from u and v inherits all its angles either from H or from \(H'\). Analogously, each face of \(H''\) distinct from \(f''_l\) and \(f''_r\) is either a face of H or a face of \(H'\), thus its angles satisfy Property (H2).

It remains to show that (H1) holds for u and v, and that (H2) holds for \(f''_l\) and \(f''_r\). To this aim, we analyze different cases based on the indegree of the two poles \(\{u,v\}\) of \(G_\nu \).

Case 1: \(\textrm{indeg} _\nu (u)=1\) and \(\textrm{indeg} _\nu (v)=1\). Refer to Fig. 3. In this case, the alias vertices \(u'\) and \(v'\), associated with u and v respectively, coincide with the poles, i.e., \(u = u'\) and \(v = v'\). Let \({\overline{ux}}\) and \({\overline{yv}}\) be the two edge segments of \(H_\nu \) incident to u and to v, respectively. Analogously, let \(\overline{ux'}\) and \(\overline{y'v}\) be the two edge segments of \(H'_\nu \) incident to u and to v, respectively. Without loss of generality, assume that H and \(H'\) are oriented in such a way that both \({\overline{ux}}\) and \(\overline{ux'}\) are vertical segments and that u is below x in any drawing of H and u is below \(x'\) in any drawing of \(H'\). By definition, since \(u = u'\) and \(v = v'\), the spirality \(\sigma (H_\nu )\) (resp. \(\sigma (H'_\nu )\)) equals the number of right turns minus the number of left turns while moving from u to v along any simple path of \(H_\nu \) (resp. of \(H'_\nu \)). Hence, since by hypothesis \(\sigma (H_\nu ) = \sigma (H'_\nu )\), the edge segments \({\overline{yv}}\) and \(\overline{y'v}\) are either both horizontal or both vertical, and more precisely they are incident to v in H and to v in \(H'\) from the same side (south, north, west, or east). In this case, \(\textrm{Sub} (H_\nu ,H'_\nu )\) defines \(a''_{u,l}=a_{u,l}\), \(a''_{u,r}=a_{u,r}\), \(a''_{v,l}=a_{v,l}\), and \(a''_{v,r}=a_{v,r}\), which implies that all the angles around u and v in \(H''\) coincide with the angles around u and v in H. Hence, Property (H1) holds for both u and v in \(H''\). Also, let \(n(p_l)\) (resp. \(n(p_r)\)) be the number of right turns minus the number of left turns along \(p_l\) (resp. \(p_r\)) while moving from u to v in H. Similarly, let \(n(p'_l)\) (resp. \(n(p'_r)\)) be the number of right turns minus the number of left turns along \(p'_l\) (resp. \(p'_r\)) while moving from u to v in \(H'\). Since \(\sigma (H_\nu ) = \sigma (H'_\nu )\), and since \(u=u'\) and \(v=v'\), we have \(n(p_l)=n(p'_l)\) and \(n(p_r)=n(p'_r)\). It follows that \(N_{90}(f''_l)-N_{270}(f''_l)=N_{90}(f_l)-N_{270}(f_l)\) and \(N_{90}(f''_r)-N_{270}(f''_r)=N_{90}(f_r)-N_{270}(f_r)\), which imply Property (H2) for \(f''_l\) and \(f''_r\) (note that, since G is biconnected, \(N_{360}(f)=0\) for every face f of H and of \(H'\)).

Fig. 3
figure 3

Case 1 of Theorem 1: schematic illustration of the graph \(H''\) defined by \(\textrm{Sub} (H_\nu ,H'_\nu )\)

Case 2: \(\textrm{indeg} _\nu (u)=1\) and \(\textrm{indeg} _\nu (v)>1\). We distinguish two subcases: \(\textrm{outdeg} _\nu (v) = 1\) or \(\textrm{outdeg} _\nu (v)=2\). Assume first that \(\textrm{outdeg} _\nu (v) = 1\) (see Fig. 4a). In this case, u and its alias vertex \(u'\) coincide and the only alias vertex \(v'\) associated with v subdivides the edge segment incident to v in H and in \(H'\). As in the analysis of Case 1, assume that H and \(H'\) are oriented so that each of the two edge segments \({\overline{ux}}\) and \(\overline{ux'}\) in H and in \(H'\), respectively, is incident to u from north. By definition, the spirality \(\sigma (H_\nu )\) (resp. \(\sigma (H'_\nu )\)) in this case equals the number of right turns minus the number of left turns along any simple path of \(H_\nu \) (resp. of \(H'_\nu \)) from u to \(v'\). Since \(\sigma (H_\nu )=\sigma (H'_\nu )\), this implies that the segments \(\overline{vv'}\) in H and \(H'\) are incident to v from the same side. In this case, \(\textrm{Sub} (H_\nu ,H'_\nu )\) defines \(a''_{u,l}=a_{u,l}\), \(a''_{u,r}=a_{u,r}\), \(a''_{v,l}=a'_{v,l}\), and \(a''_{v,r}=a'_{v,r}\), which implies that all the angles around u in \(H''\) coincide with the angles around u and all the angles around v in \(H''\) coincide with those around v in \(H'\). Thus, Property (H1) holds for u and v in \(H''\). It remains to prove  (H2) for \(f''_l\) and \(f''_r\). Denote by \(P_l\) (resp. \(P_r\)) the path of H obtained by concatenating \(p_l\) (resp. \(p_r\)) with the edge segment \(\overline{vv'}\). Analogously, denote by \(P'_l\) (resp. \(P'_r\)) the path of \(H'\) obtained by concatenating \(p'_l\) (resp. \(p'_r\)) with the edge segment \(\overline{vv'}\). Since \(\sigma (H_\nu )=\sigma (H'_\nu )\), with the usual notation we have \(n(P_l) = n(P'_l)\) and \(n(P_r) = n(P'_r)\). Since, as observed above, the segments \(\overline{vv'}\) in H and \(H'\) are incident to v from the same side, and since the angles at u are the same in \(H''\) and in H, we have \(N_{90}(f''_l)-N_{270}(f''_l)=N_{90}(f_l)-N_{270}(f_l)\) and \(N_{90}(f''_r)-N_{270}(f''_r)=N_{90}(f_r)-N_{270}(f_r)\), which imply Property (H2) for \(f''_l\) and \(f''_r\).

Fig. 4
figure 4

Case 2 of Theorem 1: schematic illustration of the graph \(H''\) defined by \(\textrm{Sub} (H_\nu ,H'_\nu )\) when a \(\textrm{outdeg} (v)=1\) and b \(\textrm{outdeg} (v)=2\)

Suppose now that \(\textrm{outdeg} _\nu (v)=2\) (see Fig. 4b). In this case, u and its alias vertex \(u'\) coincide while v has two alias vertices \(v'\) and \(v''\), which subdivides the two edge segments incident to v in H and in \(H'\). Since \(\deg (v)=4\), the angles at v are all \(90^\circ \) degree angles, both in H and in \(H'\). It follows that, the angles at u and v in \(H''\) are the same as in H, i.e., Property (H1) holds. Denote by \(P_l\) (resp. \(P_r\)) the path of H obtained by concatenating \(p_l\) (resp. \(p_r\)) with the edge segment \(\overline{vv'}\) (resp. \(\overline{vv''}\)). Analogously, denote by \(P'_l\) (resp. \(P'_r\)) the path of \(H'\) obtained by concatenating \(p'_l\) (resp. \(p'_r\)) with the edge segment \(\overline{vv'}\) (resp. \(\overline{vv''}\)). Since \(\sigma (H_\nu )=\sigma (H'_\nu )\), we have \(\frac{n(P_l)+n(P_r)}{2} = \frac{n(P'_l)+n(P'_r)}{2}\). On the other hand, since all angles at v are right angles in H and in \(H'\), we have \(n(P_r) = n(P_l) + 1\) and \(n(P'_r) = n(P'_l) + 1\). This implies that \(n(P_l) = n(P'_l)\) and \(n(P_r) = n(P'_r)\), which, together with the fact that the angles at u are the same in H and \(H''\), implies that \(N_{90}(f''_l)-N_{270}(f''_l)=N_{90}(f_l)-N_{270}(f_l)\) and \(N_{90}(f''_r)-N_{270}(f''_r)=N_{90}(f_r)-N_{270}(f_r)\). Hence, Property (H2) holds for \(f''_l\) and \(f''_r\).

Case 3: \(\textrm{indeg} _\nu (u)>1\) and \(\textrm{indeg} _\nu (v)=1\). This case is symmetric to Case 2.

Case 4: \(\textrm{indeg} _\nu (u)>1\) and \(\textrm{indeg} _\nu (v)>1\). In this case, there are three non-symmetric subcases to analyze, depending on the outdegree of u and of v, i.e., \(\textrm{outdeg} _\nu (u)=\textrm{outdeg} _\nu (v)=1\), or \(\textrm{outdeg} _\nu (u)=1\) and \(\textrm{outdeg} _\nu (v)=2\) (symmetrically \(\textrm{outdeg} _\nu (u)=2\) and \(\textrm{outdeg} _\nu (v)=1\)), or \(\textrm{outdeg} _\nu (u)=\textrm{outdeg} _\nu (v)=2\). See “Appendix A” for details and refer to Fig. 5 for a schematic illustration. \(\square \)

Fig. 5
figure 5

Case 4 of Theorem 1: schematic illustration of the graph \(H''\) defined by \(\textrm{Sub} (H_\nu ,H'_\nu )\) when a \(\textrm{outdeg} (u)=\textrm{outdeg} (v)=1\), b \(\textrm{outdeg} (u)=1\) and \(\textrm{outdeg} (v)=2\), and c \(\textrm{outdeg} (u)=\textrm{outdeg} (v)=2\)

Based on Theorem 1, in the following we can assume that two orthogonal components with the same spirality are equivalent, and we can describe the set of possible orthogonal representations for a component in terms of their spirality values.

4 Rectilinear Plane Series–Parallel Graphs

This section characterizes rectilinear plane series–parallel graphs. Let G be a plane series–parallel 4-graph. If G is biconnected let e be any edge on the external face of G; otherwise, we add a dummy edge e that makes it biconnected (recall that, if G is not biconnected we are assuming that the dummy edge e can always be added in the external face). Let T be the SPQ\(^*\)-tree of G with respect to e and let \(\nu \) be a node of T. We say that a component \(G_{\nu }\) admits spirality \(\sigma _\nu \) or, equivalently, that \(\nu \) admits spirality \(\sigma _\nu \), if there exists a rectilinear planar representation \(H_\nu \) of \(G_\nu \) with spirality \(\sigma _\nu \) in some rectilinear planar representation H of G. The following lemmas immediately derive from the results of Di Battista et al. [5], which for any S-node or P-node \(\nu \), relate the values of spirality for an orthogonal representation of \(G_\nu \) to the values of spirality of the orthogonal representations of the child components of \(G_\nu \) (i.e., the components corresponding to the children of \(\nu \)). These types of relationships will be crucial to characterize those components that are rectilinear planar in a bottom-up traversal of T. Namely, Lemma 1 concentrates on S-nodes, Lemma 2 on P-nodes with three children, and Lemma 3 on P-nodes with two children. See also Fig. 6 for an illustration.

Lemma 1

[5] Let \(\nu \) be an S-node of T with children \(\mu _1, \dots , \mu _h\) \((h \ge 2)\). The component \(G_\nu \) admits spirality \(\sigma _\nu \) if and only if \(\sigma _\nu = \sum _{i=1}^{h}\sigma _{\mu _i}\), where \(\sigma _{\mu _i}\) is a spirality value admitted by \(G_{\mu _i}\) \((1 \le i \le h)\).

Lemma 2

[5] Let \(\nu \) be a P-node of T with three children \(\mu _l\), \(\mu _c\), and \(\mu _r\). \(G_{\nu }\) admits spirality \(\sigma _\nu \) with \(G_{\mu _l}\), \(G_{\mu _c}\), \(G_{\mu _r}\) in this left-to-right order if and only if there exist three values \(\sigma _{\mu _l}\), \(\sigma _{\mu _c}\), and \(\sigma _{\mu _r}\) such that: (i) \(G_{\mu _l}\), \(G_{\mu _c}\), \(G_{\mu _r}\) admit spirality \(\sigma _{\mu _l}\), \(\sigma _{\mu _c}\), \(\sigma _{\mu _r}\), respectively; and (ii) \(\sigma _\nu = \sigma _{\mu _l} - 2 = \sigma _{\mu _c} = \sigma _{\mu _r} + 2\).

Fig. 6
figure 6

Illustration of the relationships in: a Lemma 1 for S-nodes, b Lemma 2 for P-nodes with three children, and c Lemma 3 for P-nodes with two children

If \(\nu \) is a P-node with two children, denote by \(\mu _l\) and \(\mu _r\) its left and right child in T, respectively. If \(\nu \) is a P-node with three children, denote by \(\mu _l\), \(\mu _c\), and \(\mu _r\), the three children of \(\nu \) from left to right. Also, for each pole \(w \in \{u,v\}\) of \(\nu \), the leftmost angle at w in H is the angle formed by the leftmost external edge and the leftmost internal edge of \(H_\nu \) incident to w. The rightmost angle at w in H is defined symmetrically. We define two binary variables \(\alpha _w^l\) and \(\alpha _w^r\) as follows: \(\alpha _w^l = 0\) (\(\alpha _w^r = 0\)) if the leftmost (rightmost) angle at w in H is \(180^\circ \), while \(\alpha _w^l = 1\) (\(\alpha _w^r = 1\)) if this angle is \(90^\circ \). Observe that if \(\deg (w)=4\) or if \(\nu \) has three children, \(\alpha _w^l = \alpha _w^r = 1\). Also, if \(\nu \) has two children, define two additional variables \(k_w^l\) and \(k_w^r\) as follows: \(k_w^d = 1\) if \(\textrm{indeg} _{\mu _d}(w)=\textrm{outdeg} _{\nu }(w)=1\), while \(k_{w}^d=1/2\) otherwise, for \(d \in \{l,r\}\). For example, in Fig. 2 the component of \(\nu _3\) is such that \(k_u^l=k_u^r=1\), \(k_v^l =k_v^r=\frac{1}{2}\), \(\alpha _u^l=0\), and \(\alpha _u^r=\alpha _v^l=\alpha _v^r=1\); the component of \(\nu _5\) is such that \(k_u^l=k_u^r=1\), \(k_v^l=\frac{1}{2}\), \(k_v^r=1\), \(\alpha _u^l=0\), and \(\alpha _u^r=\alpha _v^l=\alpha _v^r=1\).

Lemma 3

[5] Let \(\nu \) be a P-node of T with two children \(\mu _l\) and \(\mu _r\), and with poles u and v. \(G_{\nu }\) admits spirality \(\sigma _\nu \) with \(G_{\mu _l}\) and \(G_{\mu _r}\) in this left-to-right order if and only if there exist six values \(\sigma _{\mu _l}\), \(\sigma _{\mu _r}\), \(\alpha _u^l\), \(\alpha _u^r\), \(\alpha _v^l\), and \(\alpha _v^r\) such that: (i) \(G_{\mu _l}\) and \(G_{\mu _r}\) admit spirality \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\), respectively; (ii) \(\alpha _w^l \in \{0,1\}\), \(\alpha _w^r \in \{0,1\}\), and \(1 \le \alpha _w^l+\alpha _w^r \le 2\) for any \(w \in \{u,v\}\); and (iii) \(\sigma _\nu = \sigma _{\mu _l} - k_{u}^l \alpha _{u}^l - k_{v}^l \alpha _{v}^l = \sigma _{\mu _r} + k_{u}^r \alpha _{u}^r + k_{v}^r\alpha _{v}^r\).

In the following we prove a condition under which the plane graph \(G_\nu \) is rectilinear planar, assuming that its child components (if \(\nu \) is not a leaf of T) are rectilinear planar. This condition depends on the type of node \(\nu \) and is referred to as representability condition of \(\nu \) (or, equivalently, of \(G_\nu \)). Also, if the representability condition holds for \(\nu \), we denote by \(I_\nu \) the set of values of spirality for which \(G_\nu \) is rectilinear planar, i.e., \(G_\nu \) admits spirality \(\sigma _\nu \) if and only if \(\sigma _\nu \in I_\nu \). We prove that \(I_\nu \) is always an interval (of all integer or all semi-integer values) and call it the representability interval of \(\nu \) (or, equivalently, of \(G_\nu \)).

4.1 Representability Condition for Q\(^*\)-Nodes and S-Nodes

For a Q\(^*\)-node \(\nu \) representing a chain of \(\ell \) edges, we say that \(\ell \) is the length of \(\nu \). As the next lemmas prove, the components of Q\(^*\)- and S-nodes are always rectilinear planar, i.e., the representability condition is always true.

Lemma 4

Let \(\nu \) be a Q\(^*\)-node of length \(\ell \). Graph \(G_\nu \) is always rectilinear planar (i.e., its representability condition is always true) and its representability interval is \(I_\nu = [-\ell +1, \ell -1]\).

Proof

\(G_\nu \) is a path with \(\ell -1\) degree-2 vertices. For any integer \(k \in [-\ell +1,0]\), a rectilinear planar representation \(H_\nu \) of \(G_\nu \) with spirality k is obtained by making a left turn at k degree-2 vertices of \(G_\nu \) (going from the source to the sink pole), and no turn at any remaining vertex of \(G_\nu \). Symmetrically, for any \(k \in (0,\ell -1]\), we realize \(H_\nu \) with spirality k by making a right turn at exactly k degree-2 vertices of \(G_\nu \). It is clear that no values of spirality out of \(I_\nu \) can be achieved. \(\square \)

Figure 7 illustrates Lemma 4 for a Q\(^*\)-node \(\nu \) of length 4, for which \(I_\nu =[-3,3]\). The figure depicts a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \) for every \(\sigma _\nu \in I_\nu \).

Fig. 7
figure 7

Illustration of Lemma 4. For a \(Q^*\) node \(\nu \) of length 4 we have \(I_\nu =[-3,3]\)

Lemma 5

Let \(\nu \) be an S-node with \(h \ge 2\) children \(\mu _1, \dots , \mu _h\). Suppose that, for every \(i \in [1,h]\), the representability interval of \(G_{\mu _i}\) is \(I_{\mu _i} = [m_i,M_i]\). Graph \(G_\nu \) is always rectilinear planar (i.e., its representability condition is always true) and its representability interval is \(I_\nu = [\sum _{i=1}^hm_i,\sum _{i=1}^hM_i]\).

Proof

We use induction on the number of children of \(\nu \). In the base case \(h=2\). By hypothesis \(I_{\mu _1}=[m_1, M_1]\) and \(I_{\mu _2}=[m_2,M_2]\). By Lemma 1, a series composition of a rectilinear representation of \(G_{\mu _1}\) with spirality \(\sigma _{\mu _1}\) and of a rectilinear representation of \(G_{\mu _2}\) with spirality \(\sigma _{\mu _2}\) results in a rectilinear representation of \(G_\nu \) with spirality \(\sigma _\nu = \sigma _{\mu _1} + \sigma _{\mu _2}\). Hence, if \(M_1 = m_1+r_1\) and \(M_2 = m_2+r_2\), for two non-negative integers \(r_1\) and \(r_2\), then the possible values for \(\sigma _\nu \) are exactly \(m_1+m_2, m_1+1+m_2, \dots , m_1+r_1+m_2, \dots , m_1+r_1+m_2+1, \dots , m_1+r_1+m_2+r_2\), i.e., all values in the interval \([m_1+m_2, M_1+M_2]\). In the inductive case \(h \ge 3\); consider the series composition \(G'_1\) of \(G_{\mu _1}, \dots , G_{\mu _{h-1}}\). Graph \(G_\nu \) is the series composition of \(G'_1\) and \(G_{\mu _h}\). By the inductive hypothesis the representability interval of \(G'_1\) is \([\sum _{i=1}^{h-1}m_i,\sum _{i=1}^{h-1}M_i]\) and by Lemma 1 applied to \(G'_1\) and \(G_{\mu _h}\) we have \(I_\nu = [\sum _{i=1}^hm_i,\sum _{i=1}^hM_i]\), using the same reasoning as for the base case. \(\square \)

Figure 8 illustrates Lemma 5. Figure 8a shows an S-node \(\nu \) and its three children \(\mu _1\), \(\mu _2\), and \(\mu _3\), where \(\mu _1\) and \(\mu _3\) are Q\(^*\)-nodes and \(\mu _2\) is a P-node. Figure 8b shows the components \(G_\nu \), \(G_{\mu _1}\), \(G_{\mu _2}\), and \(G_{\mu _3}\), where: \(I_{\mu _1}=[0,0]\) and \(I_{\mu _3}=[-2,2]\) by Lemma 4; \(I_{\mu _2}=[-1,-1]\), as \(G_{\mu _2}\) only admits a rectilinear planar representation of spirality \(-1\). By Lemma 5, \(I_\nu = [\sum _{i=1}^hm_i,\sum _{i=1}^hM_i]=[0-2-1,0+2-1]=[-3,1]\). Figure 8c depicts a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \) for every \(\sigma _\nu \in I_\nu \).

Fig. 8
figure 8

Illustration of Lemma 5. a An S-node \(\nu \) with children \(\mu _1\), \(\mu _2\), and \(\mu _3\). b The components \(G_\nu \), \(G_{\mu _1}\), \(G_{\mu _2}\), and \(G_{\mu _3}\). Since \(I_{\mu _1}\)=[0, 0], \(I_{\mu _2}\)=\([-1,-1]\), and \(I_{\mu _3}\)=\([-3,3]\), we have \(I_\nu \)=\( [\sum _{i=1}^hm_i,\sum _{i=1}^hM_i]\)=\([-3,1]\). (c) A rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \) for every \(\sigma _\nu \in I_\nu \)

4.2 Representability Condition for P-Nodes with Three Children

Different from S-nodes, if \(\nu \) is a P-node and the pertinent graphs of the children of \(\nu \) are rectilinear planar, \(G_\nu \) may not be rectilinear planar. In this subsection we consider the case when \(\nu \) has three children.

Lemma 6

Let \(\nu \) be a P-node with three children \(\mu _l\), \(\mu _c\), and \(\mu _r\), ordered from left to right. Suppose that \(G_{\mu _l}, G_{\mu _c}\), and \(G_{\mu _r}\) are rectilinear planar and that their representability intervals are \(I_{\mu _l}=[m_l, M_l]\), \(I_{\mu _c}=[m_c, M_c]\), and \(I_{\mu _r} = [m_r, M_r]\), respectively. Graph \(G_\nu \) is rectilinear planar if and only if \([m_l-2,M_l-2] \cap [m_c,M_c] \cap [m_r+2,M_r+2] \ne \emptyset \). Also, if this representability condition holds then the representability interval of \(G_\nu \) is \(I_\nu = [\max \{m_l-2,m_c,m_r+2\},\min \{M_l-2,M_c,M_r+2\}]\).

Proof

Representability condition. Suppose first that \(G_\nu \) is rectilinear planar and let \(H_\nu \) be a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \). By Lemma 2, the spirality values \(\sigma _{\mu _l}\), \(\sigma _{\mu _c}\), and \(\sigma _{\mu _r}\) for the representations of \(G_{\mu _l}, G_{\mu _c}\), and \(G_{\mu _r}\) in \(H_\nu \) are such that \(\sigma _{\mu _l}=\sigma _\nu +2\), \(\sigma _{\mu _c}=\sigma _\nu \), and \(\sigma _{\mu _r}=\sigma _\nu -2\). Since \(\sigma _{\mu _l} \in [m_l,M_l]\), \(\sigma _{\mu _c} \in [m_c,M_c]\), and \(\sigma _{\mu _r} \in [m_r,M_r]\), we have \(\sigma _\nu \in [m_l-2,M_l-2] \cap [m_c,M_c] \cap [m_r+2,M_r+2]\). Suppose vice versa that \([m_l-2,M_l-2] \cap [m_c,M_c] \cap [m_r+2,M_r+2] \ne \emptyset \), and let k be any value in such intersection. Setting \(\sigma _{\mu _l} = k + 2\), \(\sigma _{\mu _c} = k\), and \(\sigma _{\mu _r} = k - 2\) we have \(\sigma _{\mu _l} \in [m_l,M_l]\), \(\sigma _{\mu _c} \in [m_c,M_c]\), and \(\sigma _{\mu _r} \in [m_r,M_r]\). By Lemma 2, \(G_\nu \) is rectilinear planar for a value of spirality \(\sigma _\nu = k\).

Representability interval. Assume that \(G_\nu \) is rectilinear planar. Clearly \([\max \{m_l-2,m_c,m_r+2\},\min \{M_l-2,M_c,M_r+2\}] = [m_l-2,M_l-2] \cap [m_c,M_c] \cap [m_r+2,M_r+2]\), and by the truth of the feasiblity condition we have \([\max \{m_l-2,m_c,m_r+2\},\min \{M_l-2,M_c,M_r+2\}] \ne \emptyset \). Similarly to the first part of the proof of the representability condition, any rectilinear planar representation of \(G_\nu \) has a value of spirality in the interval \([\max \{m_l-2,m_c,m_r+2\},\min \{M_l-2,M_c,M_r+2\}]\). On the other hand, let \(k \in [\max \{m_l-2,m_c,m_r+2\},\min \{M_l-2,M_c,M_r+2\}]\). Analogously to the second part of the proof of the representability condition, we can construct a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu =k\), by combining in parallel rectilinear planar representations of \(G_{\mu _l}\), \(G_{\mu _c}\), and \(G_{\mu _r}\) with spirality values \(\sigma _{\mu _l} = \sigma _\nu + 2\), \(\sigma _{\mu _c} = \sigma _\nu \), and \(\sigma _{\mu _r} = \sigma _\nu - 2\). \(\square \)

Figure 9 illustrates Lemma 6. In Fig. 9a, \(\nu \) has three children that are Q\(^*\)-nodes. By Lemma 4, \(I_{\mu _l}=[-5,5]\), \(I_{\mu _c}=[-3,3]\), and \(I_{\mu _c}=[-1,1]\). We have \([m_l-2,M_l-2] \cap [m_c,M_c] \cap [m_r+2,M_r+2] = [-7,3] \cap [-3,3] \cap [1,3] = \{1,2,3\}\ne \emptyset \) and, consequently, \(G_\nu \) is rectilinear planar. Also, \(I_\nu = [\max \{m_l-2,m_c,m_r+2\},\min \{M_l-2,M_c,M_r+2\}]=[1,3]\). In Fig. 9b, the left child of \(\nu \) is an S-node such that \(I_{\mu _l}=[-2,-2]\). We have \([m_l-2,M_l-2] \cap [m_c,M_c] \cap [m_r+2,M_r+2] = [-4,-4] \cap [-3,3] \cap [1,3] = \emptyset \) and, consequently, \(G_\nu \) is not rectilinear planar.

Fig. 9
figure 9

Illustration of Lemma 6. a \(G_\nu \) is rectilinear planar and \(I_\nu =[1,3]\), b \(G_\nu \) is not rectilinear planar

4.3 Representability Condition for P-Nodes with Two Children

For a P-node \(\nu \) with two children \(\mu _l\) and \(\mu _r\), the representability condition and interval depend on the different configurations of indegree and outdegree of the poles of \(\nu \) in \(G_\nu \), \(G_{\mu _l}\), and \(G_{\mu _r}\). To distinguish the different configurations, we define the type of \(\nu \) and of \(G_\nu \), using a self-contained notation; refer also to Fig. 10 for a schematic illustration. Each type is denoted using one or two symbols, I (indegree) and O (outdegree), along with suitable indices. More precisely, the possible types are defined as follows:

  • \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\): both poles of \(\nu \) have indegree two in \(G_\nu \); also one pole has outdegree \(\lambda \) in \(G_\nu \) and the other pole has outdegree \(\beta \) in \(G_\nu \), for \(1 \le \lambda \le \beta \le 2\). This gives rise to the specific types \(\textrm{I}_{2}\textrm{O}_{11}\), \(\textrm{I}_{2}\textrm{O}_{12}\), and \(\textrm{I}_{2}\textrm{O}_{22}\).

  • \(\textrm{I}_{3d}\textrm{O}_{\lambda \beta }\): one pole of \(\nu \) has indegree two in \(G_\nu \), while the other pole has indegree three in \(G_\nu \) and indegree two in \(G_{\mu _d}\) for \(d \in \{l,r\}\); also one pole has outdegree \(\lambda \) in \(G_\nu \) and the other has outdegree \(\beta \) in \(G_\nu \), for \(1 \le \lambda \le \beta \le 2\), where \(\lambda =\beta =2\) is not possible. This gives rise to the specific types \(\textrm{I}_{3\,l}\textrm{O}_{11}\), \(\textrm{I}_{3r}\textrm{O}_{11}\), \(\textrm{I}_{3\,l}\textrm{O}_{12}\), \(\textrm{I}_{3r}\textrm{O}_{12}\).

  • \(\textrm{I}_{3dd'}\): both poles of \(\nu \) have indegree three in \(G_\nu \); one of the two poles has indegree two in \(G_{\mu _d}\) and the other has indegree two in \(G_{\mu _{d'}}\), for \(dd' \in \{ll,lr,rr\}\) (both poles have outdegree one in \(G_\nu \)). Hence, the specific types are \(\textrm{I}_{3ll}\)\(\textrm{I}_{3lr}\)\(\textrm{I}_{3rr}\).

Fig. 10
figure 10

Schematic illustration of the different types of P-nodes with two children

In the next three subsections, we analyze separately the properties of the different types of P-nodes with two children.

4.3.1 Nodes of Type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\)

Lemma 8 states the representability condition and interval for P-nodes of type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\). Its proof is based on the preliminary property stated by Lemma 7.

Lemma 7

Let \(G_\nu \) be a P-node of type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\) with children \(\mu _l\) and \(\mu _r\). \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [2,4-\gamma ]\), where \(\gamma = \lambda + \beta - 2\).

Proof

We distinguish three cases, based on the values of \(\lambda \) and \(\beta \), namely the cases \(\textrm{I}_{2}\textrm{O}_{11}\), \(\textrm{I}_{2}\textrm{O}_{12}\), and \(\textrm{I}_{2}\textrm{O}_{22}\).

Case 1: \(\lambda =\beta =1\), i.e., \(G_\nu \) is of type \(\textrm{I}_{2}\textrm{O}_{11}\). We have to prove that \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [2,4]\). For a \(\textrm{I}_{2}\textrm{O}_{11}\) component we have \(k_u^l=k_v^l=k_u^r=k_v^r=1\).

If \(G_\nu \) is rectilinear planar then \(1 \le \alpha _{u}^l+\alpha _{u}^r \le 2\) and \(1 \le \alpha _{v}^l+\alpha _{v}^r \le 2\) in any rectilinear planar representation of \(G_\nu \). Hence, by Lemma 3, for any value of spirality \(\sigma _\nu \) we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=\alpha _{u}^l+\alpha _{v}^l+\alpha _{u}^r+\alpha _{v}^r \in [2,4]\).

Suppose vice versa that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [2,4]\). We define a rectilinear planar representation \(H_\nu \) of \(G_\nu \) by combining in parallel the two rectilinear planar representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) and by suitably assigning the values of \(\alpha _u^d\) and \(\alpha _v^d\) (\(d \in \{l,r\}\)), depending on the value of \(\sigma _{\mu _l}-\sigma _{\mu _r}\). This assignment is such that for any cycle C of \(G_\nu \) through u and v, the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles in the interior of C is equal to four. Poles u and v split C into two paths \(\pi _l\) and \(\pi _r\). The spirality \(\sigma _{\mu _l}\) equals the number of right minus left turns along \(\pi _l\) while going from u to v, which corresponds to the number of \(90^\circ \) minus \(270^\circ \) angles in the interior of C at the vertices of \(\pi _l\). Similarly, \(-\sigma _{\mu _r}\) equals the number of right minus left turns along \(\pi _r\) while going from v to u, which corresponds to the number of \(90^\circ \) minus \(270^\circ \) angles in the interior of C at the vertices of \(\pi _r\). By also considering the angles at u and v inside C, the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles inside C can be expressed as \(a_c = \sigma _{\mu _l}-\sigma _{\mu _r} + 4 - \alpha _u^l - \alpha _u^r - \alpha _v^l - \alpha _v^r\), and three cases are possible:

(i) if \(\sigma _{\mu _l}-\sigma _{\mu _r}=2\), for every pole \(w \in \{u,v\}\) we set \(\alpha _w^l\) and \(\alpha _w^r\) such that \(\alpha _w^l + \alpha _w^r = 1\); (ii) if \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\), for one pole \(w \in \{u,v\}\) we set \(\alpha _w^l\) and \(\alpha _w^r\) such that \(\alpha _w^l + \alpha _w^r = 1\), and for the other pole \(w' \in \{u,v\}\) we set \(\alpha _{w'}^l = \alpha _{w'}^r = 1\); (iii) if \(\sigma _{\mu _l}-\sigma _{\mu _r}=4\), for every pole \(w \in \{u,v\}\) we set \(\alpha _w^l = \alpha _w^r = 1\).

In all the cases above, we have that \(a_c=4\). Also, any other cycle not passing through u and v is an orthogonal polygon because it belongs to a rectilinear planar representation of either \(G_{\mu _l}\) (with spirality \(\sigma _{\mu _l}\)) or \(G_{\mu _r}\) (with spirality \(\sigma _{\mu _r}\)).

Case 2: \(\lambda =1\) and \(\beta =2\), i.e., \(G_\nu \) is of type \(\textrm{I}_{2}\textrm{O}_{12}\). We have to prove that \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [2,3]\). Suppose, w.l.o.g., that \(\textrm{outdeg} _\nu (u)=1\) and \(\textrm{outdeg} _\nu (v)=2\). We have \(k_u^l=k_u^r=1\) and \(k_v^l=k_v^r=\frac{1}{2}\).

If \(G_\nu \) is rectilinear planar then \(\alpha _v^l+\alpha _v^r=2\) and \(\alpha _u^l+\alpha _u^r\in [1,2]\). By Lemma 3, \(\sigma _{\mu _l}-\sigma _{\mu _r}=k_{u}^l \alpha _{u}^l +k_{v}^r \alpha _{v}^l + k_{u}^l \alpha _{u}^r + k_{v}^r\alpha _{v}^r\), and hence \(\sigma _{\mu _l}-\sigma _{\mu _r}= \alpha _{u}^l + \frac{1}{2} \alpha _{v}^l + \alpha _{u}^r + \frac{1}{2} \alpha _{v}^r\in [2,3]\).

Suppose vice versa that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar with spirality \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [2,3]\). As in the previous case, we define a rectilinear planar representation \(H_\nu \) of \(G_\nu \), by combining in parallel the two representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) and by suitably setting \(\alpha _u^d\) and \(\alpha _v^d\) (\(d \in \{l,r\}\)). Namely, we set \(\alpha _v^l=\alpha _v^r=1\), and the values of \(\alpha _u^l\) and \(\alpha _u^r\) as follows: (i) if \(\sigma _{\mu _l}-\sigma _{\mu _r}=2\), we set \(\alpha _u^l\) and \(\alpha _u^r\) such that \(\alpha _u^l + \alpha _u^r = 1\); (ii) if \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\), we set \(\alpha _u^l=\alpha _u^r=1\). With an argument similar to the previous case, for any cycle C through u and v, the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles in C can be expressed in this case by \(a_c = \sigma _{\mu _l}-\sigma _{\mu _r} + 4 - \alpha _u^l - \alpha _u^r - 1\) (the angle at v in C is always of 90\(^\circ \)). In case (i) we have \(a_c = 2 + 4 - 1 - 1 = 4\); in case (ii) we have \(a_c = 3 + 4 - 2 - 1 = 4\). Any other cycle not passing through u and v remains the same as in the representations of \(G_{\mu _l}\) and \(G_{\mu _r}\).

Case 3: \(\lambda =\beta =2\), i.e., \(G_\nu \) is of type \(\textrm{I}_{2}\textrm{O}_{22}\). We prove that \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}=2\). We have \(k_u^l=k_u^r=\frac{1}{2}\).

If \(G_\nu \) is rectilinear planar then \(\alpha _{u}^l+\alpha _{u}^r = \alpha _{v}^l+\alpha _{v}^r = 2\). By Lemma 3, \(\sigma _{\mu _l} = \sigma _{\nu } + 1\) and \(\sigma _{\mu _r} = \sigma _{\nu } - 1\); hence \(\sigma _{\mu _l}-\sigma _{\mu _r}=2\).

Suppose vice versa that \(\sigma _{\mu _l}-\sigma _{\mu _r}=2\). Again, we obtain a rectilinear planar representation \(H_\nu \) of \(G_\nu \) by combining in parallel the representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) and by suitably setting \(\alpha _u^d\) and \(\alpha _v^d\) (\(d \in \{l,r\}\)). In this case, for any cycle C through u and v, the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles in C can be expressed by \(a_c = \sigma _{\mu _l}-\sigma _{\mu _r} + 1 + 1\) (both the angles at u and v inside C is always of 90\(^\circ \) degrees). We then set \(\alpha _u^l=\alpha _v^l=\alpha _u^r=\alpha _v^r=1\), which guarantees \(a_c = 4\). Any other cycle not passing through u and v remains the same as in the representations of \(G_{\mu _l}\) and \(G_{\mu _r}\). \(\square \)

Lemma 8

Let \(\nu \) be a P-node of type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\) with children \(\mu _l\) and \(\mu _r\). Suppose that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar with representability intervals \(I_{\mu _l}=[m_l, M_l]\) and \(I_{\mu _r} = [m_r, M_r]\), respectively. Graph \(G_\nu \) is rectilinear planar if and only if \([m_l-M_r,M_l-m_r] \cap [2,4-\gamma ] \ne \emptyset \), where \(\gamma = \lambda + \beta -2\). Also, if this representability condition holds then the representability interval of \(G_\nu \) is \(I_\nu = [\max \{m_l-2,m_r\}+\frac{\gamma }{2}, \min \{M_l, M_r+2\}-\frac{\gamma }{2}]\).

Proof

We prove the correctness of the representability condition and the validity of the representability interval.

Representability condition. Suppose that \(G_\nu \) is rectilinear planar. By Lemma 7, \(G_{\mu _l}\) and \(G_{\mu _r}\) admit spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\), respectively, such that \(\sigma _{\mu _l}-\sigma _{\mu _r} \in [2,4-\gamma ]\). Hence, \(m_l-M_r \le \sigma _{\mu _l}-\sigma _{\mu _r} \le 4-\gamma \) and \(M_l-m_r \ge \sigma _{\mu _l}-\sigma _{\mu _r} \ge 2\), i.e., \([m_l-M_r,M_l-m_r] \cap [2,4-\gamma ] \ne \emptyset \).

Suppose, vice versa that \([m_l-M_r,M_l-m_r] \cap [2,4-\gamma ] \ne \emptyset \). By hypothesis \(G_{\mu _l}\) (resp. \(G_{\mu _r}\)) is rectilinear planar for every integer value of spirality in the interval \([m_l,M_l]\) (resp. \([m_r,M_r]\)). This implies that for every integer value k in the interval \([m_l-M_r, M_l-m_r]\), there exist rectilinear planar representations for \(G_{\mu _l}\) and \(G_{\mu _r}\) with spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r} = k\). Since by hypothesis there exists a value \(k \in [m_l-M_r,M_l-m_r] \cap [2,4-\gamma ]\), there must be two spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) for the representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r} = k \in [2,4-\gamma ]\). Hence, by Lemma 7, \(G_\nu \) is rectilinear planar.

Representability interval.

As in the proof of Lemma 7, we distinguish three cases, based on the values of \(\lambda \) and \(\beta \).

Case 1: \(\lambda =\beta =1\), i.e., \(G_\nu \) is of type \(\textrm{I}_{2}\textrm{O}_{11}\). We prove that \(I_\nu = [\max \{m_l-2,m_r\}, \min \{M_l, M_r+2\}]\).

Assume first that \(\sigma _\nu \) is the spirality of a rectilinear representation of \(G_\nu \). By Lemma 3, \(\sigma _\nu \in [m_l-2, M_r+2]\). Also, since for a \(\textrm{I}_{2}\textrm{O}_{11}\) component \(k_u^l=k_v^l=k_u^r=k_v^r=1\), we have \(\sigma _\nu = \sigma _{\mu _r} + \alpha _{u}^r + \alpha _{v}^r\), which implies \(\sigma _\nu \ge m_r\). Analogously, \(\sigma _\nu = \sigma _{\mu _l} - \alpha _{u}^l - \alpha _{v}^l \le M_l\). Hence, \(\sigma _\nu \in I_\nu = [\max \{m_l-2,m_r\}, \min \{M_l,M_r+2\}]\).

Assume vice versa that k is any integer in the interval \(I_\nu = [\max \{m_l-2,m_r\}, M = \min \{M_l,M_r+2\}]\). We show that \(G_\nu \) admits a rectilinear planar representation with spirality \(\sigma _\nu = k\). By hypothesis \(k \le \min \{M_l, M_r + 2\} \le M_l\); also, \(k \ge \max \{m_l-2,m_r\} \ge m_l-2\), i.e., \(k+2 \ge m_l\). Hence \([k,k+2] \cap [m_l, M_l] \ne \emptyset \). Analogously, \(k \le \min \{M_l, M_r + 2\} \le M_r + 2\), i.e., \(k-2 \le M_r\); also, \(k \ge \max \{m_l-2,m_r\} \ge m_r\). Hence \([k-2,k] \cap [m_r,M_r] \ne \emptyset \). We now distinguish the following subcases:

  • Case 1.1: \(k\le M_l-2\). Consider any two rectilinear planar representations \(H_{\mu _l}\) of \(G_{\mu _l}\) and \(H_{\mu _r}\) of \(G_{\mu _r}\) with spirality \(\sigma _{\mu _l}=k+2\) and \(\sigma _{\mu _r}\in [k-2,k] \cap [m_r, M_r] \ne \emptyset \), respectively. As already observed, \(k+2 \ge m_l\) and by hypothesis \(k+2 \le M_l\); hence \(\sigma _{\mu _l} \in [m_l,M_l]\). With this choice we have \(2\le \sigma _{\mu _l}-\sigma _{\mu _r}\le 4\), and we can combine \(H_{\mu _l}\) and \(H_{\mu _r}\) in parallel as in the proof of Lemma 7 to obtain a rectilinear planar representation \(H_\nu \) of \(G_\nu \). By Lemma 3 the spirality of \(H_\nu \) equals \(\sigma _{\mu _l} - \alpha _{l}^u - \alpha _{l}^v=k+2 - \alpha _{l}^u - \alpha _{l}^v\) and it suffices to set \(\alpha _{l}^u=\alpha _{l}^v=1\) (which is always possible, as these two values correspond to \(90^\circ \) angles) to get \(\sigma _\nu = k\).

  • Case 1.2: \(k= M_l-1\). Consider any rectilinear planar representation \(H_{\mu _l}\) of \(G_{\mu _l}\) with spirality \(\sigma _{\mu _l} = k+1 = M_l\). To suitably choose the spirality of a rectilinear planar representation \(H_{\mu _r}\) of \(G_{\mu _r}\), observe that by the representability condition \(M_l-2 \ge m_r\) and, as already proved, \(M_r \ge k-2\), i.e., \(M_r \ge M_l-3\). It follows that \([M_l-3,M_l-2] \cap [m_r,M_r] \ne \emptyset \). Hence, either \(M_l-3 \in [m_r,M_r]\) (possibly \(m_r=M_r=M_l-3\)) or \(M_l-2 \in [m_r,M_r]\) (possibly \(m_r=M_r=M_l-2\)). In the first case, choose any representation \(H_{\mu _r}\) with spirality \(\sigma _r = M_l-3\), which implies \(\sigma _{\mu _l}-\sigma _{\mu _r}=3 \in [2,4]\). In the second case, choose \(H_{\mu _r}\) with spirality \(\sigma _r = M_l-2\), which implies \(\sigma _{\mu _l}-\sigma _{\mu _r}=2 \in [2,4]\). \(H_{\mu _l}\) and \(H_{\mu _r}\) can be combined in parallel to get a representation of \(G_\nu \) with spirality \(\sigma _{\nu }=k\). Namely, by Lemma 3 we can set \(\alpha _u^l=0\) and \(\alpha _v^l=1\) (or vice versa); also, if \(\sigma _{\mu _r}=M_l-2\) we set \(\alpha _u^r=0\) and \(\alpha _v^l=1\) (or vice versa), while if \(\sigma _{\mu _r}=M_l-3\) we set \(\alpha _u^r=\alpha _v^l=1\).

  • Case 1.3: \(k= M_l\). We can combine in parallel a representation \(H_{\mu _l}\) of \(G_{\mu _l}\) with spirality \(\sigma _{\mu _l}=k=M_l\) and a representation \(H_{\mu _r}\) of \(G_{\mu _r}\) with spirality \(\sigma _{\mu _r}=k-2=M_l-2\), which implies that \( \sigma _{\mu _l}-\sigma _{\mu _r}=2\). By the representability condition we have \(M_l-2 \ge m_r\), i.e., \(\sigma _{\mu _r} \ge m_r\); also, \(k \le \min \{M_l,M_r+2\}\le M_r+2\), i.e., \(\sigma _{\mu _r} \le M_r\). Hence, \(\sigma _{\mu _r} \in [m_r,M_r]\). By Lemma 3 we can set \(\alpha _u^l=\alpha _v^l=0\) and \(\alpha _u^r=\alpha _v^l=1\) to get a representation of \(G_\nu \) with spirality \(\sigma _\nu = k\).

Case 2: \(\lambda =1\) and \(\beta =2\), i.e., \(G_\nu \) is of type \(\textrm{I}_{2}\textrm{O}_{12}\). The arguments are similar to the previous case; see “Appendix B” for details.

Case 3: \(\lambda =\beta =2\), i.e., \(G_\nu \) is of type \(\textrm{I}_{2}\textrm{O}_{22}\). We prove that \(I_\nu = [\max \{m_l-2,m_r\}+1, \min \{M_l, M_r+2\}-1]\).

Assume first that \(G_\nu \) is rectilinear planar and let \(H_\nu \) be a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \). Let \(H_{\mu _l}\) and \(H_{\mu _r}\) be the rectilinear planar representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) contained in \(H_\nu \), and let \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) be their spirality values. Since both u and v have outdegree two in \(G_\nu \) we have that \(\alpha _{u}^l+\alpha _{u}^r = \alpha _{v}^l+\alpha _{v}^r = 2\). By Lemma 3, \(\sigma _{\mu _l} = \sigma _{\nu } + 1\) and \(\sigma _{\mu _r} = \sigma _{\nu } - 1\). By the representability condition, \(\sigma _{\mu _r}=\sigma _{\mu _l}-2\). Hence \(\sigma _{\mu _r}\ge m_l-2\) and \(\sigma _{\mu _r}\ge \max \{m_l-2,m_r\}\). Also by \(\sigma _{\nu }=\sigma _{\mu _r}+1\), \(\sigma _\nu \ge \max \{m_l-2,m_r\}+1\). Similarly, by the representability condition, \(\sigma _{\mu _l}=\sigma _{\mu _r}+2\). Hence \(\sigma _{\mu _l}\le M_r+2\) and \(\sigma _{\mu _l}\le \max \{M_l,M_r+2\}\). Since \(\sigma _{\mu _l}=\sigma _\nu +1\) we have \(\sigma _\nu \le \max \{M_l,M_r+2\}-1\).

Assume vice versa that k is an integer in the interval \(I_\nu = [\max \{m_l-2,m_r\}+1,\min \{M_l,M_r+2\}-1]\). We show that there exists a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu =k\). We have \(k +1 \in [\max \{m_l,m_r+2\},\min \{M_l,M_r+2\}]\) and therefore \(k +1 \in [m_l,M_l]\). Hence there exists a rectilinear planar representation \(H_{\mu _l}\) of \(G_{\mu _l}\) with spirality \(\sigma _{\mu _l}=k+1\). Similarly, we have \(k -1 \in [\max \{m_l-2,m_r\},\min \{M_l-2,M_r\}]\) and therefore \(k-1 \in [m_r,M_r]\). Hence there exists a rectilinear planar representation \(H_{\mu _r}\) of \(G_{\mu _r}\) with spirality \(\sigma _{\mu _r} = k-1\). By the representability condition \(G_\nu \) has a rectilinear planar representation \(H_\nu \); also, following the same construction as in the proof of Lemma 7, the spirality of \(H_\nu \) is \(\sigma _\nu =k\). \(\square \)

4.3.2 Nodes of Type \(\textrm{I}_{3d}\textrm{O}_{\lambda \beta }\)

Lemma 10 states the representability condition and interval for P-nodes of type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\). Its proof is based on the preliminary property stated by Lemma 9.

Lemma 9

Let \(G_\nu \) be a P-node of type \(\textrm{I}_{3d}\textrm{O}_{\lambda \beta }\) and let \(\mu _l\) and \(\mu _r\) be its two children. \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\), respectively, such that \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [\frac{5}{2},\frac{7}{2}-\gamma ]\), where \(\gamma = \lambda + \beta - 2\).

Proof

We distinguish four cases, based on the values of \(\lambda \), \(\beta \), and d.

Case 1: \(\lambda =\beta =1\) and \(d=l\), i.e., \(G_\nu \) is of type \(\textrm{I}_{3\,l}\textrm{O}_{11}\). We prove that \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [\frac{5}{2},\frac{7}{2}]\). For an \(\textrm{I}_{3\,l}\textrm{O}_{11}\) component we have \(k_u^l=k_u^r=k_v^r=1\) and \(k_v^l=\frac{1}{2}\).

If \(G_\nu \) is rectilinear planar then \(1 \le \alpha _{u}^l+\alpha _{u}^r \le 2\) and \(\alpha _{v}^l=\alpha _{v}^r=1\) in any rectilinear planar representation of \(G_\nu \). Hence, by Lemma 3, for any value of spirality \(\sigma _\nu \) we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=\alpha _{u}^l+\frac{1}{2}\alpha _{v}^l+\alpha _{u}^r+\alpha _{v}^r \in [\frac{5}{2},\frac{7}{2}]\).

Suppose vice versa that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [\frac{5}{2},\frac{7}{2}]\). We define a rectilinear planar representation \(H_\nu \) of \(G_\nu \), by combining in parallel the two rectilinear planar representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) and by suitably assigning the values of \(\alpha _u^l\) and \(\alpha _u^r\), depending on the value of \(\sigma _{\mu _l}-\sigma _{\mu _r}\).

Let \(v'\) be the alias vertex of \(G_{\mu _l}\) that is in \(G_\nu \). Any cycle C that goes through u and v also passes through \(v'\). We show that the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles inside C is equal to four.

Vertices u and \(v'\) split C into two paths \(\pi _l\) and \(\pi _r\). Suppose to visit C clockwise. The number of right minus left turns along \(\pi _l\) while going from u to \(v'\) equals \(\sigma _{\mu _l}+\frac{1}{2}\). The number of right minus left turns along \(\pi _r\) while going from \(v'\) to u equals \(-\sigma _{\mu _r}\). Hence, the sum \(\sigma _{\mu _l}+\frac{1}{2}-\sigma _{\mu _r}+2-\alpha _u^r-\alpha _u^l\) corresponds to the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles inside C at the vertices of \(\pi _l\). Notice that \(\alpha _u^r+\alpha _u^l\in \{1,2\}\) since u is a vertex of degree 3. If \(\sigma _{\mu _l}-\sigma _{\mu _r}=\frac{5}{2}\) we set \(\alpha _u^r+\alpha _u^l=1\) and we have \(\sigma _{\mu _l}+\frac{1}{2}-\sigma _{\mu _r}+2-\alpha _u^r-\alpha _u^l=\frac{5}{2}+\frac{1}{2}+2-1=4\). Else, if \(\sigma _{\mu _l}-\sigma _{\mu _r}=\frac{7}{2}\) we set \(\alpha _u^r+\alpha _u^l=2\) and we have \(\sigma _{\mu _l}+\frac{1}{2}-\sigma _{\mu _r}+2-\alpha _u^r-\alpha _u^l=\frac{7}{2}+\frac{1}{2}+2-2=4\).

Any other cycle not passing through u and v remains the same as in the representations of either \(G_{\mu _l}\) (with spirality \(\sigma _{\mu _l}\)) and \(G_{\mu _r}\) (with spirality \(\sigma _{\mu _r}\)).

Case 2: \(\lambda =1\), \(\beta =2\), and \(d=l\), i.e., \(G_\nu \) is of type \(\textrm{I}_{3\,l}\textrm{O}_{12}\). We prove that \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}=\frac{5}{2}\) (note that this corresponds to the interval \([\frac{5}{2},\frac{7}{2}-\gamma ]\) claimed in the lemma). For an \(\textrm{I}_{3\,l}\textrm{O}_{12}\) component, \(k_u^l=k_u^r=k_v^l=\frac{1}{2}\) and \(k_v^r=1\).

If \(G_\nu \) is rectilinear planar then \( \alpha _{u}^l=\alpha _{u}^r=\alpha _{v}^l=\alpha _{v}^r=1\) in any rectilinear planar representation of \(G_\nu \). Hence, by Lemma 3, for any value of spirality \(\sigma _\nu \) we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=\frac{1}{2}\alpha _{u}^l+\frac{1}{2}\alpha _{v}^l+\frac{1}{2}\alpha _{u}^r+\alpha _{v}^r =\frac{5}{2}\).

Suppose vice versa that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}=\frac{5}{2}\). As usual, we define \(H_\nu \) by combining in parallel the two rectilinear planar representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) and we assign values \(\alpha _u^l=\alpha _v^l=\alpha _u^r=\alpha _v^r=1\).

Let \(v'\) be the alias vertex of \(G_{\mu _l}\) that is in \(G_\nu \). Any cycle C that goes through u and v also passes through \(v'\).

Vertices u and \(v'\) split C into two paths \(\pi _l\) and \(\pi _r\). Suppose to visit C clockwise. The number of right turns minus left turns along \(\pi _l\) while going from u to \(v'\) equals \(\sigma _{\mu _l}+\frac{1}{2}\). The number of right turns minus left turns along \(\pi _r\) while going from \(v'\) to u equals \(-\sigma _{\mu _r}\). Also, pole u forms a \(90^\circ \) angle in C. Hence, the sum \(\sigma _{\mu _l}+\frac{1}{2}-\sigma _{\mu _r}+1\) corresponds to the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles in C at the vertices of \(\pi _l\). Since \(\sigma _{\mu _l}-\sigma _{\mu _r}=\frac{5}{2}\) we have \(\sigma _{\mu _l}+\frac{1}{2}-\sigma _{\mu _r}+1=\frac{5}{2}+\frac{1}{2}+1=4\).

Any other cycle not passing through u and v remains the same as in the rectilinear representations of \(G_{\mu _l}\) (with spirality \(\sigma _{\mu _l}\)) and \(G_{\mu _r}\) (with spirality \(\sigma _{\mu _r}\)).

Case 3: \(\lambda =\beta =1\) and \(d=r\). Symmetric to Case 1.

Case 4: \(\lambda =1\), \(\beta =2\), and \(d=r\). Symmetric to Case 2. \(\square \)

Lemma 10

Let \(\nu \) be a P-node of type \(\textrm{I}_{3d}\textrm{O}_{\lambda \beta }\) with children \(\mu _l\) and \(\mu _r\). Suppose that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar with representability intervals \(I_{\mu _l}=[m_l, M_l]\) and \(I_{\mu _r} = [m_r, M_r]\), respectively. Graph \(G_\nu \) is rectilinear planar if and only if \([m_l-M_r,M_l-m_r] \cap [\frac{5}{2},\frac{7}{2}-\gamma ] \ne \emptyset \), where \(\gamma = \lambda + \beta -2\). Also, if this representability condition holds then the representability interval of \(G_\nu \) is \(I_\nu = [\max \{m_l-\frac{3}{2},m_r+1\}+\frac{\gamma -\rho (d)}{2},\min \{M_l-\frac{1}{2}, M_r+2\}-\frac{\gamma +\rho (d)}{2}]\), where \(\phi (\cdot )\) is a function such that \(\phi (r)=1\) and \(\phi (l)=0\).

Proof

We prove the correctness of the representability condition and the validity of the representability interval.

Representability condition. Suppose that \(G_\nu \) is rectilinear planar. By Lemma 9, \(G_{\mu _l}\) and \(G_{\mu _r}\) admit spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\), respectively, such that \(\sigma _{\mu _l}-\sigma _{\mu _r} \in [\frac{5}{2},\frac{7}{2}-\gamma ]\), where \(\gamma = \lambda + \beta -2\). Hence, \(m_l-M_r \le \sigma _{\mu _l}-\sigma _{\mu _r} \le \frac{7}{2}-\gamma \) and \(M_l-m_r \ge \sigma _{\mu _l}-\sigma _{\mu _r} \ge \frac{5}{2}\), i.e., \([m_l-M_r,M_l-m_r] \cap [\frac{5}{2},\frac{7}{2}-\gamma ] \ne \emptyset \).

Suppose, vice versa that \([m_l-M_r,M_l-m_r] \cap [\frac{5}{2},\frac{7}{2}-\gamma ] \ne \emptyset \). By hypothesis \(G_{\mu _l}\) (resp. \(G_{\mu _r}\)) is rectilinear planar for every value of spirality in the interval \([m_l,M_l]\) (resp. \([m_r,M_r]\)). This implies that for every semi-integer value k in the interval \([m_l-M_r, M_l-m_r]\), there exist rectilinear planar representations for \(G_{\mu _l}\) and \(G_{\mu _r}\) with spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r} = k\). Since by hypothesis there exists a value \(k \in [m_l-M_r,M_l-m_r] \cap [\frac{5}{2},\frac{7}{2}-\gamma ]\), there must be two values of spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) for the representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r} = k \in [\frac{5}{2},\frac{7}{2}-\gamma ]\). Hence, by Lemma 9, \(G_\nu \) is rectilinear planar.

Representability interval. As for Lemma 9, the case analysis is based on the values of \(\lambda \), \(\beta \), and d; w.l.o.g. we assume that v is the pole of degree four.

Case 1: \(\lambda =\beta =1\), and \(d=l\), i.e., \(G_\nu \) is of type \(\textrm{I}_{3\,l}\textrm{O}_{11}\). We prove that \(I_\nu = [\max \{m_l-\frac{3}{2},m_r+1\},\min \{M_l-\frac{1}{2}, M_r+2\}]\).

Assume first that \(\sigma _\nu \) is the spirality of a rectilinear planar representation of \(G_\nu \). Since for an \(\textrm{I}_{3\,l}\textrm{O}_{11}\) component we have \(k_u^l=k_u^r=k_v^r=1\) and \(k_v^l=\frac{1}{2}\), by Lemma 3 we have \(\sigma _\nu = \sigma _{\mu _r} + \alpha _{u}^r + \alpha _{v}^r\) and \(\sigma _\nu = \sigma _{\mu _l} - \alpha _{u}^l - \frac{1}{2}\alpha _{v}^l\). Since \(\alpha _u^l + \alpha _u^r \in \{1,2\}\) and \(\alpha _v^l=\alpha _v^r=1\), we have \(\sigma _\nu \ge m_r + 1\), \(\sigma _\nu \le M_r+2\), \(\sigma _\nu \ge m_l-\frac{3}{2}\), and \(\sigma _\nu \le M_l-\frac{1}{2}\).

Conversely, we show that if \(\sigma _\nu \in [\max \{m_l-\frac{3}{2},m_r+1\},\min \{M_l-\frac{1}{2},M_r+2\}]\), there exists a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \). We have \(\sigma _\nu \in [m_l-\frac{3}{2}, M_l-\frac{1}{2}]\). Hence, \(\sigma _\nu + \frac{1}{2} \le M_l\) and \(\sigma _\nu + \frac{3}{2} \ge m_l\), i.e., \([\sigma _\nu +\frac{1}{2},\sigma _{\nu }+\frac{3}{2}]\cap [m_l,M_l]\not = \emptyset \). Also, since \(m_l\) and \(M_l\) are both semi-integer numbers while \(\sigma _\nu \) is integer, it is impossible to have \(\sigma _\nu + 1 = m_l = M_l\). It follows that \(\sigma _\nu +\frac{1}{2}\in [m_l,M_l]\) or \(\sigma _\nu +\frac{3}{2}\in [m_l,M_l]\). With the same reasoning, we have \(\sigma _\nu \in [m_r+1, M_r+2]\) and \([\sigma _\nu -2,\sigma _{\nu }-1]\cap [m_r,M_r]\not = \emptyset \). Hence, \(\sigma _\nu -2\in [m_r,M_r]\) or \(\sigma _\nu -1\in [m_r,M_r]\). We now observe that either \(\sigma _\nu +\frac{3}{2}\in [m_l,M_l]\) or \(\sigma _\nu -2 \in [m_r,M_r]\). Indeed, if it were \(\sigma _\nu +\frac{3}{2}\not \in [m_l,M_l]\) and \(\sigma _\nu -2\not \in [m_r,M_r]\), then \(\sigma _\nu +\frac{1}{2}\in [m_l,M_l]\) and \(\sigma _\nu -1 \in [m_r,M_r]\) and consequently, \(\sigma _\nu +\frac{1}{2}=M_l\) and \(\sigma _\nu -1=m_r\); hence, it would be \(M_l-m_r=\frac{3}{2}\) and, by the representability condition, \(G_\nu \) would not be rectilinear planar.

Based on this observation, we can construct a rectilinear planar representation \(H_{\mu _l}\) of \(G_{\mu _l}\) with spirality \(\sigma _{\mu _l}\) and a rectilinear planar representation \(H_{\mu _r}\) of \(G_{\mu _r}\) with spirality \(\sigma _{\mu _r}\), by distinguishing the following cases, one of which must be verified:

  • Case (a): \(\sigma _\nu +\frac{3}{2}\not \in [m_l,M_l]\). This implies that \(\sigma _\nu +\frac{1}{2}\in [m_l,M_l]\) and \(\sigma _\nu -2\in [m_r,M_r]\), and therefore we set \(\sigma _{\mu _l}=\sigma _\nu +\frac{1}{2}\) and \(\sigma _{\mu _r}=\sigma _\nu -2\).

  • Case (b): \(\sigma _\nu -2\not \in [m_r,M_r]\). This implies that \(\sigma _\nu +\frac{3}{2}\in [m_l,M_l]\) and \(\sigma _\nu -1\in [m_r,M_r]\), and therefore we set \(\sigma _{\mu _l}=\sigma _\nu +\frac{3}{2}\) and \(\sigma _{\mu _r}=\sigma _\nu -1\).

  • Case (c): \(\sigma _\nu +\frac{3}{2}\in [m_l,M_l]\) and \(\sigma _\nu -2\in [m_r,M_r]\). We set \(\sigma _{\mu _l}=\sigma _\nu +\frac{3}{2}\) and \(\sigma _{\mu _r}=\sigma _\nu -2\).

In all the three cases we have \(\sigma _{\mu _l}-\sigma _{\mu _r}\in [\frac{5}{2},\frac{7}{2}]\), hence, there exists a rectilinear planar representation \(H_\nu \) of \(G_\nu \) given the values of \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\). We have to prove that in the three cases the spirality of \(H_\nu \) is \(\sigma _\nu \). By Lemma 3 we have \(\sigma _\nu ' = \sigma _{\mu _l} - \alpha _{u}^l - \frac{1}{2} \alpha _{v}^l\), where \(\sigma _\nu '\) is the spirality of the representation \(H_\nu \) of \(G_\nu \) given a choice of \(\sigma _{\mu _l}\), \(\alpha _{v}^l\), and \(\alpha _{v}^r\). In Case (a) we have \(\sigma _\nu ' = \sigma _\nu +\frac{1}{2} - \alpha _{u}^l - \frac{1}{2} \alpha _{v}^l\); choosing \(\alpha _{u}^l=0\) and \(\alpha _{v}^l=1\) we have \(\sigma _\nu ' = \sigma _\nu \). In Cases (b) and (c) we have \(\sigma _\nu ' = \sigma _\nu +\frac{3}{2} - \alpha _{u}^l - \frac{1}{2} \alpha _{v}^l\); choosing \(\alpha _{u}^l=1\) and \(\alpha _{v}^l=1\) we have \(\sigma _\nu ' = \sigma _\nu \).

Case 2: \(\lambda =1\), \(\beta =2\), and \(d=l\), i.e., \(G_\nu \) is of type \(\textrm{I}_{3\,l}\textrm{O}_{12}\). We prove that \(I_\nu = [\max \{m_l-\frac{3}{2},m_r+1\}+\frac{1}{2},\min \{M_l-\frac{1}{2}, M_r+2\}-\frac{1}{2}] = [\max \{m_l-1,m_r+\frac{3}{2}\},\min \{M_l-1, M_r+\frac{3}{2}\}\).

Assume first that \(\sigma _\nu \) is the spirality of a rectilinear planar representation of \(G_\nu \). Since for an \(\textrm{I}_{3\,l}\textrm{O}_{12}\) component we have \(k_u^l=k_u^r=k_v^l=\frac{1}{2}\) and \(k_v^r=1\), by Lemma 3 we have \(\sigma _\nu = \sigma _{\mu _r} + \frac{1}{2}\alpha _{u}^r + \alpha _{v}^r\) and \(\sigma _\nu = \sigma _{\mu _l} - \frac{1}{2}\alpha _{u}^l - \frac{1}{2}\alpha _{v}^l\). Since \(\alpha _u^l=\alpha _v^l=\alpha _u^r=\alpha _v^r=1\), we have: \(\sigma _\nu \ge m_r + \frac{3}{2}\), \(\sigma _\nu \le M_r+\frac{3}{2}\), \(\sigma _\nu \ge m_l-1\), and \(\sigma _\nu \le M_l-1\).

Conversely, we show that if \(\sigma _\nu \in [\max \{m_l-1,m_r+\frac{3}{2}\},\min \{M_l-1,M_r+\frac{3}{2}\}]\), there exists a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \). We have \(\sigma _\nu \in [m_l-1, M_l-1]\) and \(\sigma _\nu \in [m_r+\frac{3}{2}, M_r+\frac{3}{2}]\). Hence, \(\sigma _\nu +1 \in [m_l, M_l]\) and \(\sigma _\nu -\frac{3}{2} \in [m_r, M_r]\). We can construct a rectilinear planar representation \(H_{\mu _l}\) of \(G_{\mu _l}\) with spirality \(\sigma _{\mu _l}=\sigma _\nu +1\) and a rectilinear planar representation \(H_{\mu _r}\) of \(G_{\mu _r}\) with spirality \(\sigma _{\mu _r}=\sigma _\nu -\frac{3}{2}\). Notice that, for this choice, we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=\frac{5}{2}\), hence, there exists a rectilinear planar representation \(H_\nu \) of \(G_\nu \) given the values of \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\). We have to prove that the spirality of \(H_\nu \) is \(\sigma _\nu \). By Lemma 3 we have \(\sigma _\nu ' = \sigma _{\mu _l} - \frac{1}{2}\alpha _{u}^l - \frac{1}{2}\alpha _{v}^l\), where \(\sigma _\nu '\) is the spirality of the representation \(H_\nu \) of \(G_\nu \) given a choice of \(\sigma _{\mu _l}\), \(\alpha _{v}^l\), and \(\alpha _{v}^r\). Since \(\sigma _\nu =\sigma _{\mu _l}-1\), \(\alpha _{v}^l=1\), and \(\alpha _{v}^r=1\), we have \(\sigma _\nu ' = \sigma _\nu +1-1=\sigma _\nu \).

Case 3: \(\lambda =\beta =1\) and \(d=r\). Symmetric to Case 1.

Case 4: \(\lambda =1\), \(\beta =2\), and \(d=r\). Symmetric to Case 2. \(\square \)

4.3.3 Nodes of Type \(\textrm{I}_{3dd'}\)

Lemma 12 states the representability condition and interval for P-nodes of type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\). Its proof is based on the preliminary property stated by Lemma 11.

Lemma 11

Let \(G_\nu \) be a P-node of type \(\textrm{I}_{3dd'}\) and let \(\mu _l\) and \(\mu _r\) be its two children. \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\), respectively, such that \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\).

Proof

We distinguish three cases, based on the values of d and \(d'\). The proof for type \(\textrm{I}_{3rl}\) is symmetric to the one for type \(\textrm{I}_{3lr}\).

Case 1: \(d=d'=l\), i.e., \(G_\nu \) is of type \(\textrm{I}_{3ll}\). We prove that \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\). For an \(\textrm{I}_{3ll}\) component we have \(k_u^l=k_v^l=\frac{1}{2}\) and \(k_u^r=k_v^r=1\).

If \(G_\nu \) is rectilinear planar, we have \(\alpha _{u}^l=\alpha _{u}^r =\alpha _{v}^l=\alpha _{v}^r=1\) in any rectilinear planar representation of \(G_\nu \). Hence, by Lemma 3, for any value of spirality \(\sigma _\nu \) we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=\frac{1}{2}\alpha _{u}^l+\frac{1}{2}\alpha _{v}^l+\alpha _{u}^r+\alpha _{v}^r=3\).

Suppose vice versa that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\). We define a rectilinear planar representation \(H_\nu \) of \(G_\nu \), by combining in parallel the two rectilinear planar representations of \(G_{\mu _l}\) and \(G_{\mu _r}\) with values \(\alpha _u^l=\alpha _v^l=\alpha _u^r=\alpha _v^r=1\).

Let \(u'\) and \(v'\) be the alias vertices of \(G_{\mu _l}\) that subdivide edges of \(G_\nu \). Any cycle C through u and v also passes through \(u'\) and \(v'\).

Vertices \(u'\) and \(v'\) split C into two paths \(\pi _l\) and \(\pi _r\). Suppose to visit C clockwise. The number of right turns minus left turns along \(\pi _l\) while going from \(u'\) to \(v'\) equals \(\sigma _{\mu _l}+1\). The number of right turns minus left turns along \(\pi _r\) while going from \(v'\) to \(u'\) equals \(-\sigma _{\mu _r}\). The sum of these two values corresponds to the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles in the interior of C at the vertices of \(\pi _l\); we have \(\sigma _{\mu _l}+1-\sigma _{\mu _r}=3+1=4\). All other cycles not passing through u and v are orthogonal polygons as they remain the same as in \(G_{\mu _l}\) (with spirality \(\sigma _{\mu _l}\)) and \(G_{\mu _r}\) (with spirality \(\sigma _{\mu _r}\)).

Case 2: \(d=d'=r\). Symmetric to Case 1, observing that \(k_u^r=k_v^r=\frac{1}{2}\) and \(k_u^l=k_v^l=1\).

Case 3: \(d=l\) and \(d'=r\), i.e., \(G_\nu \) is of type \(\textrm{I}_{3lr}\). We prove that \(G_\nu \) is rectilinear planar if and only if \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\). For an \(\textrm{I}_{3lr}\) component we have \(k_u^r=k_v^l=\frac{1}{2}\) and \(k_u^l=k_v^r=1\).

If \(G_\nu \) is rectilinear planar, we have \(\alpha _{u}^l=\alpha _{u}^r =\alpha _{v}^l=\alpha _{v}^r=1\) in any rectilinear planar representation of \(G_\nu \). Hence, by Lemma 3, for any value of spirality \(\sigma _\nu \) we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=\alpha _{u}^l+\frac{1}{2}\alpha _{v}^l+\frac{1}{2}\alpha _{u}^r+\alpha _{v}^r=3\).

Suppose vice versa that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar for values of spirality \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\). We define \(H_\nu \) by combining in parallel the two rectilinear planar representations of \(G_{\mu _l}\) and \(G_{\mu _r}\), with values \(\alpha _u^l=\alpha _v^l=\alpha _u^r=\alpha _v^r=1\).

Let \(v'\) be the alias vertex of the pole v of \(G_{\mu _l}\) such that \(v'\) subdivides an edge of \(G_\nu \). Similarly, let \(u'\) be the alias vertex of the pole u of \(G_{\mu _r}\) such that \(u'\) subdivides an edge of \(G_\nu \). Any cycle C through u and v also passes through \(u'\) and \(v'\).

Vertices \(u'\) and \(v'\) split C into two paths \(\pi _l\) and \(\pi _r\). Visiting C clockwise, the number of right minus left turns along \(\pi _l\) while going from \(u'\) to \(v'\) equals \(\sigma _{\mu _l}+\frac{1}{2}\). The number of right minus left turns along \(\pi _r\) while going from \(v'\) to \(u'\) equals \(-\sigma _{\mu _r}+\frac{1}{2}\). The sum of these two values corresponds to the number of \(90^\circ \) angles minus the number of \(270^\circ \) angles in the interior of C at the vertices of \(\pi _l\), and we have \(\sigma _{\mu _l}+\frac{1}{2}-\sigma _{\mu _r}+\frac{1}{2}=3+\frac{1}{2}+\frac{1}{2}=4\).

\(\square \)

Lemma 12

Let \(\nu \) be a P-node of type \(\textrm{I}_{3dd'}\) with children \(\mu _l\) and \(\mu _r\). Suppose that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar with representability intervals \(I_{\mu _l}=[m_l, M_l]\) and \(I_{\mu _r} = [m_r, M_r]\), respectively. Graph \(G_\nu \) is rectilinear planar if and only if \(3 \in [m_l-M_r,M_l-m_r]\). Also, if this representability condition holds then the representability interval of \(G_\nu \) is \(I_\nu = [\max \{m_l-1,m_r+2\}-\frac{\phi (d)+\phi (d')}{2},\min \{M_l-1, M_r+2\}-\frac{\phi (d)+\phi (d')}{2}]\), where \(\phi (\cdot )\) is a function such that \(\phi (r)=1\) and \(\phi (l)=0\).

Proof

We prove the correctness of the representability condition and the validity of the representability interval.

Representability condition. Suppose that \(G_\nu \) is rectilinear planar. By Lemma 11, \(G_{\mu _l}\) and \(G_{\mu _r}\) admit spirality values \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\), respectively, such that \(\sigma _{\mu _l}-\sigma _{\mu _r} = 3\). Hence, \(m_l-M_r \le \sigma _{\mu _l}-\sigma _{\mu _r} \le 3\) and \(M_l-m_r \ge \sigma _{\mu _l}-\sigma _{\mu _r} \ge 3\), i.e., \(3 \in [m_l-M_r,M_l-m_r]\).

Suppose, vice versa that \(3 \in [m_l-M_r,M_l-m_r]\). By hypothesis \(G_{\mu _l}\) (resp. \(G_{\mu _r}\)) is rectilinear planar for every value of spirality in the interval \([m_l,M_l]\) (resp. \([m_r,M_r]\)). This implies that there exist rectilinear planar representations for \(G_{\mu _l}\) and \(G_{\mu _r}\) with spirality values \(\sigma _{\mu _l} \in [m_l,M_l]\) and \(\sigma _{\mu _r} \in [m_r,M_r]\) such that \(\sigma _{\mu _l}-\sigma _{\mu _r} = 3\). Hence, by Lemma 11\(G_\nu \) is rectilinear planar.

Representability interval. We distinguish three cases, based on the values of d and \(d'\). Note that a possible forth case for the type \(\textrm{I}_{3rl}\) is symmetric to the case for the type \(\textrm{I}_{3lr}\).

Case 1: \(d=d'=l\), i.e., \(G_\nu \) is of type \(\textrm{I}_{3ll}\). We prove that \(I_\nu = [\max \{m_l-1,m_r+2\},\min \{M_l-1, M_r+2\}]\).

Assume first that \(\sigma _\nu \) is the spirality of a rectilinear planar representation of \(G_\nu \). Since for an \(\textrm{I}_{3ll}\) component we have \(k_u^l=k_v^l=\frac{1}{2}\) and \(k_u^r=k_v^r=1\), by Lemma 3 we have \(\sigma _\nu = \sigma _{\mu _r} + \alpha _{u}^r + \alpha _{v}^r\) and \(\sigma _\nu =\sigma _{\mu _l} - \frac{1}{2}\alpha _{u}^l - \frac{1}{2}\alpha _{v}^l\). Since \(\alpha _u^l=\alpha _v^l=\alpha _u^r=\alpha _v^r=1\), we have: \(\sigma _\nu \ge m_r + 2\), \(\sigma _\nu \le M_r+2\), \(\sigma _\nu \ge m_l-1\), and \(\sigma _\nu \le M_l-1\).

Conversely, we show that if \(\sigma _\nu \in [\max \{m_l-1,m_r+2\},\min \{M_l-1,M_r+2\}]\), there exists a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \). We have \(\sigma _\nu \in [m_l-1, M_l-1]\) and \(\sigma _\nu \in [m_r+2, M_r+2]\). Hence, \(\sigma _\nu +1 \in [m_l, M_l]\) and \(\sigma _\nu -2 \in [m_r, M_r]\). We can construct a rectilinear planar representation \(H_{\mu _l}\) of \(G_{\mu _l}\) with spirality \(\sigma _{\mu _l}=\sigma _\nu +1\) and a rectilinear planar representation \(H_{\mu _r}\) of \(G_{\mu _r}\) with spirality \(\sigma _{\mu _r}=\sigma _\nu -2\). Note that, for this choice, we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\), hence, there exists a rectilinear planar representation \(H_\nu \) of \(G_\nu \) given the values of \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\). We have to prove that the spirality of \(H_\nu \) is \(\sigma _\nu \). By Lemma 3 we have \(\sigma _\nu ' = \sigma _{\mu _l} - \frac{1}{2} \alpha _{u}^l - \frac{1}{2}\alpha _{v}^l\), where \(\sigma _\nu '\) is the spirality of the representation \(H_\nu \) of \(G_\nu \) given a choice of \(\sigma _{\mu _l}\), \(\alpha _{v}^l\), and \(\alpha _{u}^l\). Since \(\sigma _\nu =\sigma _{\mu _l}-1\), \(\alpha _{u}^l=1\), and \(\alpha _{v}^l=1\), we have \(\sigma _\nu ' = \sigma _\nu +1-\frac{1}{2}-\frac{1}{2}=\sigma _\nu \).

Case 2: \(d=d'=r\). Symmetric to Case 1.

Case 3: \(d=l\) and \(d'=r\), i.e., \(G_\nu \) is of type \(\textrm{I}_{3lr}\). We prove that \(I_\nu = [\max \{m_l-1,m_r+2\}-\frac{1}{2},\min \{M_l-1, M_r+2\}-\frac{1}{2}]=[\max \{m_l-\frac{3}{2},m_r+\frac{3}{2}\},\min \{M_l-\frac{3}{2}, M_r+\frac{3}{2}\}]\).

Assume first that \(\sigma _\nu \) is the spirality of a rectilinear planar representation of \(G_\nu \). Since for an \(\textrm{I}_{3lr}\) component we have \(k_u^r=k_v^l=\frac{1}{2}\) and \(k_u^l=k_v^r=1\), by Lemma 3 we have \(\sigma _\nu = \sigma _{\mu _r} + \frac{1}{2}\alpha _{u}^r + \alpha _{v}^r\) and \(\sigma _\nu =\sigma _{\mu _l} - \alpha _{u}^l - \frac{1}{2}\alpha _{v}^l\). Since \(\alpha _u^l=\alpha _v^l=\alpha _u^r=\alpha _v^r=1\), we have: \(\sigma _\nu \ge m_r + \frac{3}{2}\), \(\sigma _\nu \le M_r+\frac{3}{2}\), \(\sigma _\nu \ge m_l-\frac{3}{2}\) and \(\sigma _\nu \le M_l-\frac{3}{2}\). Conversely, we show that if \(\sigma _\nu \in [\max \{m_l-\frac{3}{2},m_r+\frac{3}{2}\},\min \{M_l-\frac{3}{2},M_r+\frac{3}{2}\}]\), there exists a rectilinear planar representation of \(G_\nu \) with spirality \(\sigma _\nu \). We have \(\sigma _\nu \in [m_l-\frac{3}{2}, M_l-\frac{3}{2}]\) and \(\sigma _\nu \in [m_r+\frac{3}{2}, M_r+\frac{3}{2}]\). Hence, \(\sigma _\nu +\frac{3}{2} \in [m_l, M_l]\) and \(\sigma _\nu -\frac{3}{2} \in [m_r, M_r]\). We can construct a rectilinear planar representation \(H_{\mu _l}\) of \(G_{\mu _l}\) with spirality \(\sigma _{\mu _l}=\sigma _\nu +\frac{3}{2}\) and a rectilinear planar representation \(H_{\mu _r}\) of \(G_{\mu _r}\) with spirality \(\sigma _{\mu _r}=\sigma _\nu -\frac{3}{2}\). Notice that, for this choice, we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\), hence, there exists a rectilinear planar representation \(H_\nu \) of \(G_\nu \) given the values of \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\). We have to prove that the spirality of \(H_\nu \) is \(\sigma _\nu \). By Lemma 3, \(\sigma _\nu ' = \sigma _{\mu _l} - \alpha _{u}^l - \frac{1}{2}\alpha _{v}^l\), where \(\sigma _\nu '\) is the spirality of the representation \(H_\nu \) of \(G_\nu \) given a choice of \(\sigma _{\mu _l}\), \(\alpha _{v}^l\), and \(\alpha _{u}^l\). Since \(\sigma _\nu =\sigma _{\mu _l}-\frac{3}{2}\), \(\alpha _{u}^l=1\), and \(\alpha _{v}^l=1\), we have \(\sigma _\nu ' = \sigma _\nu +\frac{3}{2}-1-\frac{1}{2}=\sigma _\nu \). \(\square \)

4.4 Representability Condition for the Root

To finally achieve a characterization of rectilinear series–parallel graphs we need to consider the representability condition that must be verified at the level of the root, when the reference edge is not a dummy edge. Denote by \(e=(u,v)\) the reference edge of G and let \(\rho \) be the root of T with respect to e. Let \(\eta \) be the child of \(\rho \) that does not correspond to e, and let \(u'\) and \(v'\) be the alias vertices associated with the poles u and v of \(G_\eta \). Suppose that \(G_\eta \) is rectilinear planar with representability interval \(I_\eta \).

We say that G satisfies the root condition if \(I_\eta \cap \Delta _\rho \ne \emptyset \), where \(\Delta _\rho \) is defined as follows: (i) \(\Delta _\rho =[2,6]\) if \(u'\) coincides with u and \(v'\) coincides with v; (ii) \(\Delta _\rho =[3,5]\) if exactly one of \(u'\) and \(v'\) coincides with u and v, respectively; (iii) \(\Delta _\rho =4\) if none of \(u'\) and \(v'\) coincides with u and v. We prove the following.

Lemma 13

Let \(e=(u,v)\) be the reference edge of G and let \(\rho \) be the root of T with respect to e. Let \(\eta \) be the child of \(\rho \) that does not correspond to e. Suppose that \(G_\eta \) is rectilinear planar with representability interval \(I_\eta \). G is rectilinear planar if and only if it satisfies the root condition. Also, if G satisfies the root condition, it admits a rectilinear planar representation H for any value of spirality \(\sigma _\eta \) of \(H_\eta \) such that \(\sigma _\eta \in I_\eta \cap \Delta _\rho \), where \(H_\eta \) is the restriction of H to \(G_\eta \).

Proof

Let \(f_{\textrm{int}}\) be the internal face of G incident to e. Observe that u and v are the poles of \(G_\eta \). Let \(u'\) and \(v'\) be the alias vertices associated with u and with v, respectively. H is a rectilinear planar representation of G if and only if the following two conditions hold: the restriction \(H_\eta \) of H to \(G_\eta \) is a rectilinear planar representation; the number A of right turns minus left turns of any simple cycle of G in H containing e and traversed clockwise in H is equal to 4. We have \(A=\sigma _\eta +\alpha _{u'}+\alpha _{v'}\), where: \(\sigma _\eta \) is the spirality of \(H_\eta \); for \(w\in \{u',v'\}\), \(\alpha _w=1\), \(\alpha _w=0\), and \(\alpha _w=-1\) if the angle formed by w in \(f_{\textrm{int}}\) is equal to \(90^o\), \(180^o\), or \(270^o\), respectively.

According to the definition of root condition, there are three cases to consider: (i) \(\Delta _\rho =[2,6]\), (ii) \(\Delta _\rho =[3,5]\), and (iii) \(\Delta _\rho =4\). Consider Case (i). Since in this case the alias vertices coincide with the poles, we have \(\alpha _{u'} \in [-1,1]\), \(\alpha _{v'} \in [-1,1]\), and hence \(\alpha _{u'}+\alpha _{v'} \in [-2,2]\). If G is rectilinear planar, we have that \(A = \sigma _\eta +\alpha _{u'}+\alpha _{v'}=4\) for some \(\sigma _\eta \in I_\eta \) and for \(\alpha _{u'}+\alpha _{v'} \in [-2,2]\). Hence, \(\sigma _\eta =4-\alpha _{u'}-\alpha _{v'} \in [2,6]\), i.e., the root condition \(I_\eta \cap \Delta _\rho \ne \emptyset \) holds.

Suppose vice versa that the root condition \(I_\eta \cap \Delta _\rho \ne \emptyset \) holds. For any value \(\sigma _\eta \in I_\eta \cap \Delta _\rho \) there exists a rectilinear planar representation of \(H_\eta \) of \(G_\eta \) with spirality \(\sigma _\eta \). Also, since \(\Delta _\rho =[2,6]\), we have that \(4-\sigma _\eta \in [-2,2]\), and therefore, for any possible choice of \(\sigma _\eta \in I_\eta \cap \Delta _\rho \), we can suitably choose \(\alpha _{u'}\) and \(\alpha _{v'}\) such that \(\alpha _{u'}+\alpha _{v'}=4-\sigma _\eta \), i.e., \(A = \sigma _\eta +\alpha _{u'}+\alpha _{v'}=4\). It follows that G is rectilinear planar and it admits a rectilinear planar representation for any value \(\sigma _\eta \in I_\eta \cap \Delta _\rho \).

Cases (ii) and (iii) are proved analogously; in Case (ii) \(\alpha _{u'}+\alpha _{v'}\in [-1,1]\) and in Case (iii) \(\alpha _{u'}+\alpha _{v'}=0\). \(\square \)

Table 1 Representability conditions and intervals for the different types of nodes. In the formulas of the table, the term \(\gamma \) is such that \(\gamma =\lambda +\beta -2\), and \(\phi (\cdot )\) is a function such that \(\phi (r)=1\) and \(\phi (l)=0\)

The next theorem summarizes the main result of this section.

Theorem 2

Let G be a plane series–parallel 4-graph and let T be an SPQ\(^*\)-tree of G. Graph G is rectilinear planar if and only if, for every node of T the corresponding representability condition of Table 1 is satisfied.

5 Overview of the Bend-Minimization Algorithm

Let G be a plane series–parallel 4-graph. If G is biconnected let e be any edge on the external face of G; otherwise, we add a dummy edge e that makes it biconnected. Let T be the SPQ\(^*\)-tree of G with respect to e. Our bend-minimization algorithm works in two phases. It first visits T bottom-up (in post order) to determine the number of bends of a bend-minimum orthogonal representation of G. Then it visits T top-down to construct such an orthogonal representation.

When a node \(\nu \) is considered in the bottom-up visit, the algorithm assigns to \(\nu \) a budget \(b_\nu \) of bends. This budget corresponds to the minimum number of extra bends that must be added to the budgets of the children of \(\nu \) to realize an orthogonal representation of \(G_\nu \). In other words, \(b_\nu \) can be regarded as the minimum number of extra subdivision vertices that must be inserted along the edges of \(G_\nu \) (besides those already inserted for the children of \(\nu \)) to make it rectilinear planar. The budget \(b_\nu \) is larger than zero if and only if the representability condition of the rectilinear planarity testing for \(\nu \) is not satisfied. Hence, according to Table 1, \(b_\nu =0\) if \(\nu \) is a Q\(^*\)- or an S-node, while it can be positive if \(\nu \) is a P-node or the root of T. For instance, for the graph of Fig. 1a and the tree T of Fig. 1c, the first component that requires some bends in the bottom-up visit of T is \(G_{\nu _3}\), namely \(b_{\nu _3}=3\); two more bends are required at the root level, i.e., \(b_{\rho }=2\). When \(b_\nu > 0\), a crucial and non-trivial aspect is how to efficiently compute \(b_\nu \). The other key aspect is how to succinctly describe the set \(I'_\nu \) of spirality values that a rectilinear representation of a subdivision of \(G_\nu \) can take, by considering all possible distributions of the \(b_\nu \) subdivision vertices along its edges. We will show that \(I'_\nu \) is still an interval, which allows us to represent it in O(1) space.

Section 6 describes how to compute the budgets \(b_\nu \) and the sets \(I'_\nu \) in the bottom-up visit of T, and it proves the optimality of the solution. Section 7 describes the top-down visit and summarizes our main result.

6 Budgets and Optimality

In the following we denote by m and M the minimum and maximum values of the representability interval \(I_\nu \) of \(\nu \) when \(G_\nu \) is rectilinear planar, as defined in Table 1. Also, since when we visit \(\nu \), all its children have already been visited and have received their own budget of bends (i.e., of subdivision vertices for the corresponding component), we will simply assume that each child of \(\nu \) is rectilinear planar.

As observed, if \(\nu \) is either a Q\(^*\)-node or an S-node, \(b_\nu =0\). Hence, we assume that \(\nu \) is a P-node. A child \(\mu \) of a (non-root) P-node \(\nu \) is either a Q\(^*\)- or an S-node. To compute \(b_\nu \) and \(I'_\nu \) we define the concept of exposed edge of \(\mu \). If \(\mu \) is a Q\(^*\)-node, every edge of \(G_\mu \) is an exposed edge of \(\mu \) (and of \(G_\mu \)). If \(\mu \) is an S-node with at least one Q\(^*\)-node child \(\mu '\), every edge of \(G_\mu \) that belongs to \(G_{\mu '}\) is an exposed edge of \(\mu \) (and of \(G_\mu \)). Else, \(\mu \) is an S-node that has no exposed edge. Lemma 14 states a crucial property. It implies that when we need to insert some subdivision vertices in an S-component \(\mu \) that is a child of \(\nu \), these vertices can always be added along an exposed edge of \(\mu \), if one exists.

Lemma 14

Let \(\mu \) be an S-node such that \(G_\mu \) is rectilinear planar and \(\mu \) has an exposed edge e. Let \(H_\mu \) be an orthogonal representation of \(G_\mu \) having \(b>0\) bends. There exists an orthogonal representation \(H'_\mu \) of \(G_\mu \) with b bends such that: (i) all the b bends of \(H'_\mu \) lie on e; (ii) \(\sigma (H'_\mu ) = \sigma (H_\mu )\).

Proof

Let u and v be the poles of \(G_\mu \). Any path from u to v inside \(G_\mu \) contains the exposed edge e. Consider an orthogonal representation \(H_\mu \) of \(G_\mu \) with \(b > 0\) bends. Let \(e' \ne e\) be an edge with at least one bend in \(H_\mu \). Let \(P^{uv}\) be any simple path from u to v of \(H_\mu \) passing through \(e'\). Suppose, without loss of generality, that the bend on \(e'\) corresponds to a right turn along \(P^{uv}\) while going from u to v. Since by hypothesis \(G_\mu \) is rectilinear planar, we can derive from \(H_\mu \) a different orthogonal representation \(H''_\mu \) with b bends by simply moving the right bend from \(e'\) to e, i.e., by inserting a right bend along e and by straightening the right bend of \(H_\mu \) along \(e'\). With this transformation, the number of right and left turns along \(P^{uv}\) is the same in \(H''_\mu \) and \(H_\mu \), and the angles at u and v in the two representations are also the same. This implies that \(\sigma (H''_\mu )=\sigma (H_\mu )\). By repeatedly applying this transformation on \(H''_\mu \) until all the b bends of \(H_\mu \) are moved on e we get the desired representation \(H'_\mu \). \(\square \)

Fig. 11
figure 11

Illustration of Lemma 14. a An orthogonal representation \(H_\mu \) of an S-component with spirality 3 and having 3 bends. An exposed edge, shown as a red thick segment. b A different orthogonal representation \(H'_\mu \) of the same component having the same spirality and number of bends as \(H_\mu \), but such that all the bends are along the red thick exposed edge

An illustration of Lemma 14 is given in Fig. 11. In Fig. 11a an orthogonal representation \(H_\mu \) of an S-component is shown. It has spirality 3 and 3 bends. In Fig. 11b a different orthogonal representation \(H'_\mu \) of the same component is given, having the same spirality and number of bends as \(H_\mu \), where all the bends are along an exposed edge.

Observe that, if \(\nu \) is a P-node with three children, each of them has an exposed edge (as the poles of \(\nu \) have degree at most four). If \(\nu \) has two children, it might have a child without exposed edges only if \(\nu \) is of type \(\textrm{I}_{3ll}\) or \(\textrm{I}_{3rr}\) (see Fig. 10). Section 6.1 and Sect. 6.2 focus on the budget of P-nodes with three children and on the budget of P-nodes with two children, respectively. Section 6.3 concentrates on the budget of the root.

6.1 Budget of P-Nodes with Three Children

Lemma 15 handles the case of a P-node \(\nu \) with three children \(\mu _l\), \(\mu _c\), and \(\mu _r\) such that the corresponding components are rectilinear planar, while \(G_\nu \) is not rectilinear planar. Denote by \(I_{\mu _l}=[m_l,M_l]\), \(I_{\mu _c}=[m_c,M_c]\), and \(I_{\mu _r}=[m_r,M_r]\) the representability intervals of \(\mu _l\), \(\mu _c\), and \(\mu _r\), respectively. Since \(G_\nu \) is not rectilinear planar, the representability condition for \(\nu \) is violated, i.e., \([m_l-2, M_l-2] \cap [m_c, M_c] \cap [m_r+2, M_r+2] = \emptyset \) (see the third row of Table 1). Rename the three intervals involved in the representability condition as \([\overline{m}_x,\overline{M}_x]\), \([\overline{m}_y,\overline{M}_y]\), and \([\overline{m}_z,\overline{M}_z]\), where \(x,y,z \in \{l,c,r\}\) and \(x \ne y \ne z\), in such a way that \(\overline{m}_z = \max \{m_l-2, m_c, m_r+2\}\) and \(\overline{M}_x = \min \{M_l-2,M_c,M_r+2\}\). Namely, \(z=l\) if \(\overline{m}_z = m_l-2\), \(z=c\) if \(\overline{m}_z = m_c\), and \(z=r\) if \(\overline{m}_z = m_r+2\). Similarly, \(x=l\) if \(\overline{M}_x = M_l-2\), \(x=c\) if \(\overline{M}_x = M_c\), and \(x=r\) if \(\overline{M}_x = M_r+2\). See Fig. 12a for an example. The following simple property holds.

Fig. 12
figure 12

a Illustration of the notation \(\overline{m}_t\), \(\overline{M}_t\) for \(t\in \{x,y,z\}\). b Illustration of the statement of Lemma 15 for the graph \(G_\nu \). By Property (i) of the lemma \(b_\nu = \overline{m}_z - \overline{M}_x =2\) and by Property (ii) \(I'_\nu = [\max \{\overline{M}_x,\overline{m}_y\}, \min \{\overline{m}_z,\overline{M}_y\}]=[0,2]\)

Proposition 1

\([\overline{m}_x,\overline{M_x}]\) and \([\overline{m}_z,\overline{M}_z]\) are disjoint, with \(\overline{m}_z > \overline{M}_x\).

Proof

Suppose for a contradiction that \(\overline{m}_z \le \overline{M}_x\). Since \(\overline{M}_x\) is the minimum of the three maxima, we have that \(\overline{M}_y\) and \(\overline{M}_z\) are to the right of \(\overline{M}_x\). Also, since \(\overline{m}_z\) is the maximum of three minima, we have that \(\overline{m}_y\) and \(\overline{m}_x\) are to the left of \(\overline{m}_z\). Hence the three intervals \([\overline{m}_x,\overline{M}_x]\), \([\overline{m}_y,\overline{M}_y]\), and \([\overline{m}_z,\overline{M}_z]\) share the interval \([\overline{m}_z,\overline{M}_x]\), which contradicts the fact that \(G_\nu \) is not rectilinear planar. \(\square \)

The next lemma gives the rule for computing the budget of a P-node with three children and for determining the corresponding interval of spirality values, once a number of bends equal to the budget has been added.

Lemma 15

Let \(\nu \) be a P-node with three children \(\mu _l\), \(\mu _c\), and \(\mu _r\). Let \(G_{\mu _l}\), \(G_{\mu _c}\), and \(G_{\mu _r}\) be rectilinear planar with representability intervals \(I_{\mu _l}=[m_l,M_l]\), \(I_{\mu _c}=[m_c,M_c]\), and \(I_{\mu _r}=[m_r,M_r]\), respectively. If \(G_\nu \) is not rectilinear planar then: (i) the budget for \(\nu \) is \(b_\nu = \overline{m}_z - \overline{M}_x\); and (ii) the interval of spirality values for an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends is \(I'_\nu = [\max \{\overline{M}_x,\overline{m}_y\}, \min \{\overline{m}_z,\overline{M}_y\}]\).

Proof

Since by hypothesis \(G_\nu \) is not rectilinear planar, by the representability condition in Table 1 we have \([\overline{m}_x,\overline{M}_x] \cap [\overline{m}_y,\overline{M}_y] \cap [\overline{m}_z,\overline{M}_z] = \emptyset \). By Proposition 1, \([\overline{m}_x,\overline{M}_x] \cap [\overline{m}_z,\overline{M}_z] = \emptyset \). We prove Property (i) and (ii) separately. Figure 12b provides an illustration for the graph in Fig. 12a, where \(x=c\), \(y=l\), and \(z=r\). \(\square \)

Proof of Property (i). We show that \(b_\nu = \overline{m}_z - \overline{M}_x\). Observe that each of the three components \(G_{\mu _l}\), \(G_{\mu _c}\), and \(G_{\mu _r}\) is an S-component with an exposed edge.

We first prove that \(b_\nu \) bends are necessary. Suppose for a contradiction that \(G_\nu \) admits an orthogonal representation \(H'_\nu \) with \(b_\nu '< b_\nu \) bends. Denote by \(b'_x\) and \(b'_z\) the number of bends in the restriction of \(H'_\nu \) to \(G_{\mu _x}\) and to \(G_{\mu _z}\), respectively. By Lemma 14, we can assume that all the bends \(b'_x\) are along an exposed edge of \(G_{\mu _x}\) and all the bends \(b'_z\) are along an exposed edge of \(G_{\mu _z}\). Consider the underlying graph \(G'_\nu \) of \(H'_\nu \) obtained by replacing each bend of \(H'_\nu \) with a subdivision vertex. \(G'_\nu \) is rectilinear planar. Denote by \([m_x',M_x']\) and \([m_z',M_z']\) the spirality intervals of \(G'_{\mu _x}\) and \(G'_{\mu _z}\). Note that each subdivision vertex along an exposed edge of \(G'_{\mu _x}\) allows one more turn (either to the left or to the right) in a rectilinear planar representation of this component with respect to a rectilinear planar representation of \(G_{\mu _x}\). Hence, the spirality interval of \(G'_{\mu _x}\) extends the one of \(G_{\mu _x}\) by \(b'_x\) units, both for the minimum value and for the maximum value. The same reasoning applies to \(G'_{\mu _z}\). It follows that \(m_x'=m_x-b'_x\), \(M_x'=M_x+b'_x\), \(m_z'=m_z-b'_z\), and \(M_z'=M_z+b'_z\). Consider the three representability intervals \([m'_l-2,M'_l-2]\), \([m'_c,M'_c]\), and \([m'_r+2,M'_r+2]\) for \(G'_{\mu _l}\), \(G'_{\mu _c}\), and \(G'_{\mu _r}\), respectively. Suppose that \(x=l\), i.e., \(\min \{M_l-2, M_c, M_r+2\}=M_l-2\); then we define \(\overline{m}'_x = m'_l-2\) and \(\overline{M}'_x=M'_l-2\). Similarly, if \(x=c\), we define \(\overline{m}'_x = m'_c\) and \(\overline{M}'_x=M'_c\). Finally, if \(x=r\), we define \(\overline{m}'_x = m'_r+2\) and \(\overline{M}'_x=M'_r+2\). Analogously, if \(z=l\), i.e. \(\max \{m_l-2, m_c, m_r+2\}=m_l-2\), we define \(\overline{m}'_z = m_l-2\); if \(z=c\), we define \(\overline{m}'_z = m'_c\) and \(\overline{M}'_z=M'_c\); if \(z=r\), we define \(\overline{m}'_z = m'_r+2\) and \(\overline{M}'_z=M'_r+2\). Figure 13 illustrates this notation for the graph of Fig. 12a.

Fig. 13
figure 13

Illustration for the proof of Property (i) of Lemma 15, on graph \(G_\nu \) in Fig. 12a

We have, \(\overline{m}'_x=\overline{m}_x-b'_x\), \(\overline{m}'_z=\overline{m}_z-b'_z\), \(\overline{M}'_x=\overline{M}_x+b'_x\), and \(\overline{M}'_z=\overline{M}_z+b'_z\). Since \(G_\nu '\) is rectilinear planar, we have \([\overline{m}'_x,\overline{M}'_x] \cap [\overline{m}'_z,\overline{M}'_z]=[\overline{m}_x-b'_x,\overline{M}_x+b'_x] \cap [\overline{m}_z-b'_z,\overline{M}_z+b'_z] \not = \emptyset \). Therefore, \(\overline{m}_z-b'_z\le \overline{M}_x+b'_x\), which implies \(b_\nu =\overline{m}_z-\overline{M}_x \le b'_x+b'_z\le b'_\nu < b_\nu \), a contradiction.

We now prove that \(b_\nu \) bends suffice. Let \(b_x\) and \(b_z\) be two non-negative integers such that \(b_x+b_z=b_\nu \), \(b_x\ge \overline{m}_y-\overline{M}_x\), and \(b_z\ge \overline{m}_z-\overline{M}_y\). Note that \(b_x\) and \(b_z\) always exist because \(\overline{m}_y-\overline{M}_x+\overline{m}_z-\overline{M}_y=b_\nu -\overline{M}_y+\overline{m}_y\le b_\nu \). Insert \(b_x\) subdivision vertices on any exposed edge of \(G_{\mu _x}\) and insert \(b_z\) subdivision vertices on any exposed edge of \(G_{\mu _z}\). Clearly no subdivision vertex has been inserted on \(G_{\mu _y}\) since \(b_x+b_z=b_\nu \). Call \(G'_{\mu _x}\), \(G'_{\mu _y}\), and \(G'_{\mu _z}\) the resulting components (note that \(G'_{\mu _y}=G_{\mu _y}\)). Define \(\overline{m}'_x\), \(\overline{m}'_z\), \(\overline{M}'_x\), \(\overline{M}'_z\) as in the first part of the proof. Suppose that \(y = l\), i.e. \(\min \{M_l-2, M_c, M_r+2\}\not =M_l-2\) and \(\max \{m_l-2, m_c, m_r+2\}\not =m_l-2\). Then we define \(\overline{m}'_y = m'_l-2\) and \(\overline{M}'_y=M'_l-2\). Similarly, if \(y = c\), define \(\overline{m}'_y = m'_c\) and \(\overline{M}'_y=M'_c\). Finally, if \(y = r\), we define \(\overline{m}'_y = m'_r+2\) and \(\overline{M}'_y = M'_r+2\).

Consider the plane graph \(G'_{\nu }\) obtained by the union of \(G'_{\mu _x}\), \(G'_{\mu _y}\), and \(G'_{\mu _z}\). To prove that \(G'_\nu \) is rectilinear planar, by the representability condition in Table 1, it suffices to show that \([\overline{m}'_x,\overline{M}'_x]\cap [\overline{m}'_y,\overline{M}'_y]\cap [\overline{m}'_z,\overline{M}'_z]=[\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]\not = \emptyset \). We have:

  • \(b_x\ge \overline{m}_y-\overline{M}_x\), hence \(\overline{m}_y\le \overline{M}_x+b_x\) and \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\not = \emptyset \);

  • \(b_z\ge \overline{m}_z-\overline{M}_y\), hence \(\overline{m}_z-b_z\le \overline{M}_y\) and \([\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]\not = \emptyset \);

  • \(\overline{m}_z-\overline{M}_x=b_z+b_x=b_\nu \), hence \(\overline{m}_z-b_z= \overline{M}_x+b_x\) and \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]\not = \emptyset \).

Hence \(G'_{\nu }\) has a rectilinear planar representation \(H'_{\nu }\); replacing its subdivision vertices with bends, we get an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends.

Proof of Property (ii). We show that set \(I'_\nu \) is an interval of feasible spirality values for the orthogonal representations of \(G_\nu \) with \(b_\nu \) bends. Namely, we show that any orthogonal representation \(H_\nu \) of \(G_\nu \) with \(b_\nu \) bends has spirality in the interval \(I_\nu '\) and that for every value \(\sigma _\nu \in I_\nu '\) there exists an orthogonal representation of \(G_\nu \) with spirality \(\sigma _\nu \) and \(b_\nu \) bends.

Suppose that \(G_\nu \) has an orthogonal representation \(H_\nu \) with \(b_\nu \) bends and let \(\sigma _\nu \) be the spirality of \(H_\nu \). We prove that \(\sigma _\nu \in I'_\nu = [\max \{\overline{M}_x,\overline{m}_y\}, \min \{\overline{m}_z,\overline{M}_y\}]\). Let \(b_l\), \(b_c\), and \(b_r\) be the number of bends in the restriction of \(H_\nu \) to \(G_{\mu _l}\), \(G_{\mu _C}\), and \(G_{\mu _r}\), respectively, where \(b_l+b_c+b_r=b_\nu \). Let \(H'_\nu \) be the rectilinear planar representation obtained from \(H_\nu \) by replacing each bend with a subdivision vertex and let \(G_\nu '\) be the underlying graph. Clearly the spirality of \(H_\nu '\) equals \(\sigma _\nu \). For any \(t\in \{x,y,z\}\), by Lemma 14 we can assume that all the \(b_t\) bends are along an exposed edge of \(G_{\mu _t}\) and, consequently, \(\sigma _{\mu _t'}\in [m_t-b_t, M_t+b_t]\). By using the same notation as in the proof of Property (i) we define \(\overline{m}'_x = m'_l-2\) and \(\overline{M}'_x=M'_l-2\) if \(x = l\), \(\overline{m}'_x = m'_c\) and \(\overline{M}'_x=M'_c\) if \(x = c\), and \(\overline{m}'_x = m'_r+2\) and \(\overline{M}'_x = M'_r+2\) if \(x = r\). The values \(\overline{m}'_y\), \(\overline{M}'_y\), \(\overline{m}'_z\), and \(\overline{M}'_z\) are defined analogously (see Fig. 13). Since \(G'_\nu \) is rectilinear planar, by Table 1 we have \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y-b_y,\overline{M}_y+b_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]\not = \emptyset \).

The remainder of the proof exploits the following claim. For an example see Fig. 12b, where every bend is regarded as a subdivision vertex, and where \(b_y=0\), \(b_x\le \overline{M}_y-\overline{M}_x=2-0=2\), and \(b_z\le \overline{m}_z-\overline{m}_y=2+6=8\) in the three rectilinear representations of \(G_\nu '\).

Claim 1

These relations hold: (1) \(b_y=0\); (2) \(b_x\le \overline{M}_y-\overline{M}_x\); (3) \(b_z\le \overline{m}_z-\overline{m}_y\).

Claim Proof

We prove the three relations by contradiction.

  1. (1)

    If \(b_y>0\), then \(b_x+b_z< b_\nu =\overline{m}_z - \overline{M}_x\). Hence, \(\overline{M}_x+b_x<\overline{m}_z-b_z\) and \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=\emptyset \), a contradiction.

  2. (2)

    If \(b_x> \overline{M}_y-\overline{M}_x\), then \(b_y+b_z< b_\nu -(\overline{M}_y-\overline{M}_x)=\overline{m}_z - \overline{M}_x-(\overline{M}_y-\overline{M}_x)=\overline{m}_z-\overline{M}_y\). Hence, \(\overline{M}_y+b_y<\overline{m}_z-b_z\) and \([\overline{m}_y-b_y,\overline{M}_y+b_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z] = \emptyset \), a contradiction.

  3. (3)

    If \(b_z> \overline{m}_z-\overline{m}_y\), then \(b_x+b_y< b_\nu -(\overline{m}_z-\overline{m}_y)=\overline{m}_z - \overline{M}_x-(\overline{m}_z-\overline{m}_y)=\overline{m}_y-\overline{M}_x\). Hence, \(\overline{M}_x+b_x<\overline{m}_y-b_y\) and \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y-b_y,\overline{M}_y+b_y]= \emptyset \), a contradiction.

Fig. 14
figure 14

The four possible cases for the proof of Property (ii) of Lemma 15

We now consider spirality values of the components of \(H'_\nu \) and define related values \(\overline{\sigma }_{\mu _x'}=\sigma _{\mu _x'}-2\) if \(x = l\), \(\overline{\sigma }_{\mu _x'}=\sigma _{\mu _x'}\) if \(x = c\), and \(\overline{\sigma }_{\mu _x'}=\sigma _{\mu _x'}+2\) if \(x = r\). The values \(\overline{\sigma }_{\mu '_y}\) and \(\overline{\sigma }_{\mu '_z}\) are defined analogously. See Fig. 13 for an illustration of the notation \(\overline{\sigma }_{\mu _t'}\) for \(t\in \{x,y,z\}\). We have \(\overline{\sigma }_{\mu '_t}\in [\overline{m}_t-b_t,\overline{M}_t+b_t]\) for any \(t\in \{x,y,z\}\). Also, by Lemma 2\(\sigma _\nu =\overline{\sigma }_{\mu _x'}= \overline{\sigma }_{\mu _y'}=\overline{\sigma }_{\mu _z'}\). Hence \(\sigma _\nu \in [\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y-b_y,\overline{M}_y+b_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]\). Note that by Relation (1) of the claim \([\overline{m}_y-b_y,\overline{M}_y+b_y]=[\overline{m}_y,\overline{M}_y]\). We show that \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\max \{\overline{M}_x,\overline{m}_y\}, \min \{\overline{m}_z,\overline{M}_y\}]\). We have four cases; see Fig. 14.

Case (a): \(\overline{M}_x<\overline{m}_y\) and \(\overline{M}_y<\overline{m}_z\) (see Fig. 14a). In this case \(I'_\nu =[\max \{\overline{M}_x,\overline{m}_y\}, \min \{\overline{m}_z,\overline{M}_y\}] = [\overline{m}_y,\overline{M}_y]\). Refer to Fig. 15 for an illustration of the argument that refines Fig. 14a).

Fig. 15
figure 15

A more detailed illustration for Case (a) in the proof of Lemma 15. For any value \(\sigma _\nu \in I'_\nu \), we need to add \(b_x = \sigma _\nu - \overline{M}_x = (\sigma _\nu -\overline{m}_y)+(\overline{m}_y-\overline{M}_x)\) bends to the representation of \(G_{\mu _x}\) and \(b_z = \overline{m}_z-\sigma _\nu = (\overline{m}_z-\overline{M}_y) + (\overline{M}_y-\sigma _\nu )\) bends to the representation of \(G_{\mu _z}\)

First we prove that \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]=[\overline{m}_y,\overline{M}_y]\). We have \(\overline{M}_x+b_x\ge \overline{m}_y\), or \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]=\emptyset \). By Relation (2) of the claim we have \(b_x\le \overline{M}_y-\overline{M}_x\). Hence, \(b_x\in [\overline{m}_y-\overline{M}_x,\overline{M}_y-\overline{M}_x]\). We have \(\overline{M}_x+b_x\in [\overline{M}_x+\overline{m}_y-\overline{M}_x,\overline{M}_x+\overline{M}_y-\overline{M}_x]=[\overline{m}_y,\overline{M}_y]\). It follows that \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]=[\overline{m}_y,\overline{M}_y]\).

Second, we prove \([\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{M}_y]\). We have \(\overline{M}_y\ge \overline{m}_z-b_z\), or \([\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z] =\emptyset \). By Relation (3) of the claim we have \(b_z\le \overline{m}_z-\overline{m}_y\). Hence, \(b_z\in [\overline{m}_z-\overline{M}_y,\overline{m}_z-\overline{m}_y]\). We have \(\overline{m}_z-b_z\in [\overline{m}_z-\overline{m}_z+\overline{m}_y,\overline{m}_z-\overline{m}_z-\overline{M}_y]=[\overline{m}_y,\overline{M}_y]\).

It follows that \([\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{M}_y]\).

Hence, \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{M}_y]=I'_\nu \).

Case (b): \(\overline{M}_x\ge \overline{m}_y\) and \(\overline{M}_y<\overline{m}_z\) (see Fig. 14b). In this case \(I'_\nu =[\overline{M}_x,\overline{M}_y]\). By the same reasoning as in Case (a) we have \([\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{M}_y]\).

We prove that \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]=[\overline{M}_x,\overline{M}_y]\).

By Relation (2) of the claim \(b_x\in [0,\overline{M}_y-\overline{M}_x]\). We have \(\overline{M}_x+b_x\in [\overline{M}_x,\overline{M}_x+\overline{M}_y-\overline{M}_x]=[\overline{M}_x,\overline{M}_y]\). It follows that \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]=[\overline{M}_x,\overline{M}_y]\).

Hence, since \(\overline{M}_x\ge \overline{m}_y\), we have \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{M}_y]\cap [\overline{M}_x,\overline{M}_y]=[\overline{M}_x,\overline{M}_y]=I'_\nu \).

Case (c): \(\overline{M}_x<\overline{m}_y\) and \(\overline{M}_y\ge \overline{m}_z\) (see Fig. 14c). In this case \(I'_\nu =[\overline{m}_y,\overline{m}_z]\). It is possible to prove that \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]=[\overline{m}_y,\overline{M}_y]\) as we did in Case (a).

We prove \([\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{m}_z]\). By Relation (3) of the claim \(b_z\in [0,\overline{m}_z-\overline{m}_y]\). We have \(\overline{m}_z-b_z\in [\overline{m}_z-\overline{m}_z+\overline{m}_y,\overline{m}_z]=[\overline{m}_y,\overline{m}_z]\).

It follows that \([\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{m}_z]\).

Hence, since \(\overline{M}_y\ge \overline{m}_z\), we have \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{M}_y]\cap [\overline{m}_y,\overline{m}_z]= [\overline{m}_y,\overline{m}_z]=I'_\nu \).

Case (d): \(\overline{M}_x\ge \overline{m}_y\) and \(\overline{M}_y\ge \overline{m}_z\) (see Fig. 14d). In this case \(I'_\nu =[\overline{M}_x,\overline{m}_z]\). It is possible to prove that \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]=[\overline{M}_x,\overline{M}_y]\) as we did in Case (b) and that \([\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_y,\overline{m}_z]\) as we did for Case (c).

We have \([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{M}_x,\overline{M}_y]\cap [\overline{m}_y,\overline{m}_z]=[\overline{M}_x,\overline{m}_z]\) since \(\overline{M}_x\ge \overline{m}_y\) and \(\overline{M}_y\ge \overline{m}_z\). Hence,

\([\overline{m}_x-b_x,\overline{M}_x+b_x]\cap [\overline{m}_y,\overline{M}_y]\cap [\overline{m}_z-b_z,\overline{M}_z+b_z]=[\overline{M}_x,\overline{m}_z]=I'_\nu \).

Suppose now that we are given \(\sigma _\nu \in I'_\nu =[\max \{\overline{M}_x,\overline{m}_y\}, \min \{\overline{m}_z,\overline{M}_y\}]\). We show that there exists an orthogonal representation \(H_\nu \) of \(G_\nu \) with \(b_\nu \) bends and with spirality \(\sigma _\nu \). This is equivalent to showing that there exists a plane graph \(G'_\nu \) obtained by adding \(b_\nu \) subdivision vertices along some edges of \(G_\nu \) such that \(G'_\nu \) has a rectilinear orthogonal representation with spirality \(\sigma _\nu \). To construct \(G'_\nu \) we insert a suitable number \(b_z\in [0,b_\nu ]\) of subdivision vertices on an exposed edge of \(G_{\mu _z}\) and \(b_x=b_\nu -b_z\) subdivision vertices on an exposed edge of \(G_{\mu _x}\) (as a consequence, we do not insert any subdivision vertex in \(G_{\mu _y}\)). Let \(G'_{\mu _x}\), \(G'_{\mu _y}\), and \(G'_{\mu _z}\) be the resulting graphs. Since by hypothesis \(G_{\mu _x}\), \(G_{\mu _y}\), and \(G_{\mu _z}\) are rectilinear planar, we have that also \(G'_{\mu _x}\), \(G'_{\mu _y}\), and \(G'_{\mu _z}\) are rectilinear planar. Also, with the same reasoning as in the proof of Property (i), the representability intervals of \(G'_{\mu _x}\), \(G'_{\mu _y}\), and \(G'_{\mu _z}\) are \([m'_x,M'_x]=[m_x-b_x,M_x+b_x]\), \([m_y,M_y]\), and \([m_z-b_z,M_z+b_z]\), respectively. For any \(t\in \{x,y,z\}\) we define \(\overline{m}'_t\), \(\overline{M}'_t\), and \(\overline{\sigma }_{\mu _t'}\) as in the first part of the proof of Property (ii). We now describe how to compute \(b_x\) and \(b_z\), and how to set \(\overline{\sigma }_{\mu _x}\), \(\overline{\sigma }_{\mu _y}\), and \(\overline{\sigma }_{\mu _z}\). Let \(c_1=\max \{\overline{M}_x,\overline{m}_y\}\) and \(c_2= \min \{\overline{m}_z,\overline{M}_y\}\).

We have: \(c_1=\overline{m}_y\) and \(c_2=\overline{M}_y\) in the case of Fig. 14a; \(c_1=\overline{M}_x\) and \(c_2=\overline{M}_y\) in the case of Fig. 14b; \(c_1=\overline{m}_y\) and \(c_2=\overline{m}_z\) in the case of Fig. 14c; \(c_1=\overline{M}_x\) and \(c_2=\overline{m}_z\) in the case of Fig. 14d.

We have \(\sigma _\nu \in I'_\nu =[c_1,c_2]\). We set \(b_z=\overline{m}_z-\sigma _\nu \) and, consequently, \(b_x=b_\nu -b_z=b_\nu -\overline{m}_z+\sigma _\nu =\overline{M}_x+\sigma _\nu \). We prove that \(b_z\) (and consequently \(b_x\)) is in the interval \([0,b_\nu ]\). We have \(b_z=\overline{m}_z-\sigma _\nu \in [\overline{m}_z-c_2,\overline{m}_z-c_1] \subseteq [\overline{m}_z-\overline{m}_z,\overline{m}_z-\overline{M}_x]\), since \(c_2\le \overline{m}_z\) and \(c_1\ge \overline{M}_x\). Hence \(b_z\in [\overline{m}_z-\overline{m}_z,\overline{m}_z-\overline{M}_x]=[0,b_\nu ]\). We now set \(\overline{\sigma }_{\mu _x}=\overline{M}_x+b_x=\sigma _\nu \) and \(\overline{\sigma }_{\mu _z}=\overline{m}_z-b_z=\sigma _\nu \). Notice that \(\sigma _\nu \in [c_1,c_2]\in [\overline{m}_y,\overline{M}_y]\). Hence, it is possible to set \(\overline{\sigma }_{\mu _y}=\sigma _\nu \). By Lemma 2 we can get a rectilinear planar representation \(H'_\nu \) of \(G'_\nu \) by a parallel composition of rectilinear planar representations of \(G'_{\mu _x}\), \(G'_{\mu _y}\), and \(G'_{\mu _z}\) with spirality values \(\overline{\sigma }_{\mu _x}\), \(\overline{\sigma }_{\mu _y}\), and \(\overline{\sigma }_{\mu _z}\), respectively. By the same lemma, the spirality of \(H'_\nu \) is \(\sigma _\nu '=\overline{\sigma }_{\mu _x}=\overline{\sigma }_{\mu _y}=\overline{\sigma }_{\mu _z}=\sigma _\nu \). By replacing the subdivision vertices of \(H'_\nu \) with bends we get an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends and spirality \(\sigma _\nu \).

6.2 Budget of P-Nodes with Two Children

Let \(\mu _l\) and \(\mu _r\) be the two children of \(\nu \), and suppose that \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar with representability intervals \(I_{\mu _l}=[m_l,M_l]\) and \(I_{\mu _r}=[m_r,M_r]\), respectively. The representability condition for \(\nu \) given in Table 1 is expressed in terms of the intersection between the interval \([m_l-M_r, M_l-m_r]\) and another interval \(\Delta _\nu \) that depends on the type of P-node. Specifically: \(\Delta _\nu = [2,4-\gamma ]\) if \(\nu \) is of type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\); \(\Delta _\nu = [\frac{5}{2}, \frac{7}{2} - \gamma ]\) if \(\nu \) is of type \(\textrm{I}_{3d}\textrm{O}_{\lambda \beta }\); and \(\Delta _\nu = [3,3]\) if \(\nu \) is of type \(\textrm{I}_{3dd'}\). In the following, given two non-intersecting intervals of real numbers \(A_1 = [m_1,M_1]\) and \(A_2 = [m_2,M_2]\), the distance between \(A_1\) and \(A_2\) is defined as \(\delta (A_1, A_2)=\min \{|M_1-m_2 |, |M_2-m_1 |\}\).

Section 6.2.1 handles the case of a P-node with two children both having an exposed egde. Section 6.2.2 handles the more involved cases in which either the left child or the right child of the P-node has no exposed edge. Note that, since the vertex-degree is at most four, at least one of the two children of the P-node must have an exposed edge. We start giving two simple combinatorial results (Lemmas 16 and 17), which will be used in the proof of Lemma 18. They provide some basic rules about the values that some terms of the relationships in Lemma 3 can take, depending on the type of P-nodes with two children.

Lemma 16

Let \(\nu \) be a P-node of type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\) with children \(\mu _l\) and \(\mu _r\). Let \(G_{\mu _l}\) and \(G_{\mu _r}\) be rectilinear planar. For any rectilinear planar representation of \(G_{\mu _l}\) and \(G_{\mu _r}\), and for any \(d\in \{l,r\}\), the following relation holds:

$$\begin{aligned} k_{u}^d \alpha _{u}^d + k_{v}^d\alpha _v^d=h \Leftrightarrow h\in [\frac{\gamma }{2},2-\frac{\gamma }{2}], \end{aligned}$$

where both h and \(\frac{\gamma }{2}\) are either integer or semi-integer numbers.

Proof

For the reader’s convenience, we summarize in Table 2 the parameters associated with each type of P-node with two children. Based on these parameters, we analyze three cases:

  • \(\lambda =\beta =1\). In this case, \(\gamma =\lambda +\beta -2=0\), \(h \in \{0,1,2\}\), and \(k_u^l=k_v^l=k_u^r=k_v^r=1\) (see Table 2). Hence, \(k_{u}^d \alpha _{u}^d + k_{v}^d\alpha _v^d= \alpha _{u}^d + \alpha _v^d\). Since both poles u and v have outdegree one, both \(\alpha _{u}^d\) and \(\alpha _v^d\) can take either value 0 or 1, hence \(\alpha _{u}^d + \alpha _v^d\) can take all and only the values in the set \(\{0,1,2\}\).

  • \(\lambda =1\) and \(\beta =2\). In this case \(\gamma =1\), \(h \in \{\frac{1}{2},\frac{3}{2}\}\), \(k_u^l=k_u^r=1\), and \(k_v^l=k_v^r=\frac{1}{2}\) (see Table 2). Hence, \(k_{u}^d \alpha _{u}^d + k_{v}^d\alpha _v^d= \alpha _{u}^d + \frac{1}{2}\alpha _v^d\). Since we are assuming that \(\textrm{outdeg} (u)=1\) and \(\textrm{outdeg} (v)=2\), we have \(\alpha _{u}^d\in \{0,1\}\) and \(\alpha _v^d=1\), i.e., \(\alpha _{u}^d + \frac{1}{2}\alpha _v^d\) equals either \(\frac{1}{2}\) or \(\frac{3}{2}\).

  • \(\lambda =\beta =2\). In this case \(\gamma =2\), \(c \in \{1\}\), and \(k_u^l=k_u^r=k_v^l=k_v^r=\frac{1}{2}\) (see Table 2). Hence, \(k_{u}^d \alpha _{u}^d + k_{v}^d\alpha _v^d= \frac{1}{2}\alpha _{u}^d + \frac{1}{2}\alpha _v^d\). Since \(\textrm{outdeg} (u)=\textrm{outdeg} (v)=2\), we have \(\alpha _{u}^d=\alpha _v^d=1\).

\(\square \)

Table 2 Parameters for the P-nodes with 2 children

Lemma 17

Let \(\nu \) be a P-node of type \(\textrm{I}_{3\,l}\textrm{O}_{\lambda \beta }\) with children \(\mu _l\) and \(\mu _r\). Let \(G_{\mu _l}\) and \(G_{\mu _r}\) be rectilinear planar. For any rectilinear planar representation of \(G_{\mu _l}\) and \(G_{\mu _r}\), the following relations hold:

$$\begin{aligned} k_{u}^l \alpha _{u}^l +k_{v}^l\alpha _v^l=h_l \Leftrightarrow h_l \in [\frac{\gamma }{2}+\frac{1}{2},\frac{3}{2}-\frac{\gamma }{2}], \end{aligned}$$
(1)

where both \(h_l\) and \(\frac{\gamma }{2}+\frac{1}{2}\) are either integer or semi-integer numbers.

$$\begin{aligned} k_{u}^r \alpha _{u}^r +k_{v}^r\alpha _v^r=h_r \Leftrightarrow h_r \in [\frac{\gamma }{2}+1,2-\frac{\gamma }{2}], \end{aligned}$$
(2)

where both \(h_r\) and \(\frac{\gamma }{2}+1\) are either integer or semi-integer numbers.

Proof

\(k_v^l=\frac{1}{2}\), \(k_v^r=1\), and \(\alpha _v^d=1\) for any \(d \in \{l,r\}\). There are two subcases:

  • \(\beta =1\). In this case \(\gamma =0\), \(h_l \in \{\frac{1}{2},\frac{3}{2}\}\), \(h_r \in \{1,2\}\), and \(k_u^l=k_u^r=1\). We have \(k_{u}^d \alpha _{u}^d + k_{v}^d\alpha _v^d= \alpha _{u}^d +k_v^d\). Since \(\alpha _u^d \in \{0,1\}\), we have \(\alpha _{u}^d +k_v^d\in \{k_v^d,k_v^d +1\}\). Since \(k_v^l=\frac{1}{2}\), we have \(\{k_v^l,k_v^l +1\}=\{\frac{1}{2},\frac{3}{2}\}=\{\frac{\gamma }{2}+\frac{1}{2},\frac{3}{2}-\frac{\gamma }{2}\}\). Hence, Relation 1 holds. Since \(k_v^r=1\), we have \(\{k_v^r,k_v^r +1\}=\{1,2\}=\{\frac{\gamma }{2}+1,2-\frac{\gamma }{2}\}\). Hence, Relation 2 holds.

  • \(\beta =2\). In this case \(\gamma =1\), \(h_l \in \{1\}\), \(h_r \in \{\frac{3}{2}\}\), and \(k_u^l=k_u^r=\frac{1}{2}\). Since \(\deg (u)=4\), \(\alpha _u^d=1\). We have \(k_{u}^d \alpha _{u}^d + k_{v}^d\alpha _v^d= \frac{1}{2}+k_v^d\). Equivalently, \(k_{u}^d \alpha _{u}^d + k_{v}^d\alpha _v^d \in \{\frac{1}{2}+k_v^d, \frac{1}{2}+k_v^d\}\). Since \(k_v^l=\frac{1}{2}\), we have \(\{\frac{1}{2}+k_v^l,\frac{1}{2}+k_v^l\}=\{\frac{\gamma }{2}+\frac{1}{2},\frac{3}{2}-\frac{\gamma }{2}\}=\{1\}\). Hence, Relation 1 holds. Since \(k_v^r=1\), we have \(\{\frac{1}{2}+k_v^r,\frac{1}{2}+k_v^r\}=\{\frac{\gamma }{2}+1,2-\frac{\gamma }{2}\}=\{\frac{3}{2}\}\). Hence, Relation 2 holds.

\(\square \)

6.2.1 P-Nodes with Both Children Having an Exposed Edge

As mentioned at the beginning of Sect. 6, in the following we denote by m and M the minimum and the maximum values of the interval \(I_\nu \) as defined in Table 1. The next lemma gives the rule for computing the budget of a P-node with two children each having an exposed edge, and for determining the corresponding interval of spirality values.

Lemma 18

Let \(\nu \) be a P-node with two children \(\mu _l\) and \(\mu _r\), each having an exposed edge. Let \(G_{\mu _l}\) and \(G_{\mu _r}\) be rectilinear planar with representability intervals \(I_{\mu _l}=[m_l,M_l]\) and \(I_{\mu _r}=[m_r,M_r]\), respectively. If \(G_\nu \) is not rectilinear planar then: (i) the budget for \(\nu \) is \(b_\nu =\delta ([m_l-M_r, M_l-m_r],\Delta _\nu )\); and (ii) the set of spirality values for an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends is the interval \(I'_\nu = [m-b_\nu , M+b_\nu ]\).

Proof

Since by hypothesis \(G_\nu \) is not rectilinear planar, we have \([m_l-M_r, M_l-m_r] \cap \Delta _\nu = \emptyset \). Figure 16 illustrates the statement for a P-node \(\nu \) of type \(\textrm{I}_{2}\textrm{O}_{11}\), by also showing how the interval \(I'_\nu \) of Property (ii) is defined.

Proof of Property (i). We show that \(b_\nu = \delta ([m_l-M_r, M_l-m_r],\Delta _\nu )\). We first prove that \(b_\nu \) bends are necessary. Suppose for a contradiction that \(G_\nu \) admits an orthogonal representation \(H'_\nu \) with \(b'_\nu < b_\nu \) bends. Denote by \(b'_l\) and \(b'_r\) the number of bends in the restriction of \(H'_\nu \) to \(G_{\mu _l}\) and to \(G_{\mu _r}\), respectively. By Lemma 14, we can assume that all the bends \(b'_l\) (resp. \(b'_r\)) are along an exposed edge of \(G_{\mu _l}\) (resp. \(G_{\mu _r}\)). Consider the underlying graph \(G'_\nu \) of \(H'_\nu \) obtained by replacing each bend of \(H'_\nu \) with a subdivision vertex. \(G'_\nu \) is rectilinear planar. Also, each subdivision vertex along an exposed edge of \(G_{\mu _l}\) allows one more turn (either to the left or to the right) in a rectilinear representation of this component, i.e., it extends the spirality interval of \(G_{\mu _l}\) by one unit, both for the minimum value and for the maximum value. The same considerations happen for \(G_{\mu _r}\). Hence \(G'_{\mu _l}\) and \(G'_{\mu _r}\) are rectilinear planar with representability intervals \([m_l-b'_l,M_l+b'_l]\) and \([m_r-b'_r,M_r+b'_r]\), respectively, and the representability condition for \(G'_\nu \) is \([m_l-b'_l-M_r-b'_r, M_l+b'_l-m_r+b'_r] \cap \Delta _\nu \ne \emptyset \). Since \(b'_l+b'_r=b'_\nu \), we have \([m_l-M_r-b'_\nu , M_l-m_r+b'_\nu ] \cap \Delta _\nu \ne \emptyset \), which implies \(\delta ([m_l-M_r,M_l-m_r],\Delta _\nu ) \le b'_\nu < b_\nu \), a contradiction.

Fig. 16
figure 16

Illustration of Lemma 18 for a P-node \(\nu \) of type \(\textrm{I}_{2}\textrm{O}_{11}\), where \(m_l=M_l=0\) and \(m_r=M_r=1\). In this case \(\Delta _\nu = [2,4]\), \(m=\max \{m_l-2,m_r\}=-1\), and \(M=\min \{M_l,M_r+2\}=0\). Since \(M_l-m_r<2\), \(G_\nu \) is not rectilinear planar. By Property (i), \(b_\nu =\delta ([m_l-M_r, M_l-m_r],\Delta _\nu )=3\); by Property (ii), \(I'_\nu =[m-b_\nu ,M+b_\nu ]=[-2,3]\)

We now prove that \(b_\nu \) bends suffice. Let \(b_l\) and \(b_r\) be two arbitrarily chosen non-negative integers such that \(b_l+b_r=b_\nu \). Insert \(b_l\) (resp. \(b_r\)) subdivision vertices on any exposed edge of \(G_{\mu _l}\) (resp. \(G_{\mu _r}\)). Call \(G'_{\mu _l}\) and \(G'_{\mu _r}\) the resulting components. Since by hypothesis \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar, with the same argument as above, \(G'_{\mu _l}\) and \(G'_{\mu _r}\) are both rectilinear planar with representability intervals \([m_l-b_l,M_l+b_l]\) and \([m_r-b_r,M_r+b_r]\), respectively. Consider the plane graph \(G'_{\nu }\) obtained by the union of \(G'_{\mu _l}\) and \(G'_{\mu _r}\). Since by hypothesis \(b_\nu = \delta ([m_l-M_r, M_l-m_r],\Delta _\nu )\), we have that \([m_l-M_r-b_\nu , M_l-m_r+b_\nu ] \cap \Delta _\nu \ne \emptyset \). Since \([m_l-b_l-M_r-b_r, M_l+b_l-m_r+b_r] = [m_l-M_r-b_\nu , M_l-m_r+b_\nu ]\) we have \([m_l-b_l-M_r-b_r, M_l+b_l-m_r+b_r] \cap \Delta _\nu \ne \emptyset \). It follows that \(G'_{\nu }\) admits a rectilinear planar representation \(H'_{\nu }\). By replacing the \(b_\nu \) subdivision vertices of \(H'_{\nu }\) with bends, we get an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends.

Proof of Property (ii). Suppose without loss of generality that \(\textrm{outdeg} (u) \le \textrm{outdeg} (v)\). Denote by \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) the spirality values of orthogonal representations of \(G_{\mu _l}\) and \(G_{\mu _r}\), respectively. We distinguish three cases, based on the types of \(\nu \), namely type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\), \(\textrm{I}_{3d}\textrm{O}_{\lambda \beta }\), and type \(\textrm{I}_{3dd'}\). Since the proof line and the arguments for each case are similar, we report here only the analysis for type \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\) and move the analyses of the other two cases to “Appendix C”.

Case \(\textrm{I}_{2}\textrm{O}_{\lambda \beta }\): in this case \(\Delta _\nu = [2,4-\gamma ]\), \(m=\max \{m_l-2,m_r\}+\frac{\gamma }{2}\), and \(M=\min \{M_l, M_r+2\}-\frac{\gamma }{2}\). We show that the set \(I'_\nu \) is an interval of feasible spirality values for the orthogonal representations of \(G_\nu \) with \(b_\nu \) bends. Suppose first that \(G_\nu \) has an orthogonal representation \(H_\nu \) with \(b_\nu \) bends, and let \(\sigma _\nu \) be the spirality of \(H_\nu \). We prove that \(\sigma _\nu \in [m-b_\nu ,M+b_\nu ]\). Let \(b_l\) and \(b_r\) be the number of bends in the restriction of \(H_\nu \) to \(G_{\mu _l}\) and to \(G_{\mu _r}\), respectively, where \(b_l+b_r=b_\nu \). By Lemma 14, we can assume that all the \(b_l\) bends are along an exposed edge of \(G_{\mu _l}\) and all the \(b_r\) bends are along an exposed edge of \(G_{\mu _r}\). Since \(\sigma _{\mu _l}\in [m_l-b_l, M_l+b_l]\) and \(b_l\in [0,b_\nu ]\) we have \(\sigma _{\mu _l}\in [m_l-b_\nu , M_l+b_\nu ]\). Also, by Lemma 3 we have \(\sigma _\nu = \sigma _{\mu _l} -k_{u}^l \alpha _{u}^l - k_{v}^l \alpha _{v}^l\). By Lemma 16, we have \(-k_{u}^l \alpha _{u}^l - k_{v}^l \alpha _{v}^l\in [\frac{\gamma }{2}-2,-\frac{\gamma }{2}]\). Hence, \(\sigma _\nu \in [m_l-b_\nu +\frac{\gamma }{2}-2, M_l+b_\nu -\frac{\gamma }{2}]\). With a symmetric argument on \(\sigma _{\mu _r}\) we have that \(\sigma _\nu \in [m_r-b_\nu +\frac{\gamma }{2}, M_r+b_\nu +2-\frac{\gamma }{2}]\). It follows that \(\sigma _\nu \in [m_l-b_\nu +\frac{\gamma }{2}-2, M_l+b_\nu -\frac{\gamma }{2}]\cap [m_r-b_\nu +\frac{\gamma }{2}, M_r+b_\nu +2-\frac{\gamma }{2}]=[\max \{m_l-2,m_r\}+\frac{\gamma }{2}-b_\nu ,\min \{M_l, M_r+2\}-\frac{\gamma }{2}+b_\nu ] =[m-b_\nu , M+b_\nu ]\).

To complete the proof it remains to show that for every \(\sigma _\nu \in [m-b_\nu ,M+b_\nu ]\), there exists an orthogonal representation \(H_\nu \) of \(G_\nu \) with \(b_\nu \) bends and with spirality \(\sigma _\nu \). This is equivalent to showing that there exists a plane graph \(G'_\nu \) obtained by adding \(b_\nu \) subdivision vertices along some edges of \(G_\nu \) such that \(G'_\nu \) has a rectilinear orthogonal representation with spirality \(\sigma _\nu \). To construct \(G'_\nu \) we insert a suitable number \(b_l\in [0,b_\nu ]\) of subdivision vertices on an exposed edge of \(G_{\mu _l}\) and \(b_r=b_\nu -b_l\) subdivision vertices on an exposed edge of \(G_{\mu _r}\). Let \(G'_{\mu _l}\) and \(G'_{\mu _r}\) be the resulting graphs. Since by hypothesis \(G_{\mu _l}\) and \(G_{\mu _r}\) are rectilinear planar, also \(G'_{\mu _l}\) and \(G'_{\mu _r}\) are rectilinear planar. With the same reasoning as in the proof of Property (i), the representability intervals of \(G'_{\mu _l}\) and \(G'_{\mu _r}\) are \([m_l-b_l,M_l+b_l]\) and \([m_r-b_r,M_r+b_r]\). We now describe how to compute \(b_l\) and, consequently, \(b_r\).

Since by hypothesis \(G_\nu \) is not rectilinear planar we have \([m_l-M_r, M_l-m_r] \cap \Delta _\nu = \emptyset \), i.e., \([m_l-M_r, M_l-m_r] \cap [2,4-\gamma ] = \emptyset \). We consider two subcases:

  • \(M_l-m_r<2\). In this case, by Property (i) we have \(b_\nu = \delta ([m_l-M_r, M_l-m_r],[2,4-\gamma ]) = 2-M_l+m_r\). For example, in Fig. 16 we have \(\gamma =0\) and \(b_\nu =3\). We set \(b_l = \sigma _\nu - M_l + h\), where h is a number (either integer or semi-integer) in the interval \([\frac{\gamma }{2},2-\frac{\gamma }{2}]\) such that \(b_l \in [0,b_\nu ]\). We first prove that such a value h always exists.

    Suppose first that \(\sigma _\nu \in [m-b_\nu ,m-b_\nu +1]\). In this case we choose \(h = 2-\frac{\gamma }{2}\). This implies that \(b_l = \sigma _\nu - M_l + 2 - \frac{\gamma }{2} \in [m-b_\nu -M_l+2-\frac{\gamma }{2}, m-b_\nu +1-M_l+2-\frac{\gamma }{2}]\). For example, in Fig. 16 for every \(\sigma _\nu \in [m-b_\nu ,m-b_\nu +1]=[-2,-1]\) we set \(b_l=\sigma _\nu - M_l + 2 - \frac{\gamma }{2}=\sigma _\nu +2\). Since \(M_l-m_r<2\) we have \(m_l-2\le M_l-2<m_r\) and hence \(m_l-2<m_r\). Since \(m = \max \{m_l-2,m_r\}+\frac{\gamma }{2}\), we have \(m=m_r+\frac{\gamma }{2}\). Also, since we have \(b_\nu = 2-M_l+m_r\), it follows \(m-b_\nu -M_l+2-\frac{\gamma }{2}=m_r+\frac{\gamma }{2}-b_\nu -M_l+2-\frac{\gamma }{2}=0\). Hence, \(b_l\in [0,1]\). Since by hypothesis \(G_\nu \) is not rectilinear planar, \(b_\nu \ge 1\), and therefore there exists a value of \(h \in [\frac{\gamma }{2},2-\frac{\gamma }{2}]\) such that \(b_l\in [0,b_\nu ]\).

    Suppose now that \(\sigma _\nu \in [m-b_\nu +2,M+b_\nu ]\). In this case we choose \(h = \frac{\gamma }{2}\). This implies that \(b_l = \sigma _\nu - M_l + \frac{\gamma }{2}\in [m-b_\nu +2-M_l+\frac{\gamma }{2}, M+b_\nu -M_l+\frac{\gamma }{2}]\). For example, in Fig. 16\(\sigma _\nu \in [m-b_\nu +2,M+b_\nu ]=[0,3]\) and we set \(b_l=\sigma _\nu - M_l - \frac{\gamma }{2}=\sigma _\nu \). We have \(m-b_\nu +2-M_l+\frac{\gamma }{2}=m_r+\frac{\gamma }{2}-b_\nu +2-M_l+\frac{\gamma }{2}=\gamma \). It follows that \(b_l\in [\gamma , M+b_\nu -M_l+\frac{\gamma }{2}]\). Since \(M_l<m_r+2\le M_r+2\) we have \(M_l<M_r+2\). Also, since \(M = \min \{M_l,M_r+2\}-\frac{\gamma }{2}\) it follows that \(M=M_l-\frac{\gamma }{2}\). Hence, \(M+b_\nu -M_l+\frac{\gamma }{2}=M_l-\frac{\gamma }{2}+b_\nu -M_l+\frac{\gamma }{2}=b_\nu \). Hence, \(b_l\in [\gamma , b_\nu ]\). Since \(\gamma \ge 0\), also in this case there exists a value of \(h \in [\frac{\gamma }{2},2-\frac{\gamma }{2}]\) such that \(b_l\in [0,b_\nu ]\). We represent \(G_{\mu _l}'\) with spirality \(\sigma _{\mu _l}'=M_l+b_l=M_l+\sigma _\nu - M_l + h=\sigma _\nu + c\) and \(G_{\mu _r}'\) with spirality \(\sigma _{\mu _r}'=m_r-b_r=m_r-(b_\nu -b_l)=m_r-b_\nu +b_l=m_r-b_\nu +\sigma _\nu - M_l + h=m_r-M_l-b_\nu +\sigma _\nu +h=b_\nu -2-b_\nu +\sigma _\nu +h=\sigma _\nu +h-2\). We have \(\sigma _{\mu _l}'-\sigma _{\mu _r}'=\sigma _\nu + h -(\sigma _\nu +h-2)=2\), and by Lemma 7, \(G_\nu '\) is rectilinear planar. It remains to show that \(G_\nu '\) admits a rectilinear planar representation with spirality \(\sigma _\nu '=\sigma _\nu \). Given the choice of \(\sigma _{\mu _l}'\) and \(\sigma _{\mu _r}'\), by Lemma 3 every rectilinear planar representation of \(G_\nu '\) has spirality \(\sigma _\nu '=\sigma _{\mu _l}' - k_u^l \alpha _{u}^l - k_u^r\alpha _{v}^l=\sigma _\nu + h - k_u^l \alpha _{u}^l - k_u^r\alpha _{v}^l\). Since \(h \in [\frac{\gamma }{2},2-\frac{\gamma }{2}]\), by Lemma 16 there exists a value \(k_u^l \alpha _{u}^l + k_u^r\alpha _{v}^l\) such that \(h- k_u^l \alpha _{u}^l - k_u^r\alpha _{v}^l=0\), and thus \(\sigma _\nu '=\sigma _\nu \). For example, in Fig. 16, for every \(\sigma _\nu \in I_\nu = [-2,3]\), there is a rectilinear representation of \(G_\nu \) with \(\sigma _{\mu _l}-\sigma _{\mu _r}=2\), \(b_l\) and \(b_r\) chosen as described above, and spirality \(\sigma _\nu \).

  • \(m_l-M_r>4-\gamma \). In this case, by Property (i) we have \(b_\nu = \delta ([m_l-M_r, M_l-m_r],[2,4-\gamma ]) = m_l-M_r-4+\gamma \). We set \(b_l = m_l-\sigma _\nu - 2+\frac{\gamma }{2}\). We first prove that \(b_l \in [0,b_\nu ]\). We have \(b_l = m_l-\sigma _\nu -2 +\frac{\gamma }{2} \in [m_l-M-b_\nu -2+\frac{\gamma }{2}, m_l-m+b_\nu -2+\frac{\gamma }{2}]\). Since \(M_l\ge m_l>M_r+4-\gamma \ge M_r+2\), we have \(M=M_r+2-\frac{\gamma }{2}\). Hence, \(m_l-M-b_\nu -2+\frac{\gamma }{2}=m_l-(M_r+2-\frac{\gamma }{2})-b_\nu -2+\frac{\gamma }{2}=m_l-M_r-4+\gamma -b_\nu =0\). Also, since \(m_l-2 \ge m_l-4+\gamma > M_r\ge m_r\), we have \(m=m_l-2+\frac{\gamma }{2}\). Hence, \(m_l-m+b_\nu -2+\frac{\gamma }{2}=m_l-(m_l-2+\frac{\gamma }{2})+b_\nu -2+\frac{\gamma }{2}=b_\nu \). It follows that \(b_l\in [0,b_\nu ]\).

    We represent \(G_{\mu _l}'\) with spirality \(\sigma _{\mu _l}'=m_l-b_l=m_l-(m_l-\sigma _\nu -2+\frac{\gamma }{2})=\sigma _\nu +2-\frac{\gamma }{2}\) and \(G_{\mu _r}'\) with spirality \(\sigma _{\mu _r}'=M_r+b_r=M_r+b_\nu -b_l=M_r+m_l-M_r-4+\gamma -m_l+\sigma _\nu +2-\frac{\gamma }{2}=\sigma _\nu +\frac{\gamma }{2}-2\). We have \(\sigma _{\mu _l}'-\sigma _{\mu _r}'=\sigma _\nu +2-\frac{\gamma }{2}-(\sigma _\nu +\frac{\gamma }{2}-2)=4-\gamma \) and, by Lemma 7, \(G_\nu '\) is rectilinear planar.

    It remains to show that \(G_\nu '\) admits a rectilinear representation with spirality \(\sigma _\nu '=\sigma _\nu \). Given the choice of \(\sigma _{\mu _l}'\) and \(\sigma _{\mu _r}'\), by Lemma 3 every rectilinear representation of \(G_\nu '\) has spirality \(\sigma _\nu '=\sigma _{\mu _l}' - k_u^l \alpha _{u}^l - k_u^r\alpha _{v}^l=\sigma _\nu +2-\frac{\gamma }{2}- k_u^l \alpha _{u}^l - k_u^r\alpha _{v}^l\). Since \(2-\frac{\gamma }{2}\in [\frac{\gamma }{2},2-\frac{\gamma }{2}]\), by Lemma 16 we can set \(k_u^l \alpha _{u}^l + k_u^r\alpha _{v}^l=2-\frac{\gamma }{2}\), and thus \(\sigma _\nu '=\sigma _\nu \).

Case \(\textrm{I}_{3d}\textrm{O}_{\lambda \beta }\) and Case \(\textrm{I}_{3dd'}\): see “Appendix C”. \(\square \)

6.2.2 P-Nodes Having a Child with No Exposed Edges

We now consider the case of a P-node \(\nu \) having a child that does not contain an exposed edge (see Lemmas 20 and 21). Denote by \(\mu \) such a child node; observe that \(\mu \) is an S-node whose children \(\nu _1, \nu _2, \dots , \nu _h\) (\(h \ge 2\)) (e.g., ordered from the bottom pole to the top pole of \(\mu \)) are all P-nodes of type \(\textrm{I}_{2}\textrm{O}_{22}\). This is because, if one \(\nu _i\) among \(\nu _2, \dots , \nu _{h-1}\) had a pole of outdegree one, then the external edge of \(G_{\nu _i}\) incident to this pole would be part of a Q\(^*\)-node child of \(\mu \), thus contradicting the fact that \(\mu \) has no exposed edges; also, the bottom pole of \(\nu _1\) (resp. of \(\nu _h\)) coincides with the bottom pole (resp. top pole) of \(\nu \), and has outdegree two in \(G_{\nu _1}\) (resp. in \(G_{\nu _h}\)).

For a given integer value \(b \ge 0\), denote by \(\sigma ^{\max }_{\nu _i}(b)\) the maximum value of spirality that any orthogonal representation of \(G_{\nu _i}\) with at most b bends can have (\(i \in \{1, \dots , h\}\)). When we consider the value \(b+1\), the value \(\sigma ^{\max }_{\nu _i}(b + 1)\) may or may not increase by one unit with respect to \(\sigma ^{\max }_{\nu _i}(b)\), i.e., either \(\sigma ^{\max }_{\nu _i}(b + 1)=\sigma ^{\max }_{\nu _i}(b)+1\) or \(\sigma ^{\max }_{\nu _i}(b + 1)=\sigma ^{\max }_{\nu _i}(b)\). By plotting the function \(\sigma ^{\max }_{\nu _i}(b)\) as b increases, we define the positive flexibility breakpoint of \(G_{\nu _i}\) as the maximum number of bends \(b^+_{\nu _i}\) such that for every non-negative integer \(b < b^+_{\nu _i}\), we have \(\sigma ^{\max }_{\nu _i}(b + 1)=\sigma ^{\max }_{\nu _i}(b)+1\). For example, Fig. 17 shows a component \(G_{\nu _i}\) and a plot of the function \(\sigma ^{\max }_{\nu _i}(b)\) for \(b = 0, 1,\dots , 5\). In the figure, the positive flexibility breakpoint is \(b^+_{\nu _i} = 3\) because passing from \(b=3\) to \(b=4\) does not allow us to have an orthogonal representation of \(G_{\nu _i}\) with a larger value of spirality. The positive flexibility breakpoint of the S-node \(\mu \) is denoted as \(b^+_{\mu }\) and it is defined as the sum of the positive flexibility breakpoints of its children, i.e., \(b^+_{\mu } = \sum _{i=1}^{h} b^+_{\nu _i}\).

Fig. 17
figure 17

A P-component \(G_{\nu _i}\) of type \(\textrm{I}_{2}\textrm{O}_{22}\) and a plot of function \(\sigma ^{\max }_{\nu _i}(b)\) for \(b = 0, 1,\dots , 5\). For each value of b, the figure depicts an orthogonal representation of (maximum) spirality \(\sigma ^{\max }_{\nu _i}(b)\) among those with b bends (cross vertices). The positive flexibility breakpoint is \(b^+_{\nu _i} = 3\)

Symmetrically, for a given integer \(b \ge 0\), let \(\sigma ^{\min }_{\nu _i}(b)\) be the minimum value of spirality that an orthogonal representation of \(G_{\nu _i}\) with at most b bends can have (\(i \in \{1, \dots , h\}\)). The value of \(\sigma ^{\min }_{\nu _i}(b+1)\) may or may not decrease by one unit with respect to \(\sigma ^{\min }_{\nu _i}(b)\). We define the negative flexibility breakpoint of \(G_{\nu _i}\) as the maximum number of bends \(b^-_{\nu _i}\) such that for every non-negative integer \(b < b^-_{\nu _i}\), we have \(\sigma ^{\min }_{\nu _i}(b + 1)=\sigma ^{\min }_{\nu _i}(b)-1\). For example, Fig. 18 shows the same component \(G_{\nu _i}\) as in Fig. 17 and a plot of the function \(\sigma ^{\min }_{\nu _i}(b)\) for \(b = 0, 1,\dots , 4\). In the figure, the negative flexibility breakpoint is \(b^-_{\nu _i} = 1\) because passing from \(b=1\) to \(b=2\) does not allow us to have an orthogonal representation of \(G_{\nu _i}\) with a smaller value of spirality. The negative flexibility breakpoint of the S-node \(\mu \) is denoted as \(b^-_{\mu }\) and it is defined as the sum of the negative flexibility breakpoints of its children, i.e., \(b^-_{\mu } = \sum _{i=1}^{h} b^-_{\nu _i}\). The next lemma establishes how to compute in constant time the positive and negative flexibility breakpoints for a P-node \(\nu _i\) of type \(\textrm{I}_{2}\textrm{O}_{22}\), given the representability intervals of its children.

Fig. 18
figure 18

A P-component \(G_{\nu _i}\) of type \(\textrm{I}_{2}\textrm{O}_{22}\) and a plot of function \(\sigma ^{\min }_{\nu _i}(b)\) for \(b = 0, 1,\dots , 4\). For each value of b, the figure depicts an orthogonal representation of (minimum) spirality \(\sigma ^{\min }_{\nu _i}(b)\) among those with b bends (cross vertices). The negative flexibility breakpoint is \(b^-_{\nu _i} = -1\)

Lemma 19

Let \(\nu _i\) be a P-node of type \(\textrm{I}_{2}\textrm{O}_{22}\) with children \(\mu _l\) and \(\mu _r\) such that \(G_{\nu _i}\) is rectilinear planar. Let \(I_{\mu _l}=[m_l,M_l]\) and \(I_{\mu _r}=[m_r,M_r]\) be the representability intervals of \(G_{\mu _l}\) and \(G_{\mu _r}\), respectively. We have \(b^+_{\nu _i} = |M_r+2-M_l |\) and \(b^-_{\nu _i} = |m_l-2-m_r |\). Also, an orthogonal representation of \(G_{\nu _i}\) with spirality \(\sigma ^{\max }_{\nu _i}(b^+_{\nu _i})\) (resp. with \(\sigma ^{\min }_{\nu _i}(b^-_{\nu _i})\) \()\) can be obtained by inserting all the bends on an exposed edge of either \(G_{\mu _l}\) or \(G_{\mu _r}\).

Proof

We prove that \(b^+_{\nu _i} = |M_r+2-M_l |\). The proof that \(b^-_{\nu _i} = |m_l-m_r-2 |\) is symmetric. Consider a rectilinear planar representation \(H_{\nu _i}\) of \(G_{\nu _i}\) with maximum value of spirality, that is spirality \(\sigma ^{\max }_{\nu _i}(0)\) which, by Table 1

is \(\sigma ^{\max }_{\nu _i}(0)=\min \{M_l-1,M_r+1\}\). Let \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) be the spirality values of the left and the right orthogonal components of \(H_{\nu _i}\), respectively. By Lemma 7, we know that \(\sigma _{\mu _l} - \sigma _{\mu _r} = 2\). Also, by Lemma 3, \(\sigma ^{\max }_{\nu _i}(0)=\sigma _{\mu _l}-1=\sigma _{\mu _r}+1\). By Table 1, either \(\sigma _{\mu _l} = M_l\) or \(\sigma _{\mu _r} = M_r\) (possibly both). Three cases are possible:

  • \(\sigma _{\mu _l} = M_l\) and \(\sigma _{\mu _r} = M_r\). Note that, since \(\sigma _{\mu _l} = \sigma _{\mu _r}+2\), in this case we have \(|M_r+2-M_l |=0\). We show that if we are allowed to subdivide an edge of \(G_{\nu _i}\) with exactly one degree-2 vertex, so to obtain a graph \(G'_{\nu _i}\), the maximum value of spirality that a rectilinear planar representation \(H'_{\nu _i}\) of \(G'_{\nu _i}\) equals \(\sigma ^{\max }_{\nu _i}(0)\). In other words, we show that \(\sigma ^{\max }_{\nu _i}(1)=\sigma ^{\max }_{\nu _i}(0)\). By Lemma 14, we can assume that the degree-2 vertex subdivides an exposed edge, which belongs either to \(G_{\mu _l}\) or to \(G_{\mu _r}\). Suppose that this degree-2 vertex is inserted along an exposed edge of \(G_{\mu _l}\). Denote by \(G'_{\mu _l}\) and \(G'_{\mu _r}\) the left component and the right component of \(G'_{\nu _i}\), respectively. The maximum spirality of a rectilinear planar representation of \(G'_{\mu _l}\) is \(M_l+1\), while the maximum spirality of a rectilinear planar representation of \(G'_{\mu _r}\) remains \(M_r\), because \(G'_{\mu _r}\) coincides with \(G_{\mu _r}\). Assume for a contradiction that \(G'_{\nu _i}\) admits a rectilinear planar representation \(H'_{\nu _i}\) with spirality \(\sigma ^{\max }_{\nu _i}(0)+1\), and denote by \(\sigma '_{\mu _l}\) and \(\sigma '_{\mu _r}\) the spirality values of the left and right components of \(H'_{\nu _i}\). We should have that \(\sigma ^{\max }_{\nu _i}(0)+1 = \sigma '_{\mu _l} - 1\) and \(\sigma ^{\max }_{\nu _i}(0)+1 = \sigma '_{\mu _r} + 1\). Now, \(\sigma ^{\max }_{\nu _i}(0)+1=M_l\) and \(\sigma ^{\max }_{\nu _i}(0)+1=(M_r+1)+1\), which implies that \(G'_{\mu _r}\) should have a rectilinear planar representation with spirality \(M_r+1\), a contradiction. A symmetric argument applies if we subdivide an exposed edge of \(G_{\mu _r}\). Hence, \(b^+_{\nu _i} = 0 = |M_r+2-M_l |\).

  • \(\sigma _{\mu _l} = M_l\) and \(\sigma _{\mu _r} < M_r\). Subdivide an exposed edge of \(G_{\nu _l}\) with a degree 2-vertex, and call \(G'_{\nu _i}\) the graph resulting from \(G_{\nu _i}\) after this subdivision. As in the previous case, denote by \(G'_{\mu _l}\) and \(G'_{\mu _r}\) the left and the right components of \(G'_{\nu _i}\), where \(G'_{\mu _r}\) coincides with \(G_{\mu _r}\). We show that \(G'_{\nu _i}\) admits a rectilinear planar representation with spirality \(\sigma '_\nu = \sigma ^{\max }_{\nu _i}(0) + 1\). Since we have added a subdivision vertex on an exposed edge of \(G_{\mu _l}\), there exists a rectilinear planar representation \(H'_{\mu _l}\) of \(G'_{\mu _l}\) with spirality \(\sigma '_{\mu _l}=M_l+1\). Also, since \(\sigma _{\mu _r} < M_r\), there exists a rectilinear planar representation of \(G'_{\mu _r}\) with spirality \(\sigma '_{\mu _r}=\sigma _{\mu _r}+1\). Hence, \(\sigma '_{\mu _l} - \sigma '_{\mu _r} = 2\) and therefore, by Lemma 7, we can merge the representations \(H'_{\mu _l}\) and \(H'_{\mu _r}\) into a rectilinear planar representation \(H'_{\nu _i}\) of \(G'_{\nu _i}\). The spirality of \(H'_{\nu _i}\) is \(\sigma '_{\nu _i} = \sigma ^{\max }_{\nu _i}(0) + 1\). By replacing the subdivision vertex of \(H'_{\mu _l}\) with a bend, we get an orthogonal representation of \(G_{\nu _i}\) with one bend and with spirality \(\sigma ^{\max }_{\nu _i}(0) + 1\), i.e., \(\sigma ^{\max }_{\nu _i}(1)=\sigma ^{\max }_{\nu _i}(0) + 1\). Iterate this procedure until \(\sigma '_{\mu _r}=M_r\), i.e., until \(\sigma '_{\nu _i}=M_r+1\). Denote by b the number of bends added in total. By Lemma 3, the spirality of the resulting orthogonal representation is \(\sigma ^{\max }_{\nu _i}(b)=M_l+b-1=M_r+1\), and hence \(b = M_r+2-M_l\). If we consider the rectilinear representation \(H'_{\nu _i}\) where the b bends are replaced with degree-2 vertices, its left and right components have the maximum possible spirality in their representability intervals. Hence, the previous case applies, and inserting exactly one subdivision vertex to \(G'_{\nu _i}\) does not result into a graph that admits a rectilinear planar representation with spirality greater than the one of \(H'_{\nu _i}\). It follows that \(b^+_{\nu _i} = M_r+2-M_l\).

  • \(\sigma _{\mu _l} < M_l\) and \(\sigma _{\mu _r} = M_r\). With a symmetric argument as in the previous case, \(b^+_{\nu _i} = M_l - (M_r + 2)\).

\(\square \)

The next lemma gives the rule for computing the budget of a P-node with two children such that the left one has no exposed edge, and for determining the corresponding interval of spirality values.

Lemma 20

Let \(\nu \) be a P-node with two children \(\mu _l\) and \(\mu _r\), such that \(\mu _l\) has no exposed edge. Let \(G_{\mu _l}\) and \(G_{\mu _r}\) be rectilinear planar with representability intervals \(I_{\mu _l}=[m_l,M_l]\) and \(I_{\mu _r}=[m_r,M_r]\), respectively. If \(G_\nu \) is not rectilinear planar then: (i) the budget for \(\nu \) is \(b_\nu =\delta ([m_l-M_r, M_l-m_r],[3,3])\); and (ii) the interval of spirality values for an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends is \(I'_\nu = [m-b_\nu , M+\min \{b^+_{\mu _l},b_\nu \}]\) if \(M_l - m_r < 3\) and \(I'_\nu = [m-\min \{b^-_{\mu _l},b_\nu \}, M+b_\nu ]\) if \(m_l - M_r > 3\).

Proof

Since by hypothesis \(G_\nu \) is not rectilinear planar, by Table 1 we have \(3 \notin [m_l-M_r, M_l-m_r] \cap \Delta _\nu = \emptyset \), where \(\Delta _\nu =[3,3]\). In other words, \(3 \notin [m_l-M_r, M_l-m_r]\).

Proof of Property (i). We first prove that \(b_\nu = \delta ([m_l-M_r, M_l-m_r],[3,3])\) bends are necessary. Suppose for a contradiction that \(G_\nu \) admits an orthogonal representation \(H'_\nu \) with \(b'_\nu < b_\nu \) bends. Let \(b'_l\) and \(b'_r\) be the number of bends in the restriction of \(H'_\nu \) to \(G_{\mu _l}\) and to \(G_{\mu _r}\), respectively. By Lemma 14, we can assume that all the bends \(b'_r\) are along an exposed edge of \(G_{\mu _r}\). Consider the underlying graph \(G'_\nu \) of \(H'_\nu \) obtained by replacing each bend of \(H'_\nu \) with a subdivision vertex. \(G'_\nu \) is rectilinear planar. Let \(G'_{\mu _l}\) and \(G'_{\mu _r}\) be the left and right component of \(G'_\nu \), respectively. Hence \(G'_{\mu _r}\) is rectilinear planar with representability interval \([m_r-b'_r,M_r+b'_r]\). About \(G'_{\mu _l}\), its representability interval \(I'_{\mu _l}=[p,q]\) is such that \([p,q] \subseteq [m_l-b_l',M_l+b_l']\). In particular \([p,q] = [m_l-b_l',M_l+b_l']\) when \(b_{\mu _l}^- \ge b'_l\) and \(b_{\mu _l}^+ \ge b'_l\). By Table 1, the representability condition for \(G'_\nu \) is \([p-M_r-b'_r, q-m_r+b'_r] \cap [3,3] \ne \emptyset \). Since \(p \ge m_l-b_l'\) and \(q \le M_l+b_l'\) we have \([p-M_r-b'_r, q-m_r+b'_r] \subseteq [m_l-b_l'-M_r-b'_r,M_l+b_l'-m_r+b'_r]\), and therefore \([m_l-b_l'-M_r-b'_r,M_l+b_l'-m_r+b'_r] \cap [3,3] \ne \emptyset \). This equals to say that \([m_l-M_r-b'_\nu ,M_l-m_r+b'_\nu ] \cap [3,3] \ne \emptyset \), which implies that \(\delta ([m_l-M_r,M_l-m_r],[3,3]) \le b'_\nu < b_\nu \), a contradiction.

We now prove that \(b_\nu \) bends suffice. Insert \(b_\nu \) subdivision vertices on any exposed edge of \(G_{\mu _r}\), and let \(G'_{\mu _r}\) be the resulting component. Since \(G_{\mu _r}\) is rectilinear planar by hypothesis, \(G'_{\mu _r}\) is also rectilinear planar and its representability interval is \([m_r-b_\nu ,M_r+b_\nu ]\). Consider the plane graph \(G'_{\nu }\) obtained by the union of \(G_{\mu _l}\) and \(G'_{\mu _r}\). Since by hypothesis \(b_\nu = \delta ([m_l-M_r, M_l-m_r],[3,3])\), we have that \([m_l-M_r-b_\nu , M_l- m_r+b_\nu ] \cap [3,3] \ne \emptyset \). It follows that \(G'_{\nu }\) is rectilinear planar. Consider any rectilinear representation \(H'_{\nu }\) of \(G'_{\nu }\) and replace each of its subdivision vertices with a bend. Since by construction \(G'_{\nu }\) has \(b_\nu \) subdivision vertices, the resulting orthogonal representation has at most \(b_\nu \) bends.

Proof of Property (ii). Since by hypothesis \(3 \notin [m_l-M_r, M_l-m_r]\) we have two cases: either \(M_l - m_r < 3\) or \(M_r - m_l > 3\). For each of them, we must show that every orthogonal representation of \(G_\nu \) with \(b_\nu \) bends has spirality \(\sigma _\nu \) in the interval \(I'_\nu \) and that for every value \(\sigma _\nu \in I'_\nu \) there exists an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends and spirality \(\sigma _\nu \). We show the argument for the case \(M_l-m_r<3\) (the other case is treated analogously).

By Table 1 we have \(M=\min \{M_l-1, M_r+2\}\) and \(m=\max \{m_l-1,m_r+2\}\). Since \(M_l<m_r+3\le M_r+3\), we have \(M_l-1<M_r+2\) and since \(m_l-3\le M_l-3<m_r\), we have \(m_l-1<m_r+2\). Hence, \(M=M_l-1\) and \(m=m_r+2\).

Suppose first that \(G_\nu \) has an orthogonal representation \(H_\nu \) with \(b_\nu \) bends. We prove that \(\sigma _\nu \in [m-b_\nu ,M+\min \{b_{\mu _l}^+,b_\nu \}]\). Let \(\sigma _\nu \) be the spirality of \(H_\nu \), and let \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) be the spirality values of the restrictions \(H_{\mu _l}\) and \(H_{\mu _r}\) of \(H_\nu \) to \(G_{\mu _l}\) and \(G_{\mu _r}\), respectively. By Lemma 7 we have \(\sigma _{\mu _l}-\sigma _{\mu _r}=3\). Let \(b_l\) and \(b_r\) be the number of bends in \(H_{\mu _l}\) and \(H_{\mu _r}\), respectively. Clearly, \(b_l + b_r = b_\nu \). We now prove the following claim. \(\square \)

Claim 2

\(b_l\in [0,\min \{b_{\mu _l}^+,b_\nu \}]\).

Claim Proof

Suppose for a contradiction that \(b_l\not \in [0,\min \{b_{\mu _l}^+,b_\nu \}]\). Clearly, \(b_l \in [0,b_\nu ]\), and thus, under this hypothesis, it must be \(\min \{b_{\mu _l}^+,b_\nu \}=b_{\mu _l}^+\) and \(b_l\in [b_{\mu _l}^++1,b_\nu ]\). We show that there exists an orthogonal representation \(H_\nu '\) of \(G_\nu \) with less than \(b_\nu \) bends, which is impossible by definition of budget \(b_\nu \). We will denote by \(H'_{\mu _l}\) and \(H'_{\mu _r}\) the restrictions of \(H_\nu '\) to \(G_{\mu _l}\) and to \(G_{\mu _r}\), respectively. Also, \(b_l'\) and \(b_r'\) will denote the number of bends of \(H'_{\mu _l}\) and \(H'_{\mu _r}\), while \(\sigma _{\mu _l}'\) and \(\sigma _{\mu _r}'\) will denote the spirality values of \(H'_{\mu _l}\) and \(H'_{\mu _r}\), respectively. We distinguish two cases: (a) \(b_l=b_{\mu _l}^++1\) and (b) \(b_l\in [b_{\mu _l}^++2, b_\nu ]\).

In case (a), we set \(b_l'=b_l-1=b_{\mu _l}^+\) and \(b_r'=b_r\). By definition of positive flexibility breakpoint it is possible to set \(\sigma _{\mu _l}'=\sigma _{\mu _l}\). Also, we set \(\sigma _{\mu _r}'=\sigma _{\mu _r}\). Since \(\sigma _{\mu _l}'-\sigma _{\mu _r}'=\sigma _{\mu _l}-\sigma _{\mu _r}=3\), by Lemma 7, \(H_\nu '\) exists and it has \(b_l'+b_r'=b_\nu -1<b_\nu \) bends, a contradiction.

In case (b), we set \(b_l'=b_l-2\) and \(b_r'=b_r+1\). Again by definition of positive flexibility breakpoint, it is possible to set \(\sigma _{\mu _l}'=\sigma _{\mu _l}-1\). Also, since \(G_{\mu _r}\) has an exposed edge, by Lemma 14 we can use such an edge to place the extra bend of the right component. It follows that, we can set \(\sigma _{\mu _r}'=\sigma _{\mu _r}-1\). Therefore, \(\sigma _{\mu _l}'-\sigma _{\mu _r}'=\sigma _{\mu _l}-\sigma _{\mu _r}=3\) and, by Lemma 7, \(H_\nu '\) exists and it has \(b_l'+b_r'<b_l+b_r=b_\nu \) bends, a contradiction.

Since \(G_\nu \) is of type \(\textrm{I}_{3ll}\), by Lemma 3 and Table 2 we have \(\sigma _\nu = \sigma _{\mu _l} -1=\sigma _{\mu _r} +2\). By the claim we have \(b_l\in [0,\min \{b_{\mu _l}^+,b_\nu \}]\), hence \(m_l-\min \{b_{\mu _l}^+,b_\nu \}\le \sigma _{\mu _l}\le M_l+\min \{b_{\mu _l}^+,b_\nu \}\) and hence \(\sigma _\nu \in [m_l-\min \{b_{\mu _l}^+,b_\nu \}-1, M_l+\min \{b_{\mu _l}^+,b_\nu \}-1]\). Also, \(b_r\in [0,b_\nu ]\) and \(\sigma _\nu \in [m_r-b_\nu +2,M_r+b_\nu +2]\). Hence \(\sigma _\nu \ge \max \{m_l-\min \{b_{\mu _l}^+,b_\nu \}-1,m_r-b_\nu +2\}\). By Property (i), \(b_\nu = \delta ([m_l-M_r, M_l-m_r],[3,3]) = 3-M_l+m_r\), hence, \(m_r-b_\nu +2=m_r-3+M_l-m_r+2=M_l-1\ge m_l-\min \{b_{\mu _l}^+,b_\nu \}-1\). It follows that \(\sigma _\nu \ge m_r-b_\nu +2\). Also, \(\sigma _\nu \le \min \{M_l+\min \{b_{\mu _l}^+,b_\nu \}-1, M_r+b_\nu +2\}\). Since by hypothesis \(M_l-1\le m_r+2\le M_r+2\) and since \(\min \{b_{\mu _l}^+,b_\nu \}\le b_\nu \), we have \(M_l+\min \{b_{\mu _l}^+,b_\nu \}-1\le M_r+b_\nu +2\) and \(\sigma _\nu \le M_l+\min \{b_{\mu _l}^+,b_\nu \}-1\). Hence, \(\sigma _\nu \in [m_r-b_\nu +2, M_l+\min \{b_{\mu _l}^+,b_\nu \}-1] = [m-b_\nu ,M+\min \{b_{\mu _l}^+,b_\nu \}]=I'_\nu \).

It remains to show that for every \(\sigma _\nu \in I'_\nu = [m-b_\nu , M+\min \{b^+_{\mu _l},b_\nu \}]\), there exists an orthogonal representation \(H_\nu \) of \(G_\nu \) with \(b_\nu \) bends and with spirality \(\sigma _\nu \). With the same notation and arguments as in Lemma 18, we show how to set the number of bends \(b_l\) and \(b_r\) that can be assigned to the left and right component to guarantee the existence of \(H_\nu \). By Property (i), \(b_\nu = \delta ([m_l-M_r, M_l-m_r],[3,3]) = 3-M_l+m_r\). By setting \(b_l = \sigma _\nu - M_l + 1\) and \(b_r = b_\nu - b_l\), we have \(b_l\in [m-b_\nu - M_l + 1, M+\min \{b_{\mu _l}^+,b_\nu \} - M_l + 1]\), and hence \(b_l\in [m_r+2-b_\nu - M_l + 1, M_l-1+\min \{b_{\mu _l}^+,b_\nu \} - M_l + 1]=[0,\min \{b_{\mu _l}^+,b_\nu \}]\), i.e., \(b_l \in [0,\min \{b_{\mu _l}^+,b_\nu \}]\).

Let \(\nu _1, \dots , \nu _h\) be the children of \(\mu _l\). Since \(G_{\mu _l}\) has no exposed edge, each \(G_{\nu _i}\) \((i=1, \dots , h)\) is a parallel component of type \(\textrm{I}_{2}\textrm{O}_{22}\) and Lemma 19 applies. We distribute the \(b_l\) bends on the components \(G_{\nu _i}\) in such a way that the number of bends assigned to \(G_{\nu _i}\) is at most \(b_{\nu _i}^+\) \((i=1, \dots , h)\). This is always possible, because, as showed above, \(b_l \in [0,\min \{b_{\mu _l}^+,b_\nu \}]\). The bends assigned to each \(G_{\nu _i}\) are inserted on an exposed edge according to the procedure in the proof of Lemma 19. The graph \(G_{\mu _l}'\) obtained from \(G_{\mu _l}\) by regarding each bend as a subdivision vertex admits a rectilinear planar representation \(H'_{\mu _l}\) with spirality \(\sigma _{\mu _l}'=M_l+b_l=M_l+\sigma _\nu - M_l + 1=\sigma _\nu +1\). We now place \(b_r\) bends along an exposed edge of \(G_{\mu _r}\). The graph \(G_{\mu _r}'\) obtained from \(G_{\mu _r}\) by regarding each bend as a subdivision vertex admits a rectilinear planar representation \(H_{\mu _r}'\) with spirality \(\sigma _{\mu _r}'=m_r-b_r=m_r-(b_\nu -b_l)=m_r-b_\nu +\sigma _\nu - M_l + 1=(m_r-M_l+1)-b_\nu +\sigma _\nu =b_\nu -2-b_\nu +\sigma _\nu =\sigma _\nu -2\). It follows that \(\sigma _{\mu _l}'-\sigma _{\mu _r}'=\sigma _\nu +1-(\sigma _\nu -2)=3\) and, by Lemma 11, \(G_\nu '\) is rectilinear planar and it admits a rectilinear planar representation \(H'_\nu \) obtained by combining in parallel \(H_{\mu _l}'\) and \(H_{\mu _r}'\). By Lemma 3, \(H'_\nu \) has spirality \(\sigma _\nu '=\sigma _{\mu _l}' - {k_u^l}' {\alpha _{u}^l}' - {k_u^l}'{\alpha _v^l}'\). Since u and v have degree four, we have \({\alpha ^l_u}'={\alpha ^l_v}'={\alpha ^r_u}'={\alpha ^r_v}'=1\). Also, by Table 2, \({k_u^l}'={k_u^r}'=\frac{1}{2}\). Hence, \(\sigma '_\nu =\sigma _\nu + 1 - 1=\sigma _\nu \). Replacing the subdivision vertices of \(H'_\nu \) with bends we get an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends and spirality \(\sigma _\nu \).

The proof of Lemma 21 considers the case where the right child of a P-node with two children has no exposed edge. The proof is symmetric to that of Lemma 20, hence it is omitted.

Lemma 21

Let \(\nu \) be a P-node with two children \(\mu _l\) and \(\mu _r\), such that \(\mu _r\) has no exposed edge. Let \(G_{\mu _l}\) and \(G_{\mu _r}\) be rectilinear planar with representability intervals \(I_{\mu _l}=[m_l,M_l]\) and \(I_{\mu _r}=[m_r,M_r]\), respectively. If \(G_\nu \) is not rectilinear planar, then: (i) the budget for \(\nu \) is \(b_\nu =\delta ([m_l-M_r, M_l-m_r],[3,3])\); and (ii) the interval of spirality values for an orthogonal representation of \(G_\nu \) with \(b_\nu \) bends is \(I'_\nu = [m-\min \{b^-_{\mu _r},b_\nu \},M+b_\nu ]\) if \(m_l - M_r > 3\) and \(I'_\nu = [m-b_\nu ,M+\min \{b^+_{\mu _r},b_\nu \}]\) if \(M_l - m_r < 3\).

6.3 Budget of the Root

We finally show how to compute the budget of the root \(\rho \) of T. Recall that \(\rho \) is the P\(^r\)-node describing the parallel composition of the reference edge \(e=(u,v)\) with the rest of the graph. If e is a dummy edge, the budget of \(\rho \) is zero, because e does not need to be drawn. Thus we assume that the graph is biconnected and e is a real edge. Let \(\eta \) be the child of \(\rho \) that does not correspond to e, and let \(u'\) and \(v'\) be the alias vertices associated with the poles u and v of \(G_\eta \). If \(G_\eta \) is rectilinear planar with representability interval \(I_\eta \), by the root condition in Table 1 we know that G is rectilinear planar if and only if \(I_\eta \cap \Delta _\rho \ne \emptyset \). Recall that \(\Delta _\rho \) is defined as follows: (i) \(\Delta _\rho =[2,6]\) if \(u'\) coincides with u and \(v'\) coincides with v; (ii) \(\Delta _\rho =[3,5]\) if exactly one of \(u'\) and \(v'\) coincides with u and v, respectively; (iii) \(\Delta _\rho =4\) if none of \(u'\) and \(v'\) coincides with u and v. We prove the following.

Lemma 22

Let \(e=(u,v)\) be the reference edge of G and let \(\rho \) be the root of T with respect to e. Let \(\eta \) be the child of \(\rho \) that does not correspond to e. Suppose that \(G_\eta \) is rectilinear planar with representability interval \(I_\eta \). If G is not rectilinear planar then \(b_\rho =\delta (I_\eta ,\Delta _\rho )\).

Proof

See Fig. 19 for an illustration of the statement.

Let \(f_{\textrm{int}}\) be the internal face of G incident to e. Note that H is an orthogonal representation of G if and only if the following two conditions hold: the restriction \(H_\eta \) of H to \(G_\eta \) is an orthogonal representation; the number A of right turns minus left turns of any simple cycle of G in H containing e and traversed clockwise in H is equal to 4. We have \(A=\sigma _\eta -\sigma _e+\alpha _{u'}+\alpha _{v'}\), where: \(\sigma _\eta \) is the spirality of \(H_\eta \); \(\sigma _e\) is the spirality of e; for \(w\in \{u',v'\}\), \(\alpha _w=1\), \(\alpha _w=0\), and \(\alpha _w=-1\) if the angle formed by w in \(f_{\textrm{int}}\) equals \(90^o\), \(180^o\), or \(270^o\), respectively.

Since G is not rectilinear planar, H must contain some bends. Denote by b the number of bends of H. Each of these b bends placed along an edge of \(G_\eta \) contributes to increase or decrease \(\sigma _\eta \) by at most one unit, therefore increasing or decreasing A by at most one unit. Also placing this bend along e contributes to increase or decrease A by at most one unit. Hence, without loss of generality, we can assume that all the b bends are placed along e, which implies that \(H_\eta \) does not contain any bend. It follows that \(\sigma _\eta \in I_\eta = [m_\eta ,M_\eta ]\) and \(\sigma _e\in [-b,b]\). We now show that if b is the minimum value such that \(A=4\) then \(b=b_\rho \). Observe that when b is minimum, we have \(|\sigma _e |=b\), and therefore \(|\sigma _e |>0\).

Consider first Case (i) in the definition of \(\Delta _\rho \), i.e., \(\Delta _\rho =[2,6]\). Since in this case the alias vertices coincide with the poles, we have \(\alpha _{u'} \in [-1,1]\), \(\alpha _{v'} \in [-1,1]\), and hence \(\alpha _{u'}+\alpha _{v'} \in [-2,2]\). Since \(\sigma _\eta +\alpha _{u'}+\alpha _{v'}+\sigma _e=4\) there are two possible subcases for any possible choice of the values \(\sigma _\eta \), \(\alpha _{u'}\), and \(\alpha _{v'}\): either (a) \(\sigma _\eta +\alpha _{u'}+\alpha _{v'}<4\) or (b) \(\sigma _\eta +\alpha _{u'}+\alpha _{v'}>4\).

  • Case (a). The maximum value for \(\sigma _\eta +\alpha _{u'}+\alpha _{v'}\) is \(M_\eta +2\). Hence \(M_\eta +2<4\), which implies \(M_\eta <2\). It follows that \(b_\rho =\delta (I_\eta ,\Delta _\rho )=2-M_\eta \). Also, since b is the minimum value such that \(A=4\) and \(\sigma _\eta +\alpha _{u'}+\alpha _{v'}<4\), we have that \(b=\sigma _e\) and \(M_\eta +2+b=4\), which implies \(b = 2-M_\eta = b_\rho \). Therefore, an orthogonal representation of G with b bends is constructed by placing b bends along e and choosing \(\sigma _\eta = M_\eta \).

  • Case (b). The minimum value for \(\sigma _\eta +\alpha _{u'}+\alpha _{v'}\) is \(m_\eta -2\). Hence \(m_\eta -2>4\), which implies \(m_\eta >6\). It follows that \(b_\rho =\delta (I_\eta ,\Delta _\eta )=m_\eta -6\). Also, since b is the minimum value such that \(A=4\) and \(\sigma _\eta +\alpha _{u'}+\alpha _{v'}>4\), we have that \(b=-\sigma _e\) and \(m_\eta -2-b=4\), which implies \(b = m_\eta - 6 = b_\rho \). Therefore, an orthogonal representation of G with b bends is constructed by placing b bends along e and choosing \(\sigma _\eta = m_\eta \).

The proofs for Case (ii) (\(\Delta _\rho =[3,5]\)) and Case (iii) (\(\Delta _\rho =4\)) are analogous, observing that in Case (ii) we have \(\alpha _{u'}+\alpha _{v'}\in [-1,1]\) and in Case (iii) we have \(\alpha _{u'}+\alpha _{v'}=0\). \(\square \)

Fig. 19
figure 19

Illustration of Lemma 22. We have \(I_\eta =[-1,-1]\) and: in Case (i), \(\Delta _\rho =[2,6]\) and \(b_\rho =\delta (I_\eta ,\Delta _\rho )=3\); in Case (ii), \(\Delta _\rho =[3,5]\) and \(b_\rho =\delta (I_\eta ,\Delta _\rho )=4\); in Case (iii), \(\Delta _\rho =4\) and \(b_\rho =\delta (I_\eta ,\Delta _\rho )=5\)

Table 3 summarizes how to compute \(b_\nu \) and \(I'_\nu \) for the different types of nodes \(\nu \).

Table 3 Summary of how to compute \(b_\nu \) and \(I'_\nu \) for the different types of nodes \(\nu \). In the formulas, we have \(\gamma =\lambda +\beta -2\) and \(\phi (\cdot )\) is such that \(\phi (r)=1\) and \(\phi (l)=0\). Values m and M are computed as shown in Table 1

6.4 Optimality of the Approach

Our bottom-up algorithm incrementally computes for each node \(\nu \) of T the budget of bends needed to realize an orthogonal representation of \(G_\nu \). We prove that, the total budget at the level of the root of T corresponds to the number of bends of a bend-minimum orthogonal representation of G. More formally, for a node \(\nu \) of T, the cumulative budget \(B_\nu \) of \(\nu \) is the sum of the budgets of all nodes in the subtree of T rooted at \(\nu \). If \(\nu \) is a leaf of T, \(B_\nu = b_\nu = 0\). If \(\nu \) is an internal node with children \(\mu _1, \mu _2, \dots , \mu _h\) then \(B_\nu = b_\nu + \sum _{i=1, \dots , h}B_{\mu _i}\). Hence, the cumulative budget \(B_\rho \) of the root corresponds to the total number of bends at the end of the bottom-up visit.

Theorem 3

Let G be a plane series–parallel 4-graph, let T be an SPQ\(^*\)-tree of G, and let \(\rho \) be the root of T. The cumulative budget \(B_{\rho }\) computed by the bottom-up visit equals the number of bends of a bend-minimum orthogonal representation of G.

Proof

We prove that once the algorithm has processed a node \(\nu \) in the bottom-up visit, the cumulative budget \(B_\nu \) equals the number of bends of a bend-minimum orthogonal representation of \(G_\nu \). This implies that once the algorithm has visited the root \(\rho \) of T, the cumulative budget \(B_\rho \) equals the number of bends of a bend-minimum orthogonal representation of \(G_\rho = G\). The proof is by induction on the depth of the subtree of T rooted at \(\nu \).

Base Case. For a leaf \(\nu \) of T (\(\nu \) is a Q\(^*\)-node), the statement is trivial, as \(B_\nu =0\).

Inductive Case. Let \(\nu \) be a node of T that is not a leaf. Denote by \(\mu _1, \mu _2, \dots , \mu _h\) the children of \(\nu \). By the inductive hypothesis, each \(B_{\mu _i}\) \((i = 1, \dots , h)\) corresponds to the number of bends of a bend-minimum representation of \(G_{\mu _i}\). By definition, \(B_\nu = b_\nu + \sum _{i=1, \dots , h}B_{\mu _i}\), where \(b_\nu \) is the minimum number of bends that must be used in addition to \(\sum _{i=1, \dots , h}B_{\mu _i}\) to realize an orthogonal representation of \(G_\nu \) (\(b_\nu = 0\) if \(\nu \) is an S-node). Budget \(B_\nu \) corresponds to the minimum number of bends of any orthogonal representation \(H_\nu \) of \(G_\nu \) with the property that the number of bends \(b(H_{\mu _i})\) of the restriction \(H_{\mu _i}\) of \(H_\nu \) to \(G_{\mu _i}\) is such that \(b(H_{\mu _i}) \ge B_{\mu _i}\) (\(i \in \{1, \dots , h\}\)). Let \(H'_\nu \) be any bend-minimum orthogonal representation of \(G_\nu \), and let \(H'_{\mu _i}\) be the restriction of \(H'_\nu \) to \(G_{\mu _i}\). Since, by the inductive hypothesis, there is no orthogonal representation of \(G_{\mu _i}\) with less bends than \(B_{\mu _i}\), we have \(b(H'_{\mu _i}) \ge B_{\mu _i}\), and hence, by the previous observation, \(b(H'_\nu ) \ge B_\nu \). On the other hand, since \(H'_\nu \) is bend-minimum for \(G_\nu \), we also have \(b(H'_\nu ) \le B_\nu \), i.e., \(b(H'_\nu ) = B_\nu \). \(\square \)

7 Bend-Minimization in Linear Time

The bottom-up visit described above, equips each node \(\nu \) of T with three information: the budget \(b_\nu \), the cumulative budget \(B_\nu \), and, if \(\nu \ne \rho \), an interval \(I'_\nu =[m'_\nu ,M'_\nu ]\) of all possible spirality values that an orthogonal representation of \(G_\nu \) with \(B_\nu \) bends can have. Once the bottom-up visit of T has been completed, our algorithm performs a top-down visit of T to suitably add to G a number \(B_\rho \) of subdivision vertices, so that the resulting graph \(G'\) admits a rectilinear planar representation.

At the beginning of the top-down visit, the root \(\rho \) is considered. Let \(\eta \) be the child of \(\rho \) that does not correspond to e. If \(I'_\eta \cap \Delta _\rho \ne \emptyset \), the algorithm selects an arbitrary value \(\sigma _\eta \in I'_\eta \cap \Delta _\rho \) as target spirality value for a representation of \(G'_\eta \) within a rectilinear planar representation of \(G'\). If, vice versa, \(I'_\eta \cap \Delta _\rho = \emptyset \), according to the proof of Lemma 22, the algorithm subdivides e with \(b_e=\delta (I'_\eta ,\Delta _\rho )\) bends and sets the target spirality value \(\sigma _\eta \) as either \(\sigma _\eta =M'_\eta \) (if \(M'_\eta \) is smaller than the infimum of \(\Delta _\rho \)) or \(\sigma _\eta =m'_\eta \) (if \(m'_\eta \) is larger than the supremum of \(\Delta _\rho \)). In the next step of the top-down visit, the algorithm considers node \(\eta \), for which the target spirality value \(\sigma _\eta \) has been previously fixed. If \(\eta \) is an S-node then \(b_\eta =0\), i.e., no subdivision vertices must be added in this step. If \(\eta \) is a P-node and \(b_\eta > 0\), the algorithm suitably adds \(b_\eta \) subdivision vertices along some edges of \(G_\eta \). To do so, it applies the procedures described in the second part of the proof of Property (ii) of Lemma 15, of Lemma 18, or of Lemmas 20 and 21, depending on whether \(\eta \) is a P-node with three children, a P-node with two children both having an exposed edge, or a P-node with two children one of which has no exposed edge. Then, the algorithm sets the spirality values for each child of \(\eta \). Namely, we distinguish the following cases:

Case 1: \(\eta \) is an S-node, with children \(\mu _1, \dots , \mu _h\) \((i \in \{1, \dots , h\})\). Let \(I'_{\mu _i}=[m'_i,M'_i]\) be the representability interval of \(\mu _i\) (assuming that any orthogonal representation of \(G_{\mu _i}\) will have \(B_{\nu _i}\) bends). We must find a value \(\sigma _{\mu _i} \in [m'_i,M'_i]\) for each \(i = 1, \dots , h\) such that \(\sum _{i=i}^h \sigma _{\mu _i} = \sigma _\eta \). To this aim, initially set \(\sigma _{\mu _i} = M'_i\) for each \(i = 1, \dots , h\) and consider \(s = (\sum _{i=i}^h \sigma _{\mu _i}) - \sigma _\eta \). By Lemma 1, \(s \ge 0\). If \(s = 0\) we are done. Otherwise, iterate over all \(i=1, \dots , h\) and for each i decrease both \(\sigma _{\mu _i}\) and s by the value \(\min \{s, M'_i - m'_i\}\), until \(s=0\).

Case 2: \(\eta \) is a P-node with three children, \(\mu _l\), \(\mu _c\), and \(\mu _r\). By Lemma 2, it suffices to set \(\sigma _{\mu _l}=\sigma _{\eta }+2\), \(\sigma _{\mu _c}=\sigma _{\eta }\), and \(\sigma _{\mu _r}=\sigma _{\eta }-2\).

Case 3: \(\eta \) is a P-node with two children, \(\mu _l\) and \(\mu _r\). Let u and v be the poles of \(\eta \). By Lemma 3, \(\sigma _{\mu _l}\) and \(\sigma _{\mu _r}\) must be determined in such a way that \(\sigma _{\mu _l} = \sigma _{\eta }+k_u^l\alpha _u^l+k_v^l\alpha _v^l\) and \(\sigma _{\mu _r} = \sigma _{\eta }-k_u^r\alpha _u^r-k_v^r\alpha _v^r\). The values of \(k_u^l\), \(k_v^l\), \(k_u^r\), \(k_v^r\) are fixed by the indegree and outdegree of u and v. Hence, it suffices to choose the values of \(\alpha _u^l\), \(\alpha _v^l\), \(\alpha _u^r\), \(\alpha _v^r\) such that they are consistent with the type of \(\eta \) and yield \(\sigma _{\mu _l} \in I'_{\mu _l}\) and \(\sigma _{\mu _r} \in I'_{\mu _r}\). Since each \(\alpha _w^d\) \((w \in \{u,v\}, d \in \{l,r\})\) is either 0 or 1, there are at most four combinations of values to consider.

Case 4: \(\eta \) is a Q\(^*\)-node. In this case the algorithm does nothing, as no further subdivision vertices must be added.

In the subsequent steps of the top-down visit, for every node \(\nu \) the algorithm applies the same procedure as for \(\eta \) to determine a target spirality value \(\sigma _\nu \) and to suitably distribute the \(b_\nu \) subdivision vertices along the edges of \(G_\nu \).

Theorem 4

Let G be an n-vertex plane series–parallel 4-graph. There exists an O(n)-time algorithm that computes a bend-minimum orthogonal representation of G.

Proof

If G is biconnected let e be any edge of G on the external face; otherwise, let e be a dummy edge added on the external face to make G biconnected. Let T be an SPQ\(^*\)-tree of G with respect to e. The algorithm executes the bottom-up and the top-down visits described above. Once the top-down visit is completed and \(B_\rho \) subdivision vertices have been suitably inserted in G, a rectilinear planar representation of the subdivision of G is easily computed from the spirality values of each component and from the values of the angles at the poles of each component. From this representation we obtain a bend-minimum orthogonal representation of G by replacing the subdivision vertices with bends. Since the obtained orthogonal representation has \(B_\rho \) bends, by Theorem 3 it has the minimum number of bends.

We now analyze the time complexity of the algorithm. T can be computed in O(n) time and it consists of O(n) nodes [4]. For a node \(\nu \) of T that is not a Q\(^*\)-node, we denote by \(n_\nu \) the number of children of \(\nu \).

Consider first the bottom-up visit. Let \(\nu \) be a visited node of T. If \(\nu \) is a Q\(^*\)-node then \(b_\nu =0\) and, by Table 1, \(I'_\nu = I_\nu \) is computed in O(1) time (we can assume that the length \(\ell \) of the chain of edges represented by \(\nu \) is stored at \(\nu \) during the construction of T). If \(\nu \) is an S-node, we still have \(b_\nu =0\) and, by Table 1, \(I'_\nu = I_\nu \) is computed in \(O(n_\nu )\) time. If \(\nu \) is a P-node with three children, by Lemma 15\(b_\nu \) and \(I'_\nu \) are computed in O(1) time. If \(\nu \) is a P-node with two children each having an exposed edge, by Lemma 18\(b_\nu \) and \(I'_\nu \) are computed in O(1) time. Suppose now that \(\nu \) is a P-node with an S-node child that has no exposed edge, and assume that this S-node is the left child \(\mu _l\) of \(\nu \). By Lemma 20, \(b_\nu \) and \(I'_\nu \) can be computed in O(1) time if we know the flexibility breakpoints (positive and negative) of \(\mu _l\). By Lemma 19, the flexibility breakpoints of \(\mu _l\) can be computed in \(O(n_{\mu _l})\) time. By Lemma 21, the same reasoning applies if the right child of \(\nu \) is an S-node with no exposed edge. Finally, if \(\nu \) coincides with the root \(\rho \) of T, by Lemma 22\(b_\nu \) is easily computed in O(1) time. In summary, for each S-node \(\nu \) of T, the bottom-up visit requires \(O(n_\nu )\) time to compute \(b_\nu \), \(I'_\nu \), and the flexibility breakpoints of \(\nu \) if needed. For any other type of node, the visit takes O(1) time. Thus, the bottom-up visit requires O(n) overall time.

In the top-down visit, for every non-leaf node \(\nu \) of T, the algorithm spends \(O(b_\nu )\) time to add \(b_\nu \) subdivision vertices. Also, we should consider the extra time t required to decide what are the edges along which these bends must be added and what is the target spirality value for each child of \(\nu \). Namely, if \(\nu \) is the root, \(t=O(1)\). If \(\nu \) is an S-node, \(t=O(n_\nu )\) by Case 1 of the top-down visit described above. If \(\nu \) is a P-node with three children, by Case 2 of the top-down visit and by Lemma 15, \(t=O(1)\). If \(\nu \) is a P-node with two children each having an exposed edge, by Case 3 of the top-down visit and by Lemma 18, \(t=O(1)\). Finally, if \(\nu \) is a P-node with two children, one of which is an S-node \(\mu \) with no exposed edge, by Case 3 and by Lemmas 20 and 21, \(t=O(n_\mu )\). Hence, since \(B_\rho =\sum _\nu b_\nu = O(n)\) [21], the top-down visit takes O(n) overall time, and a rectilinear planar representation of the subdivision of G is easily computed in O(n) time from the spirality values of each component and from the values of the angles at the poles of each component.

\(\square \)

8 Conclusions and Open Problems

We proved that there exists an optimal linear-time algorithm that computes a bend-minimum orthogonal drawing of a plane series–parallel 4-graph; this result solves, for a popular and widely studied family of plane graphs, a question opened for over 30 years, thus shedding new light on the complexity of computing orthogonal drawings of plane graphs with the minimum number of bends. It is also worth remarking that, despite the sophisticated analysis and key ingredients needed to prove our main theorem, the resulting bend-minimization algorithm is relatively easy to implement, as at every node of the SPQ\(^*\)-tree it just requires to apply some simple formulas, as summarized in Tables 1 and 3. We conclude by suggesting two open problems:

  • Problem 1. Our result holds for the series–parallel graphs that are also called two-terminal, which are either biconnected or which can be made biconnected with the addition of a single edge. Can we extend Theorem 4 to 1-connected plane 4-graphs whose biconnected components are two-terminal series–parallel graphs, also known as partial 2-trees? Here the main difficulty of extending our approach is to succinctly describe the possible spirality values for those components that contain cut-vertices. In fact, a cut-vertex requires the imposition of some constraints at its angles, in order to correctly compose the different biconnected components that contain it. These constraints forbid some vertex angles, and in turns some spirality values that an orthogonal representation can take.

  • Problem 2. Is it possible to find a linear-time algorithm for the bend-minimization problem of triconnected plane 4-graphs? A positive answer to this question, together with our result, could be used to solve the problem of computing a bend-minimum orthogonal drawing of a general plane 4-graph in linear time.