1 Introduction

Let G be a graph with maximum vertex degree \(\varDelta \). The k-bend planar slope number of G is the minimum number of slopes for the edge segments needed to construct a k-bend planar drawing of G, i.e., a planar drawing where each edge is a polyline with at most \(k \ge 0\) bends. Since no more than two edge segments incident to the same vertex can use the same slope, \(\lceil \varDelta /2 \rceil \) is a trivial lower bound for the k-bend planar slope number of G, irrespectively of k. Besides its theoretical interest, this problem forms a natural extension of two well-established graph drawing models: The orthogonal [6, 16, 18, 29] and the octilinear drawing models [3, 4, 7, 26], which both have several applications, such as in VLSI and floor-planning [25, 30], and in metro-maps and map-schematization [21, 27, 28]. Orthogonal drawings use only 2 slopes for the edge segments (0 and \(\frac{\pi }{2}\)), while octilinear drawings use no more than 4 slopes (0, \(\frac{\pi }{4}\), \(\frac{\pi }{2}\), and \(\frac{3\pi }{4}\)); consequently, they are limited to graphs with \(\varDelta \le 4\) and \(\varDelta \le 8\), respectively.

These two drawing models have been generalized to graphs with arbitrary maximum vertex degree \(\varDelta \) by Keszegh et al. [23], who proved that every planar graph admits a 2-bend planar drawing with \(\lceil \varDelta /2 \rceil \) equispaced slopes. As a witness of the tight connection between the two problems, the result by Keszegh et al. was built upon an older result for orthogonal drawings of degree-4 planar graphs by Biedl and Kant [6]. In the same paper, Keszegh et al. also studied the 1-bend planar slope number and showed an upper bound of \(2 \varDelta \) and a lower bound of \(\frac{3}{4}(\varDelta - 1)\) for this parameter. The upper bound has been recently improved, initially by Knauer and Walczak [24] to \(\frac{3}{2}(\varDelta - 1)\) and subsequently by Angelini et al. [1] to \(\varDelta -1\). Angelini et al. actually proved a stronger result: Given any set \(\mathcal {S}\) of \(\varDelta -1\) slopes, every planar graph with maximum vertex degree \(\varDelta \) admits a 1-bend planar drawing whose edge segments use only slopes in \(\mathcal {S}\). Any such slope set is hence called universal for 1-bend planar drawings. This result simultaneously establishes the best-known upper bound on the 1-bend planar slope number of planar graphs and the best-known lower bound on the angular resolution of 1-bend planar drawings, i.e., on the minimum angle between any two edge segments incident to the same vertex. Indeed, if the slopes in \(\mathcal {S}\) are equispaced, the resulting drawings have angular resolution at least \(\frac{\pi }{\varDelta -1}\).

In this paper we study slope sets that are universal for k-bend upward planar drawings of directed graphs (or digraphs for short). Recall that in an upward drawing of a digraph G, every edge (uv) is drawn as a y-monotone non-decreasing curve from u to v. Also, G admits an upward planar drawing if and only if it is a subgraph of a planar st-graph [13, 22]. As such drawings are common for representing planar digraphs, they have been extensively studied in the literature (see, e.g., [5, 9, 15, 18, 20]). A preliminary result for this setting is due to Di Giacomo et al. [14], who proved that every series-parallel digraph with maximum vertex degree \(\varDelta \) admits a 1-bend upward planar drawing that uses at most \(\varDelta \) slopes, and this bound on the number of slopes is worst-case optimal. Notably, their construction gives rise to drawings with optimal angular resolution \(\frac{\pi }{\varDelta }\) (but it uses a predefined set of slopes). Upward drawings with one bend per edge and few slopes have also been studied for posets by Czyzowicz et al. [11].

Fig. 1.
figure 1

(a) A 1-bend upward planar drawing of a bitonic st-graph, and (b) a 2-bend upward planar drawing of a planar st-graph, both defined on a slope set \(\mathcal {S}=\{-\frac{\pi }{4},0,\frac{\pi }{4},\frac{\pi }{2},\pi \}\).

Contribution. We extend the study of universal sets of slopes to upward planar drawings, and present the first constructive technique that works for all planar st-graphs. This technique exploits a linear ordering of the vertices of a planar digraph introduced by Gronemann [19], called bitonic st-ordering (see also Sect. 2). We show that any set \(\mathcal {S}\) of \(\varDelta \) slopes containing the horizontal slope is universal for 1-bend upward planar drawings of degree-\(\varDelta \) planar digraphs having a bitonic st-ordering (Sect. 3). We remark that the size of \(\mathcal {S}\) is worst-case optimal [14] and, if the slopes of \(\mathcal {S}\) are chosen to be equispaced, the angular resolution of the resulting drawing is at least \(\frac{\pi }{\varDelta }\) (also optimal); see Fig. 1a for an illustration. We then extend our construction to all planar st-graphs by using two bends on a restricted number of edges (Sect. 4). More precisely, we show that, given a set \(\mathcal {S}\) of \(\varDelta \) slopes containing the horizontal slope, every n-vertex upward planar digraph with maximum vertex degree \(\varDelta \) has a 2-bend upward planar drawing that uses only slopes in \(\mathcal {S}\) and with at most \(4n-9\) bends in total; see Fig. 1b for an illustration.

For space reasons some proofs are omitted and can be found in [2].

2 Preliminaries

We assume familiarity with common notation and definitions about graphs, drawings, and planarity (see, e.g., [12]).

Fig. 2.
figure 2

(a) A bitonic sequence. (b) A forbidden configuration.

An upward planar drawing of a directed simple graph (or digraph for short) G is a planar drawing such that each edge of G is drawn as a curve monotonically non-decreasing in the y-direction. An upward drawing is strict if its edge curves are monotonically increasing. A digraph is upward planar if it admits an upward planar drawing. Note that if a digraph admits an upward drawing then it also admits a strict upward drawing. A digraph is upward planar if and only if it is a subgraph of a planar st-graph [13]. Let \(G=(V,E)\) be an n-vertex planar st-graph, i.e., G is a plane acyclic digraph with a single source s and a single sink t, such that s and t belong to the boundary of the outer face and the edge \((s,t) \in E\) [13]. (Other works do not explicitly require the edge (st) to be part of G, see, e.g., [19].) An st-ordering of G is a numbering \(\sigma : V \rightarrow \{1,2,\dots ,n\}\) such that for each edge \((u,v) \in E\), it holds \(\sigma (u) < \sigma (v)\) (which implies \(\sigma (s)=1\) and \(\sigma (t)=n\)). Every planar st-graph has an st-ordering, which can be computed in O(n) time (see, e.g., [10]). If u and v are two adjacent vertices of G such that \(\sigma (u)<\sigma (v)\), we say that v is a successor of u, and u is a predecessor of v. Denote by \(S(u) = \{v_1,v_2,\dots ,v_q\}\) the sequence of successors of v ordered according to the clockwise circular order of the edges incident to u in the planar embedding of G. The sequence S(u) is bitonic if there exists an integer \(1 \le h \le q\) such that \(\sigma (v_1)< \dots< \sigma (v_{h-1}) < \sigma (v_h)> \sigma (v_{h+1})> \dots > \sigma (v_q)\); see Fig. 2a for an illustration. Notice that when \(h=1\) or \(h=q\), S(u) is actually a monotonic decreasing or increasing sequence. A bitonic st-ordering of G is an st-ordering such that, for every vertex \(u \in V\), S(u) is bitonic [19]. A planar st-graph G is a bitonic st-graph if it admits a bitonic st-ordering. Deciding whether G is bitonic can be done in linear time both in the fixed [19] and in the variable [8] embedding settings. If G is not bitonic, every st-ordering \(\sigma \) of G contains a forbidden configuration defined as follows. A sequence of successors S(u) of a vertex u forms a forbidden configuration if there exist two indices i and j, with \(i<j\), such that \(\sigma (v_i) > \sigma (v_{i+1})\) and \(\sigma (v_j) < \sigma (v_{j+1})\), i.e. there is a path from \(v_{i+1}\) to \(v_i\) and a path from \(v_j\) to \(v_{j+1}\); see Fig. 2b.

Let \(G=(V,E)\) be an n-vertex maximal plane graph with vertices u, v, and w on the boundary of the outer face. A canonical ordering [17] of G is a linear ordering \(\chi = \{v_1=u,v_2=v,\dots ,v_n=w\}\) of V, such that for every \(3 \le i \le n\):

  • C1: The subgraph \(G_i\) induced by \(\{v_1,v_2,\dots ,v_i\}\) is 2-connected and internally triangulated, while the boundary of its outer face \(C_i\) is a cycle containing \((v_1,v_2)\);

  • C2: If \(i+1\le n\), \(v_{i+1}\) belongs to \(C_{i+1}\) and its neighbors in \(G_{i}\) form a subpath of the path obtained by removing \((v_1,v_2)\) from \(C_i\).

Computing \(\chi \) takes O(n) time [17]. Also, \(\chi \) is upward if for every edge (uv) of a digraph G u precedes v in \(\chi \).

The slope of a line \(\ell \) is the angle \(\alpha \) that a horizontal line needs to be rotated counter-clockwise in order to make it overlap with \(\ell \). If \(\alpha =0\) we say that the slope of \(\ell \) is horizontal. The slope of a segment is the slope of the line containing it. Let \(\mathcal {S}=\{\alpha _1,\dots ,\alpha _h\}\) be a set of h slopes such that \(\alpha _i < \alpha _{i+1}\). The slope set \(\mathcal {S}\) is equispaced if \(\alpha _{i+1} - \alpha _i = \frac{\pi }{h}\), for \(i=1,\dots ,h-1\). Consider a k-bend planar drawing \(\varGamma \) of a graph G, i.e., a planar drawing in which every edge is mapped to a polyline containing at most \(k+1\) segments. For a vertex v in \(\varGamma \) each slope \(\alpha \in \mathcal {S}\) defines two different rays that emanate from v and have slope \(\alpha \). If \(\alpha \) is horizontal these rays are called left horizontal ray and right horizontal ray. Otherwise, one of them is the top and the other one is the bottom ray of v. We say that a ray \(r_v\) of a vertex v is free if there is no edge attached to v through \(r_v\) in \(\varGamma \). We also say that \(r_v\) is outer if it is free and the first face encountered when moving from v along \(r_v\) is the outer face of \(\varGamma \). The slope number of a k-bend drawing \(\varGamma \) is the number of distinct slopes used for the edge segments of \(\varGamma \). The k-bend upward planar slope number of an upward planar digraph G is the minimum slope number over all k-bend upward planar drawings of G.

3 1-Bend Upward Planar Drawings

Let \(G=(V,E)\) be an n-vertex planar st-graph with a bitonic st-ordering \(\sigma =\{v_1,v_2,\dots ,v_n\}\); see, e.g., Fig. 3a. We begin by describing an augmentation technique to “transform” \(\sigma \) into an upward canonical ordering of a suitable supergraph \(\widehat{G}\) of G. We start from a result by Gronemann [19], whose properties are summarized in the following lemma; see, e.g., Fig. 3b.

Lemma 1

([19]). Let \(G=(V,E)\) be an n-vertex planar st-graph that admits a bitonic st-ordering \(\sigma =\{v_1,v_2,\dots ,v_n\}\). There exists a planar st-graph \(G'=(V',E')\) with an st-ordering \(\chi =\{v_L,v_R,v_1,v_2,\dots ,v_n\}\) such that: (i) \(V'=V\cup \{v_L,v_R\}\); (ii) \(E \subset E'\) and \((v_L,v_R) \in E'\); (iii) \(v_L\) and \(v_R\) are on the boundary of the outer face of \(G'\); (iv) Every vertex of G with less than two predecessors in \(\sigma \) has exactly two predecessors in \(\chi \). Also, \(G'\) and \(\chi \) are computed in O(n) time.

We call \(G'\) a canonical augmentation of G. Observe that \(G'\) always contains the edges \((v_L,v_1)\) and \((v_R,v_1)\) because of Lemma (1). We also insert the edge \((v_L,v_n)\), which is required according to our definition of st-graph; this addition is always possible because \(v_L\) and \(v_n\) are both on the boundary of the outer face. The next lemma shows that any planar st-graph obtained by triangulating \(G'\) admits an upward canonical ordering; see, e.g., Fig. 3c.

Fig. 3.
figure 3

(a) A bitonic st-graph G with \(\sigma =\{v_1,v_2,\dots ,v_8\}\). (b) A canonical augmentation \(G'\) of G with \(\chi =\{v_L,v_R,v_1,v_2,\dots ,v_8\}\). (c) A planar st-graph \(\widehat{G}\) obtained by triangulating \(G'\). \(\chi \) is an upward canonical ordering of \(\widehat{G}\).

Lemma 2

Let \(G'\) be a canonical augmentation of an n-vertex bitonic st-graph G. Every planar st-graph \(\widehat{G}\) obtained by triangulating \(G'\) has the following properties: (a) it has no parallel edges; (b) \(\chi =\{v_L,v_R,v_1,v_2,\dots ,v_n\}\) is an upward canonical ordering.

Proof

Concerning Property (a), suppose for a contradiction that \(\widehat{G}\) has two parallel edges \(e_1\) and \(e_2\) connecting u with v. Let \(\mathcal {C}\) be the 2-cycle formed by \(e_1\) and \(e_2\) and let \(V_\mathcal {C}\) be the set of vertices distinct from u and v that are inside \(\mathcal C\) in the embedding of \(\widehat{G}\). \(V_\mathcal {C}\) is not empty, as otherwise \(\mathcal C\) would be a non-triangular face of \(\widehat{G}\). Let w be the vertex with the lowest number in \(\chi \) among those in \(V_\mathcal {C}\). Since \(\widehat{G}\) is planar (in particular \(e_1\) and \(e_2\) are not crossed) and has a single source, it contains a directed path from u to every vertex in \(V_\mathcal {C}\). Hence, it has an edge from u to w. Also, by assumption, there is no vertex z in \(V_\mathcal {C}\) such that \(\chi (z) < \chi (w)\), which implies that u is the only predecessor of w in \(\chi \), a contradiction to Lemma 1(iv). Concerning Property (b), if \(\chi \) is a canonical ordering of \(\widehat{G}\), then \(\chi \) is actually an upward canonical ordering because it is also an st-ordering. To see that \(\chi \) is a canonical ordering, observe first that \(v_L\), \(v_R\) and \(v_n\) are on the boundary of the outer face of \(\widehat{G}\) by construction. Denote by \(\widehat{G}_i\) the subgraph of \(\widehat{G}\) induced by \(\{v_L,v_R,v_1,\dots ,v_i\}\) and let \(\widehat{C}_i\) be the boundary of its outer face. We first prove by induction on i (for \(i=1,2,\dots ,n\)) that \(\widehat{G}_i\) is 2-connected. In the base case \(i=1\), \(\widehat{G}_1\) is a 3-cycle and therefore it is 2-connected. In the case \(i>1\), \(\widehat{G}_{i-1}\) is 2-connected by induction and \(v_{i}\) has at least two predecessors in \(\widehat{G}_{i-1}\) by Lemma 1(iv), thus \(\widehat{G}_{i}\) is 2-connected. We now prove that each \(\widehat{G}_i\), for \(i=1,2,\dots ,n\), is internally triangulated, which concludes the proof of condition C1 of canonical ordering. Suppose, for a contradiction, that there exists an inner face f that is not a triangle. Since \(\widehat{G}\) is triangulated, there exists a vertex \(v_j\), with \(j > i\), that is embedded inside f in \(\widehat{G}_j\). Since \(\chi \) is an st-ordering, there is no directed path from \(v_{j}\) to any vertex of f. On the other hand, either \(v_{j}=v_n\) or there is a directed path from \(v_{j}\) to \(v_n\). Both cases contradict the fact that \(v_n\) belongs to the boundary of the outer face of \(\widehat{G}\). We finally show that \(v_{i}\) belongs to \(C_{i}\), for \(i=1,2,\dots ,n\). Since we already proved that \(\widehat{G}_{i}\) is triangulated, this is enough to prove C2. By the planarity of \(\widehat{G}_i\), there is a face f in \(\widehat{G}_{i-1}\) such that all the neighbors of \(v_{i}\) in \(\widehat{G}_{i-1}\) belong to the boundary of f. We claim that f is the outer face of \(\widehat{G}_{i}\). If it was an inner face, then \(v_{i}\) would be embedded inside f in \(\widehat{G}_{i}\) and, by the same argument used above, \(v_n\) would not belong to the boundary of the outer face of \(\widehat{G}\).    \(\square \)

We now show that any set of \(\varDelta \) slopes \(\mathcal {S}\) that contains the horizontal slope is universal for 1-bend upward planar drawings of bitonic st-graphs. The algorithm is inspired by a technique of Angelini et al. [1]. We will use important additional tools with respect to [1], such as the construction of a triangulated canonical augmentation, extra slopes to draw the edges inserted by the augmentation procedure, and different geometric invariants. Let G be an n-vertex bitonic st-graph with maximum vertex degree \(\varDelta \); see Fig. 3a. The algorithm first computes a triangulated canonical augmentation \(\widehat{G}\) of G; see Figs. 3b and c. We call dummy edges all edges that are in \(\widehat{G}\) but not in G and real edges the edges in \(\widehat{G}\) that are also in G. By Lemma 2, \(\widehat{G}\) admits an upward canonical ordering \(\chi =\{v_L,v_R,v_1,v_2,\dots ,v_n\}\), where \(\chi \) is an st-ordering such that each vertex distinct from \(v_L\) and \(v_R\) has at least two predecessors. Let \(\mathcal {S}=\{\rho _1,\dots ,\rho _\varDelta \}\) be any set of \(\varDelta \) slopes, which we call real slopes. Let \(\rho ^*\) be the smallest angle between two slopes in \(\mathcal {S}\) and let \(\varDelta ^*\) be the maximum number of dummy edges incident to a vertex of \(\widehat{G}\). For each slope \(\rho _i\) (\(1 \le i \le \varDelta )\), we add \(\varDelta ^*\) dummy slopes \(\{\delta ^i_1,\dots ,\delta ^i_{\varDelta ^*}\}\) such that \(\delta ^i_j = \rho _i + j \cdot \frac{\rho ^*}{\varDelta ^*+1}\), for \(j=1,2,\dots , \varDelta ^*\). Hence, there are \(\varDelta ^*\) dummy slopes between any two consecutive real slopes. We will use the real slopes for the real edges and the dummy slopes for the dummy ones.

Let \(\widehat{G}_i\) be the subgraph of \(\widehat{G}\) induced by \(\{v_L,v_R,v_1,v_2,\dots ,v_i\}\). The algorithm constructs the drawing by adding the vertices according to \(\chi \). More precisely, it computes a drawing \(\widehat{\varGamma }_i\) of the digraph \(\widehat{G}^-_i\) obtained from \(\widehat{G}_i\) by removing the dummy edges \((v_L,v_R)\) and \((v_1,v_R)\), which exist by construction, and \((v_R,v_2)\) if it exists. Let \(\widehat{C}_i\) be the boundary of the outer face of \(\widehat{G}_i\), and let \(\widehat{P}_i\) be the path obtained by removing \((v_L,v_R)\) from \(\widehat{C}_i\). For a vertex v of \(\widehat{P}_i\), we denote by \(d_r(v,i)\) (resp. \(d_d(v,i)\)) the number of real (resp. dummy) edges incident to v that are not in \(\widehat{G}_{i}\) and by \(\overset{\curvearrowright }{\rho _{j}}(v,i)\) (resp. \(\overset{\curvearrowleft }{\rho _{j}}(v,i)\)) the j-th outer real top ray in \(\widehat{\varGamma }_{i}\) encountered in clockwise (resp. counterclockwise) order around v starting from the left (resp. right) horizontal ray. For dummy top rays, we define analogously \(\overset{\curvearrowright }{\delta _{j}}(v,i)\) and \(\overset{\curvearrowleft }{\delta _{j}}(v,i)\). \(\widehat{\varGamma }_i\) satisfies the following invariants:

Fig. 4.
figure 4

(a)–(b) Illustration for invariants I3I5; real rays are dashed, dummy rays are dotted. (c)–(d) Illustration for Lemma 4.

 

I1:

\(\widehat{\varGamma }_i\) is a 1-bend upward planar drawing whose real edges use only slopes in \(\mathcal {S}\).

I2:

Every edge of \(\widehat{P}_i\) contains a horizontal segment.

I3:

Every vertex v of \(\widehat{P}_i\) has at least \(d_r(v,i)\) outer real top rays; see Fig. 4a.

I4:

Every vertex v of \(\widehat{P}_i\) has at least \(d_d(v,i)\) outer dummy top rays between \(\overset{\curvearrowright }{\delta _{1}}(v,i)\) and \(\overset{\curvearrowright }{\rho _{1}}(v,i)\) (resp. \(\overset{\curvearrowleft }{\delta _{1}}(v,i)\) and \(\overset{\curvearrowleft }{\rho _{1}}(v,i)\)), including \(\overset{\curvearrowright }{\delta _{1}}(v,i)\) (resp. \(\overset{\curvearrowleft }{\delta _{1}}(v,i)\)); see Fig. 4b.

I5:

Let \(\ell \) be any horizontal line and let p and \(p'\) be any two intersection points between \(\ell \) and the polyline representing \(\widehat{P}_i\) in \(\widehat{\varGamma }_{i}\); walking along \(\ell \) from left to right, p and \(p'\) are encountered in the same order as when walking along \(\widehat{P}_i\) from \(v_L\) to \(v_R\); see Fig. 4b.

 

The last vertex \(v_n\) is added to \(\widehat{\varGamma }_{n-1}\) in a slightly different way and the resulting drawing will satisfy I1. The next two lemmas state important properties of any 1-bend upward planar drawing satisfying I1I5. Similar lemmas are proven in [1, Lemmas 2 and 3], but for drawings that satisfy different invariants.

Lemma 3

Let \(\widehat{\varGamma }_i\) be a drawing of \(\widehat{G}^-_i\) that satisfies Invariants I1I5. Let (uv) be any edge of \(\widehat{P}_i\) such that u is encountered before v along \(\widehat{P}_i\) when going from \(v_L\) to \(v_R\), and let \(\lambda \) be a positive number. There exists a drawing \(\widehat{\varGamma }'_i\) of \(\widehat{G}^-_i\) that satisfies Invariants I1I5 and such that: (i) the horizontal distance between u and v is increased by \(\lambda \); (ii) the horizontal distance between any two other consecutive vertices along \(\widehat{P}_i\) is the same as in \(\widehat{\varGamma }_i\).

The next lemma can be proven by suitably applying Lemma 3; see Figs. 4c and d.

Lemma 4

Let \(\widehat{\varGamma }_i\) be a drawing of \(\widehat{G}^-_i\) that satisfies Invariants I1I5. Let u be a vertex of \(\widehat{P}_i\), and let \(t_u\) be any outer top ray of u that crosses an edge of \(\widehat{G}^-_i\) in \(\widehat{\varGamma }_i\). There exists a drawing \(\widehat{\varGamma }'_i\) of \(\widehat{G}^-_i\) that satisfies Invariants I1I5 in which \(t_u\) does not cross any edge of \(\widehat{G}^-_i\).

We now describe our drawing algorithm starting with the computation of \(\widehat{\varGamma }_2\). We aim at drawing both \(v_1\) and \(v_2\) horizontally aligned between \(v_L\) and \(v_R\). Note that \(v_1\) is the source of G, and, by the definition of a canonical augmentation, \(v_1\) is adjacent to both \(v_L\) and \(v_R\), while \(v_2\) is adjacent to \(v_1\) and to at least one of \(v_L\) and \(v_R\). We remove the dummy edges \((v_1,v_R)\) and \((v_L,v_R)\), and the dummy edge \((v_R,v_2)\) if it exists. The resulting graph is either the path \(\langle v_L, v_1, v_2, v_R \rangle \) or the path \(\langle v_L, v_2, v_1, v_R \rangle \), which we draw along a horizontal segment.

Lemma 5

Drawing \(\widehat{\varGamma }_2\) satisfies Invariants I1I5.

Assume now that we have constructed drawing \(\widehat{\varGamma }_{i-1}\) of \(\widehat{G}_{i-1}\) satisfying I1I5 \((3 \le i < n)\). Let \(\{u_1,\dots ,u_q\}\) be the neighbors of the next vertex \(v_i\) along \(\widehat{P}_{i-1}\). Let \(t_{1}\) be either \(\overset{\curvearrowleft }{\rho _{1}}(u_1,i-1)\), if \((u_1,v_i)\) is real, or \(\overset{\curvearrowleft }{\delta _{1}}(u_1,i-1)\), if \((u_1,v_i)\) is dummy. Symmetrically, let \(t_{q}\) be either \(\overset{\curvearrowright }{\rho _{1}}(u_q,i-1)\), if \((u_q,v_i)\) is real, or \(\overset{\curvearrowright }{\delta _{1}}(u_q,i-1)\), if \((u_q,v_i)\) is dummy. Let \(t_{j}\) (for \(1< j < q\)) be any outer real (resp. dummy) top ray emanating from \(u_j\) if \((u_j,v_i)\) is real (resp. dummy). By I3 all such top rays exist and by Lemma 4 we can assume that none of them crosses \(\widehat{\varGamma }_{i-1}\).

Fig. 5.
figure 5

Addition of vertex \(v_i\).

Let \(\ell \) be a horizontal line above the topmost point of \(\widehat{\varGamma }_{i-1}\). Let \(p_j\) be the intersection point of \(t_{j}\) and \(\ell \). We can assume that, for \(j=1,2,\dots ,q-1\), \(p_j\) is to the left of \(p_{j+1}\). If this is not the case, we can increase the distance between \(u_j\) and \(u_{j+1}\) so to guarantee that \(p_j\) and \(p_{j+1}\) appear in the desired order along \(\ell \); this can be done by applying Lemma 3 with respect to each edge \((u_j,u_{j+1})\) for a suitable choice of \(\lambda \); see Figs. 5a and b for an illustration. We will place \(v_i\) above \(\ell \) using \(q-2\) bottom rays \(b_2,b_3,\dots ,b_{q-1}\) of \(v_i\) for the segments of the edges \((u_j,v_i)\) (\(j=2,3,\dots ,q-1\)) incident to \(v_i\) such that: (i) \(b_j\) (\(1<j < q\)) is real (resp. dummy) if \((u_j,v_i)\) is real (resp. dummy); (ii) \(b_j\) precedes \(b_{j+1}\) in the counterclockwise order around \(v_i\) starting from \(b_2\). This choice is possible for the real rays because \(v_i\) has \(\varDelta -1\) real bottom rays and it has at least one incident real edge not in \(\widehat{G}_{i}\) (otherwise it would be a sink of G, which is not possible because \(i < n\)). Concerning the dummy rays, we have at most \(\varDelta ^*\) dummy edges incident to \(v_i\) and \(\varDelta ^*\) dummy bottom rays between any two consecutive real rays. Consider the ray \(t_{1}\) and choose a point p to the right of \(t_{1}\) and above \(\ell \) such that placing \(v_i\) on p guarantees that \(\min _{i=1 \dots q-2}\{x(p'_{i+1})-x(p'_i)\} > x(p_q)-x(p_1)\), where \(p'_1=p_1\) and \(p'_2,p'_3,\dots ,p'_{q-1}\) are the intersection points of the rays \(b_2,b_3,\dots ,b_{q-1}\) with the line \(\ell \) (see Fig. 5c). Observe that for a sufficiently large y-coordinate, point p can always be found. We now apply Lemma 3 to each of the edges \((u_1,u_2)\), \((u_2,u_3)\), \(\dots \), \((u_{q-2},u_{q-1})\), in this order, choosing \(\lambda \ge 0\) so that each \(p_j\) is translated to \(p'_j\) (for \(j=2,3,\dots ,q-1\)). We finally apply again the same procedure to \((u_{q-1},u_q)\) so that the intersection point between \(t_{q}\) and the horizontal line \(\ell _H\) passing through \(v_i\) is to the right of \(v_i\) (see Fig. 5d). After this translation procedure, we can draw the edge \((u_1,v_i)\) (resp. \((u_q,v_i)\)) with a bend at the intersection point between \(t_{1}\) (resp. \(t_{q}\)) and \(\ell _H\) and therefore using the slope of \(t_{1}\) (resp. \(t_{q}\)) and the horizontal slope (see Fig. 5e). The edges \((u_j,v_i)\) (\(j=2,3,\dots ,q-1\)) are drawn with a bend point at \(p_j=p'_j\) and therefore using the slopes of \(t_{j}\) and \(b_j\).

Lemma 6

Drawing \(\widehat{\varGamma }_i\), for \(i=3,4,\dots ,n-1\), satisfies Invariants I1I5.

Proof

The proof is by induction on \(i \ge 3\). \(\widehat{\varGamma }_{i-1}\) satisfies Invariants I1I5 by Lemma 5 when \(i=3\), and by induction when \(i > 3\).

Proof of I1. By construction, each \((u_j,v_i)\) (\(j=1,2,\dots ,q\)) is drawn as a chain of at most two segments that use real and dummy slopes. In particular, if \((u_j,v_i)\) is real, then it uses real slopes, i.e., slopes in \(\mathcal {S}\). By the choice of \(\ell \), the bend point of \((u_j,v_i)\) has y-coordinate strictly greater than that of \(u_j\) and smaller than or equal to that of \(v_i\). Since each \((u_j,v_i)\) is oriented from \(u_j\) to \(v_i\) (as \(\chi \) is an upward canonical ordering), the drawing is upward. Concerning planarity, we first observe that \(\widehat{\varGamma }_{i-1}\) is planar and it remains planar each time we apply Lemma 3. Also, by Lemma 4 each \((u_j,v_i)\) (\(j=1,2,\dots ,q\)) does not intersect \(\widehat{\varGamma }_{i-1}\) (except at \(u_j\)). Further, the order of the bend points along \(\ell \) guarantees that the edges incident to \(v_i\) do not cross each other.

Proof of I2. The only edges of \(\widehat{P}_i\) that are not in \(\widehat{P}_{i-1}\) are \((u_1,v_i)\) and \((u_q,v_i)\). For both these edges the segment incident to \(v_i\) is horizontal by construction.

Proof of I3. For each vertex of \(\widehat{P}_i\) distinct from \(u_1\), \(u_q\) and \(v_i\), I3 holds by induction. Invariant I3 also holds for \(v_i\) because \(d_r(v_i,i) \le \varDelta -1\) (as otherwise \(v_i\) would be a source of G, which is not possible because \(i>1\)) and all the real top rays of \(v_i\), which are \(\varDelta -1\), are outer. Consider now vertex \(u_1\) (a symmetric argument applies to \(u_q\)). If \((u_1,v_i)\) is real, then \(d_r(u_1,i)=d_r(u_1,i-1)-1\); in this case \(t_{1}=\overset{\curvearrowleft }{\rho _{1}}(u_1,i-1)\) and therefore all the other \(d_r(u_1,i-1)-1\) outer real top rays of \(u_1\) in \(\widehat{\varGamma }_{i-1}\) remain outer in \(\widehat{\varGamma }_{i}\). If \((u_1,v_i)\) is dummy, then \(d_r(u_1,i)=d_r(u_1,i-1)\); in this case \(t_{1}=\overset{\curvearrowleft }{\delta _{1}}(u_1,i-1)\) and therefore all the \(d_r(u_1,i-1)\) outer real top rays of \(u_1\) in \(\widehat{\varGamma }_{i-1}\) remain outer in \(\widehat{\varGamma }_{i}\).

Proof of I4. For each vertex of \(\widehat{P}_i\) distinct from \(u_1\), \(u_q\) and \(v_i\), I4 holds by induction. I4 also holds for \(v_i\) because \(d_d(v_i,i) \le \varDelta ^*\) and there are \(\varDelta ^*\) dummy top rays between \(\overset{\curvearrowright }{\delta _{1}}(v_i,i)\) and \(\overset{\curvearrowright }{\rho _{1}}(v_i,i)\) including \(\overset{\curvearrowright }{\delta _{1}}(v_i,i)\) (all the top rays of \(v_i\) are outer). Analogously, there are \(\varDelta ^*\) outer dummy top rays between \(\overset{\curvearrowleft }{\delta _{1}}(v_i,i)\) and \(\overset{\curvearrowleft }{\rho _{1}}(v_i,i)\) including \(\overset{\curvearrowleft }{\delta _{1}}(v_i,i)\). Consider now \(u_1\) (a symmetric argument applies to \(u_q\)). If \((u_1,v_i)\) is real, then \(d_d(u_1,i)=d_d(u_1,i-1)\); in this case \(t_{1}=\overset{\curvearrowleft }{\rho _{1}}(u_1,i-1)\) and there are \(\varDelta ^*\) outer dummy top rays between \(\overset{\curvearrowleft }{\delta _{1}}(u_1,i)\) and \(\overset{\curvearrowleft }{\rho _{1}}(u_1,i)\) including \(\overset{\curvearrowleft }{\delta _{1}}(u_1,i)\) (namely, all those between \(t_{1}=\overset{\curvearrowleft }{\rho _{1}}(u_1,i-1)\) and \(\overset{\curvearrowleft }{\rho _{2}}(u_1,i-1)\)). If \((u_1,v_i)\) is dummy, then \(d_d(u_1,i)=d_d(u_1,i-1)-1\); in this case \(t_{1}=\overset{\curvearrowleft }{\delta _{1}}(u_1,i-1)\) and therefore all the other \(d_d(u_1,i-1)-1\) outer dummy top rays of \(u_1\), which by induction were between \(\overset{\curvearrowleft }{\delta _{1}}(u_1,i-1)\) and \(\overset{\curvearrowleft }{\rho _{1}}(u_1,i-1)\), remain outer in \(\widehat{\varGamma }_{i}\).

Proof of I5. Notice that the various applications of Lemma 3 to \(\widehat{\varGamma }_{i-1}\) preserve I5. Let p and \(p'\) be any two intersection points between a horizontal line \(\ell \) and the polyline representing \(\widehat{P}_i\) in \(\widehat{\varGamma }_{i}\), with p to the left of \(p'\) along \(\ell \). If p and \(p'\) belong to \(\widehat{P}_{i-1}\), I5 holds by induction. If both p and \(p'\) belong to the path \(\langle u_1, v_i, u_q \rangle \), I5 holds by construction. If p belongs to \(\widehat{P}_{i-1}\) and \(p'\) belongs to \(\langle u_1, v_i, u_q \rangle \), then p belongs to the subpath of \(\widehat{P}_{i-1}\) that goes from \(v_L\) to \(u_1\) because the subpath from \(u_q\) to \(v_R\) is completely to the right of \(t_{q}\), hence I5 holds also in this case. If p belongs to \(\langle u_1, v_i, u_q \rangle \) and \(p'\) belongs to \(\widehat{P}_{i-1}\), the proof is symmetric.    \(\square \)

Lemma 7

G has a 1-bend upward planar drawing \(\varGamma \) using only slopes in \(\mathcal {S}\).

Proof

By Lemma 6, drawing \(\widehat{\varGamma }_{n-1}\) satisfies Invariant I1I5. We explain how to add the last vertex \(v_n\) to obtain a drawing that satisfies Invariant I1. Let \(\{u_1,\dots ,u_q\}\) be the predecessors of \(v_n\) on \(\widehat{P}_{n-1}\). Notice that, in this case \(u_1=v_L\) and \(u_q=v_R\). Vertex \(v_n\) is added to the drawing similarly to all the other vertices added in the previous steps of the algorithm. The only difference is that the number of real incoming edges incident to \(v_n\) in \(\widehat{\varGamma }_{n-1}\) can be up to \(\varDelta \). If this is the case, since the real bottom rays are \(\varDelta -1\), they are not enough to draw all the real edges incident to \(v_n\). Let j be the smallest index such that \((u_j,v_n)\) is a real edge. We ignore all the dummy edges \((u_h,v_n)\), for \(h=1,2,\dots ,j-1\), and apply the construction used in the previous steps considering only \(\{u_j,u_{j+1},\dots ,u_q\}\) as predecessors of \(v_n\) (notice that such predecessors are at least two because \(v_n\) has at least two incident real edges). By ignoring these dummy edges, the segment of the real edge \((u_j,v_n)\) incident to \(v_n\) will be drawn using the left horizontal slope. Denote by \(\widehat{\varGamma }_{n}\) the resulting drawing. As in the proof of Lemma 6, we can prove that I1 holds for \(\widehat{\varGamma }_{n}\) and therefore \(\widehat{\varGamma }_{n}\) is a 1-bend upward planar drawing whose real edges use only slopes in \(\mathcal {S}\). The drawing \(\varGamma \) of G is obtained from \(\widehat{\varGamma }_{n}\) by removing all its dummy edges and the two dummy vertices \(v_L\) and \(v_R\).    \(\square \)

Lemma 8

Drawing \(\varGamma \) can be computed in O(n) time.

Lemmas 7 and 8 are summarized by Theorem 1. Corollary 1 is a consequence of Theorem 1 and of a result in [14].

Theorem 1

Let \(\mathcal {S}\) be any set of \(\varDelta \ge 2\) slopes including the horizontal slope and let G be an n-vertex bitonic planar st-graph with maximum vertex degree \(\varDelta \). Graph G has a 1-bend upward planar drawing \(\varGamma \) using only slopes in \(\mathcal {S}\), which can be computed in O(n) time.

Corollary 1

Every bitonic st-graph with maximum vertex degree \(\varDelta \ge 2\) has 1-bend upward planar slope number at most \(\varDelta \), which is worst-case optimal.

If \(\mathcal {S}\) is equispaced, Theorem 1 implies a lower bound of \(\frac{\pi }{\varDelta }\) on the angular resolution of the computed drawing, which is worst-case optimal [14]. Also, Theorem 1 can be extended to planar st-graphs with \(\varDelta \le 3\), as any such digraph can be made bitonic by only rerouting the edge (st).

Theorem 2

Every planar st-graph with maximum vertex degree 3 has 1-bend upward planar slope number at most 3.

We conclude with the observation that an upward drawing constructed by the algorithm of Theorem 1 can be transformed into a strict upward drawing that uses \(\varDelta +1\) slopes rather than \(\varDelta \). It suffices to replace every horizontal segment oriented from its leftmost (rightmost) endpoint to its rightmost (leftmost) one with a segment having slope \(\varepsilon \) (\(-\varepsilon \)), for a sufficiently small value of \(\varepsilon >0\).

4 2-bend Upward Planar Drawings

We now extend the result of Theorem 1 to non-bitonic planar st-graphs. By adapting a technique of Keszegh et al. [23], one can construct 2-bend upward planar drawings of planar st-graphs using at most \(\varDelta \) slopes. We improve upon this result in two ways: (i) The technique in [23] may lead to drawings with \(5n-11\) bends in total, while we prove that \(4n-9\) bends suffice; (ii) It uses a fixed set of \(\varDelta \) slopes (and it is not immediately clear whether it can work with any set of slopes), while we show that any set of \(\varDelta \) slopes with the horizontal one is universal.

Let G be an n-vertex non-bitonic planar st-graph. All forbidden configurations of G can be removed in linear time by subdividing at most \(n-3\) edges of G [19]. Let \(G_b\) be the resulting bitonic st-graph, called a bitonic subdivision of G. Let \(\langle u,d,v \rangle \) be a directed path of \(G_b\) obtained by subdividing the edge (uv) of G with the dummy vertex d. We call (ud) the lower stub, and (dv) the upper stub of (uv). We can prove the existence of an augmentation technique similar to that of Lemma 1, but with an additional property on the upper stubs.

Lemma 9

Let \(G=(V,E)\) be an n-vertex planar st-graph that is not bitonic. Let \(G_b=(V_b,E_b)\) be an N-vertex bitonic subdivision of G, with a bitonic st-ordering \(\sigma =\{v_1,v_2,\dots ,v_N\}\). There exists a planar st-graph \(G'=(V',E')\) with an st-ordering \(\chi =\{v_L,v_R,v_1,v_2,\dots ,v_N\}\) such that: (i) \(V'=V_b\cup \{v_L,v_R\}\); (ii) \(E_b \subset E'\) and \((v_L,v_R) \in E'\); (iii) \(v_L\) and \(v_R\) are on the boundary of the outer face of \(G'\); (iv) Every vertex of \(G_b\) with less than two predecessors in \(\sigma \) has exactly two predecessors in \(\chi \). (v) There is no vertex in \(G'\) such that its leftmost or its rightmost incoming edge is an upper stub. Also, \(G'\) and \(\chi \) are computed in O(n) time.

Theorem 3

Let \(\mathcal {S}\) be any set of \(\varDelta \ge 2\) slopes including the horizontal slope and let G be an n-vertex planar st-graph with maximum vertex degree \(\varDelta \). Graph G has a 2-bend upward planar drawing \(\varGamma \) using only slopes in \(\mathcal {S}\), which has at most \(4n-9\) bends in total and which can be computed in O(n) time.

Proof

We compute a triangulated canonical augmentation \(\widehat{G}\) of G by (1) applying Lemma 9 and (2) triangulating the resulting digraph. By Lemma 2, \(\widehat{G}\) has an upward canonical ordering \(\chi \). The algorithm of Theorem 1 to \(\widehat{G}\) would lead to a 3-bend drawing of G (by interpreting every subdivision vertex as a bend). We explain how to modify it to construct a drawing \(\widehat{\varGamma }\) of \(\widehat{G}\) with at most 2 bends per edge and \(4n-9\) bends in total. Let \(v_i\) the next vertex to be added according to \(\chi \) and let \(\{u_1,u_2,\dots ,u_q\}\) its neighbors in \(\widehat{P}_{i-1}\). Suppose that \(u_j\) is a dummy vertex and that \((u_j,v_i)\) is an upper stub. To save one bend along the edge subdivided by \(u_j\), we draw \((u_j,v_i)\) without bends. By Lemma 9(v), we have that \(1< j < q\). The ray \(t_{j}\) used to draw the segment of \((u_j,v_i)\) incident to \(u_j\) can be any outer real top ray; we choose the ray with same slope as the real bottom ray \(b_j\) used to draw the segment of \((u_j,v_i)\) incident to \(v_i\). This is possible because all real top rays of \(u_j\) are outer (since \((u_j,v_i)\) is the only real outgoing edge of \(u_j\)). Hence, edge \((u_j,v_i)\) has no bends. The drawing \(\varGamma \) of G is obtained from \(\widehat{\varGamma }\) by removing dummy edges and replacing dummy vertices (except \(v_L\) and \(v_R\), which are removed) with bends. Since the upper stubs of subdivided edges has 0 bends, each edge of \(\varGamma \) has at most 2 bends. Let \(m_1\) and \(m_2\) be the number of edges drawn with 1 and 2 bends, respectively; we have \(m_2 \le n-3\) and \(m_1=m-m_2 \le 3n-6 -(n-3)=2n-3\). Thus the total number of bends is at most \(2n-3+2(n-3)=4n-9\). Finally, \(\widehat{G}\) can be computed in O(n) time (Lemma 9) and the modified drawing algorithm still runs in linear time.    \(\square \)

A planar st-graph with a source/sink of degree \(\varDelta \) requires at least \(\varDelta -1\) slopes in any upward planar drawing; thus the gap with Theorem 3 is one unit. Similarly to Theorem 1, Theorem 3 implies a lower bound of \(\frac{\pi }{\varDelta }\) on the angular resolution of \(\varGamma \); an upper bound of \(\frac{\pi }{\varDelta -1}\) can be proven with the same digraph used for the lower bound on the slope number. Finally, Theorem 4 extends the result of Theorem 3 to every upward planar graph using an additional slope.

Theorem 4

Let \(\mathcal {S}\) be any set of \(\varDelta +1\) slopes including the horizontal slope and let G be an n-vertex upward planar graph with maximum vertex degree \(\varDelta \ge 2\). Graph G has a 2-bend upward planar drawing using only slopes in \(\mathcal {S}\).

5 Open Problems

(i) Can we draw every planar st-graph with at most one bend per edge (or less than \(4n-9\) in total) and \(\varDelta \) slopes? (ii) What is the 2-bend upward planar slope number of planar st-graphs? Is \(\varDelta \) a tight bound? (iii) What is the straight-line upward planar slope number of upward planar digraphs?