Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

1 Introduction

In an L-drawing of a directed graph each vertex v is assigned a point in the plane with exclusive integer x- and y-coordinates, and each directed edge (uv) consists of a vertical segment exiting u and of a horizontal segment entering v [1]. The drawings of two edges may cross and partially overlap, following the model of [17]. The ambiguity among crossings and bends is resolved by replacing bends with small rounded junctions. An L-drawing in which edges possibly overlap, but do not cross, is a planar L-drawing; see, e.g., Fig. 1b. A planar L-drawing is upward planar if its edges are y-monotone, and it is upward-rightward planar if its edges are simultaneously x-monotone and y-monotone.

Fig. 1.
figure 1

(a) A bitonic st-orientation of the octahedron that admits an upward planar L-drawing (b). (c) The corresponding drawing in the Kandinsky model. (d) An upward planar st-graph U that does not admit an upward-planar L-drawing

Planar L-drawings correspond to drawings in the Kandinsky model [12] with exactly one bend per edge and with some restrictions on the angles around each vertex; see Fig. 1c. It is NP-complete [4] to decide whether a multigraph has a planar embedding that allows a Kandinsky drawing with at most one bend per edge [5]. On the other hand, every simple planar graph has a Kandinsky drawing with at most one bend per edge [5]. Bend-minimization in the Kandinsky-model is NP-complete [4] even if a planar embedding is given, but can be approximated by a factor of two [2, 11]. Heuristics for drawings in the Kandinsky model with empty faces and few bends have been discussed by Bekos et al. [3].

Bitonic st-orderings were introduced by Gronemann for undirected planar graphs [14] as an alternative to canonical orderings. They were recently extended to directed plane graphs [16]. In a bitonic st-ordering the successors of any vertex must form an increasing and then a decreasing sequence in the given embedding. More precisely, a planar st-graph is a directed acyclic graph with a single source s and a single sink t that admits a planar embedding in which s and t lie on the boundary of the same face. A planar st-graph always admits an upward-planar straight-line drawing [8]. An st-ordering of a planar st-graph is an enumeration \(\pi \) of the vertices with distinct integers, such that \(\pi (u) < \pi (v)\) for every edge \((u,v) \in E\). Given a plane st-graph, i.e., a planar st-graph with a fixed upward-planar embedding \(\mathcal E\), consider the list \(S(v)=\langle v_1,v_2,\dots ,v_k \rangle \) of successors of v in the left-to-right order in which they appear around v. The list S(v) is monotonically decreasing with respect to an st-ordering \(\pi \) if \(\pi (v_i)>\pi (v_{i+1})\) for \(i=1,\dots ,k-1\). It is bitonic with respect to \(\pi \) if there is a vertex \(v_h\) in S(v) such that \(\pi (v_i)<\pi (v_{i+1})\), \(i=1,\dots ,h-1\) and \(\pi (v_i)>\pi (v_{i+1})\), \(i=h,\dots ,k-1\). For an upward-planar embedding \(\mathcal E\), an st-ordering \(\pi \) is bitonic or monotonically decreasing, respectively if the successor list of each vertex is bitonic or monotonically decreasing, respectively. Here, \(\langle \mathcal{E}, \pi \rangle \) is called a bitonic pair or monotonically decreasing pair, respectively, of G.

Gronemann used bitonic st-orderings to obtain on the one hand upward-planar polyline grid drawings in quadratic area with at most \(|V|-3\) bends in total [16] and on the other hand contact representations with upside-down oriented T-shapes [15]. A bitonic st-ordering for biconnected undirected planar graphs can be computed in linear time [14] and the existence of a bitonic st-ordering for plane (directed) st-graphs can also be decided in linear time [16]. However, in the variable embedding scenario no algorithm is known to decide whether an st-graph G admits a bitonic pair. Bitonic st-orderings turn out to be strongly related to upward-planar L-drawings of st-graphs. In fact, the y-coordinates of an upward-planar L-drawing yield a bitonic st-ordering.

In this work, we initiate the investigation of planar and upward-planar L-drawings. In particular, our contributions are as follows. (i) We prove that deciding whether a directed planar graph admits a planar L-drawing is NP-complete. (ii) We characterize the planar st-graphs admitting an upward (upward-rightward, resp.) planar L-drawing as the st-graphs admitting a bitonic (monotonic decreasing, resp.) st-ordering. (iii) We provide a linear-time algorithm to compute an embedding, if any, of a planar st-graph that allows for a bitonic st-ordering. This result complements the analogous algorithm proposed by Gronemann for undirected graphs [14] and extends the algorithm proposed by Gronemann for planar st-graphs in the fixed embedding setting [16]. (iv) Finally, we show how to decide efficiently whether there is a planar L-drawing for a plane directed graph with a fixed assignment of the edges to the four ports of the vertices.

Due to space limitations, full proofs are provided in [6].

2 Preliminaries

We assume familiarity with basic graph drawing concepts and in particular with the notions of connectivity and SPQR-trees (see also [6, 9]).

A (simple, finite) directed graph \(G=(V,E)\) consists of a finite set V of vertices and a finite set \(E \subseteq \{(u,v) \in V \times V; u \ne v\}\) of ordered pairs of vertices. If (uv) is an edge then v is a successor of u and u is a predecessor of v. A graph is planar if it admits a drawing in the plane without edge crossings. A plane graph is a planar graph with a fixed planar embedding, i.e., with fixed circular orderings of the edges incident to each vertex—determined by a planar drawing—and with a fixed outer face.

Given a planar embedding and a vertex v, a pair of consecutive edges incident to v is alternating if they are not both incoming or both outgoing. We say that v is k-modal if there exist exactly k alternating pairs of edges in the cyclic order around v. An embedding of a directed graph G is k-modal, if each vertex is at most k-modal. A 2-modal embedding is also called bimodal. An upward-planar drawing determines a bimodal embedding. However, the existence of a bimodal embedding is not a sufficient condition for the existence of an upward-planar drawing. Deciding whether a directed graph admits an upward-planar (straight-line) drawing is an NP-hard problem [13].

figure a

L-Drawings. A planar L-drawing determines a 4-modal embedding. This implies that there exist planar directed graphs that do not admit planar L-drawings. A 6-wheel whose central vertex is incident to alternating incoming and outgoing edges is an example of a graph that does not admit any 4-modal embedding, and therefore any planar L-drawing.

On the other hand, the existence of a 4-modal embedding is not sufficient for the existence of a planar L-drawing. E.g., the octahedron depicted in the figure on the right does not admit a planar L-drawing. Since the octahedron is triconnected, it admits a unique combinatorial embedding (up to a flip). Each vertex is 4-modal. However, the rightmost vertex in a planar L-drawing must be 1-modal or 2-modal.

Any upward-planar L-drawing of an st-graph G can be modified to obtain an upward-planar drawing of G: Redraw each edge as a y-monotone curve arbitrarily close to the drawing of the corresponding 1-bend orthogonal polyline while avoiding crossings and edge-edge overlaps. However, not every upward-planar graph admits an upward-planar L-drawing. E.g., the graph in Fig. 1d contains a subgraph that does not admit a bitonic st-ordering [16]. In Sect. 4 (Theorem 3), we show that this means it does not admit an upward planar L-drawing.

The Kandinsky Model. In the Kandinsky model [12], vertices are drawn as squares of equal sizes on a grid and edges—usually undirected—are drawn as orthogonal polylines on a finer grid; see Fig. 1c. Two consecutive edges in the clockwise order around a vertex define a face and an angle in \(\{0, \pi /2, \pi , 3\pi /2, 2\pi \}\) in that face. In order to avoid edges running through other vertices, the Kandinsky model requires the so called bend-or-end property: There is an assignment of bends to vertices with the following three properties. (a) Each bend is assigned to at most one vertex. (b) A bend may only be assigned to a vertex to which it is connected by a segment (i.e., it must be the first bend on an edge). (c) If \(e_1,e_2\) are two consecutive edges in the clockwise order around a vertex v that form a 0 angle inside face f, then a bend of \(e_1\) or \(e_2\) forming a \(3\pi /2\) angle inside f must be assigned to v. Further, the Kandinsky model requires that there are no empty faces.

Given a planar L-drawing, consider a vertex v and all edges incident to one of the four ports of v. By assigning to v all bends on these edges—except the bend furthest from v—we satisfy the bend-or-end property. This implies the following lemma, which is proven in [6].

Lemma 1

A graph has a planar L-drawing if and only if it admits a drawing in the Kandinsky model with the following properties: (i) Each edge bends exactly once; (ii) at each vertex, the angle between any two outgoing (or between any two incoming) edges is 0 or \(\pi \); and (iii) at each vertex, the angle between any incoming edge and any outgoing edge is \(\pi /2\) or \(3\pi /2\).

3 General Planar L-Drawings

We consider the problem of deciding whether a graph admits a planar L-drawing. In Sect. 3.1, we show that the problem is NP-complete if no planar embedding is given. In the fixed embedding setting (Sect. 3.2) the problem can be described as an ILP. It is solvable in linear time if we also fix the ports.

3.1 Variable Embedding Setting

As a central building block for our hardness reduction we use a directed graph W that can be constructed starting from a 4-wheel with central vertex c and rim (uvwz). We orient the edges of W so that v and z (the V-ports of W) are sinks and u and w (the H-ports of W) are sources. Finally, we add directed edges (vc), (zc), (cw), and (cu); see Fig. 2. We now provide Lemma 2 which describes the key property of planar L-drawings of W.

Fig. 2.
figure 2

4-wheel graph W and two planar L-drawings of W.

Lemma 2

In any planar L-drawing of W with cycle (uvwz) as the outer face the edges of the outer face form a rectangle (that contains vertex c).

We are now ready to give the main result of the section.

Theorem 1

It is NP-complete to decide whether a directed graph admits a planar L-drawing.

Sketch of proof

We reduce from the NP-complete problem of HV-rectilinear planarity testing [10]. In this problem, the input is a biconnected degree-4 planar graph G with edges labeled either H or V, and the goal is to decide whether G admits an HV-drawing, i.e., a planar drawing such that each H-edge (V-edge) is drawn as a horizontal (vertical) segment. Starting from G, we construct a graph \(G'\) by replacing: (i) vertices with 4-wheels as in Fig. 2; (ii) V-edges with the gadget shown in Fig. 3a; and (iii) H-edges with an appropriately rotated and re-oriented version of the V-edge gadget. If (uv) is a V-edge, the two vertices labeled u and v of its gadget are identified with a V-port of the respective vertex gadgets. Otherwise, they are identified with an H-port. Figure 3b shows a vertex gadget with four incident edges. The proof that \(G'\) and G are equivalent is somewhat similar to Brückner’s hardness proof in [5, Theorem 3] and exploits Lemma 2. Refer to [6] for the full details.    \(\square \)

Fig. 3.
figure 3

(a) Edge gadget for a V-edge. (b) Connections among gadgets.

3.2 Fixed Embedding and Port Assignment

In this section, we show how to decide efficiently whether there is a planar L-drawing for a plane directed graph with a fixed assignment of the edges to the four ports of the vertices. Using Lemma 1 and the ILP formulation of Barth et  al. [2], we first set up linear inequalities that describe whether a plane 4-modal graph has a planar L-drawing. Using these inequalities, we then transform our decision problem into a matching problem that can be solved in linear time.

We call a vertex v an in/out-vertex on a face f if v is incident to both, an incoming edge and an outgoing edge on f. Let \(x_{vf} \in \{0,1,2\}\) describe the angle in a face f at a vertex v: the angle between two outgoing or two incoming edges is \(x_{vf}\cdot \pi \) and the angle between an incoming and an outgoing edge is \(x_{vf}\cdot \pi + \pi /2\). Let \(x_{f e}^v \in \{0,1\}\) be 1 if there is a convex bend in face f on edge e assigned to a vertex v to fulfill the bend-or-end property. There is a planar L-drawing with these parameters if and only if the following four conditions are satisfied (see [6] for details): (1) The angles around a vertex v sum to \(2\pi \). (2) Each edge has exactly one bend. (3) The number of convex angles minus the number of concave angles is 4 in each inner face and \(-4\) in the outer face. (4) The bend-or-end property is fulfilled, i.e., for any two edges \(e_1\) and \(e_2\) that are consecutive around a vertex v and that are both incoming or both outgoing, and for the faces \(f_1\), f, and \(f_2\) that are separated by \(e_1\) and \(e_2\) (in the cyclic order around v), it holds that \(x_{vf} + x_{f_1 e_1}^v + x_{f_2e_2}^v \ge 1\). Let \(e=(v,w)\) be incident to faces f and h, Condition (2) implies \(-x_{h e}^v - x_{he}^w = x_{fe}^v + x_{fe}^w-1\). Hence, (3) yields

Observe that the number of in/out-vertices on a face f is odd if and only if \(\deg f\) is odd. Moreover, if we omit the bend-or-end property, we can formulate the remaining conditions as an uncapacitated network flow problem. The network has three types of nodes: one for each vertex, face, and edge of the graph. It has two types of edges: from vertices to incident faces and from faces to incident edges. The supplies are \(\lceil \frac{4-k}{2}\rceil \) for the k-modal vertices, \(\pm 2 + 1/2\cdot ( \# \text {in/out-vertices } - \deg f)\) for a face f, and \(-1\) for the edges.

Theorem 2

Given a directed plane graph G and labels \(out(e)\in \{\mathrm{top}, \mathrm{bottom}\}\) and \(in(e)\in \{\mathrm{right}, \mathrm{left}\}\) for each edge e, it can be decided in linear time whether G admits a planar L-drawing in which each edge e leaves its tail at out(e) and enters its head at in(e).

Sketch of proof

First, we have to check whether the cyclic order of the edges around a vertex is compatible with the labels. The labels determine the bends and the angles around the vertices, i.e., \(x_{fe}^v+x_{fe}^w\) for each edge \(e=(v,w)\) and each incident face f, and \(x_{vf}\) for each vertex v and each incidence to a face f. We check whether these values fulfill Conditions 1, 2, and \(3'\). In order to also check Condition 4, we first assign for each port of a vertex v, all but the middle edges to v (where a middle edge of a port is the last edge in clockwise order bending to the left or the first edge bending to the right). We check whether we thereby assign an edge more than once. Assigning the middle edges can be reduced to a matching problem in a bipartite graph of maximum degree 2 where the nodes on one side are the ports with two middle edges and the nodes on the other side are the unassigned edges.   \(\square \)

4 Upward- and Upward-Rightward Planar L-Drawings

In this section, we characterize (see Theorem 3) and construct (see Theorem 6) upward-planar and upward-rightward planar L-drawings.

4.1 A Characterization via Bitonic st-Orderings

Characterizing the plane directed graphs that admit an L-drawing is an elusive goal. However, we can characterize two natural subclasses of planar L-drawings via bitonic st-orderings.

Theorem 3

A planar st-graph admits an upward- (upward-rightward-) planar L-drawing if and only if it admits a bitonic (monotonically decreasing) pair.

Sketch of proof

\(\Rightarrow \)”: Let \(G=(V,E)\) be an st-graph with n vertices. The y-coordinates of an upward- (upward-rightward-) planar L-drawing of G yield a bitonic (monotonically decreasing) st-ordering.

\(\Leftarrow \)”: Given a bitonic (monotonically decreasing) st-ordering \(\pi \) of \(G=(V,E)\), we construct an upward- (upward-rightward-) planar L-drawing of G using an idea of Gronemann [16]. For each vertex v, we use \(\pi (v)\) as its y-coordinate.

For the x-coordinates we use a linear extension of a partial order \(\prec \). Let \(v_1,\dots ,v_n\) be the vertices of G in the ordering given by \(\pi \). Let \(G_i\) be the subgraph of G induced by \(V_i=\{v_1,\dots ,v_i\}\). To construct \(\prec \), we augment \(G_i\) to \(\overline{G}_i\) in such a way that the outer face \(f_{\overline{G}_i}\) of \(\overline{G}_i\) is a simple cycle and all vertices on \(f_{\overline{G}_i}\) are comparable: We start with a triangle on \(v_1\) and two new vertices \(v_{-1}\) and \(v_{-2}\), with y-coordinates \(-1\) and \(-2\), respectively, and set \(v_{-2} \prec v_1 \prec v_{-1}\). For \(i=2,\dots ,n\), let \(u_1,\dots ,u_k\) be the predecessors of \(v_i\) in ascending order with respect to \(\prec \). If \(\pi \) is monotonically decreasing or if \(k=1\), we add an edge e with head \(v_i\). The tail of e is the right neighbor r of \(u_k\) or the left neighbor \(\ell \) of \(u_1\) on \(f_{\overline{G}_i}\), respectively, if the maximum successor \(s_{\max }\) of \(u_1\) is to the left (or equal to) or the right of \(v_i\), respectively; see Fig. 4a. Now let \(u_1,\dots ,u_k\) be the predecessors of \(v_i\) in the possibly augmented graph; see Fig. 4b. We add the condition \(u_{k-1} \prec v_i \prec u_k\).   \(\square \)

Fig. 4.
figure 4

How to turn a bitonic st-ordering into a planar L-drawing.

Corollary 1

Any undirected planar graph can be oriented such that it admits an upward-planar L-drawing.

Proof

Triangulate the graph G and construct a bitonic st-ordering for undirected graphs [14]. Orient the edges from smaller to larger st-numbers.   \(\square \)

4.2 Bitonic st-Orderings in the Variable Embedding Setting

By Theorem 3, testing for the existence of an upward- (upward-rightward-) planar L-drawing of a planar st-graph G reduces to testing for the existence of a bitonic (monotonically decreasing) pair \(\langle \mathcal{E}, \pi \rangle \) for G. In this section, we give a linear-time algorithm to test an st-graph for the existence of a bitonic pair \(\langle \mathcal{E}, \pi \rangle \).

The following lemma is proved in [6].

Lemma 3

Let \(G=(V,E)\) be a planar st-graph with source s, sink t, and \((s,t) \notin E\). Then there exists a supergraph \(G'=(V',E')\) of G, where \(V'=V \cup \{s'\}\) and \(E' = E \cup \{(s',s), (s',t)\}\), such that (i) \(G'\) is an st-graph with source \(s'\) and sink t, and (ii) \(G'\) admits a bitonic (resp., monotonically increasing) st-ordering if and only if G does.

By Lemma 3, in the following we assume that an st-graph G always contains edge (st). Hence, either G coincides with edge (st), which trivially admits a bitonic st-ordering, or it is biconnected.

A path p from u to v in a directed graph is monotonic increasing (monotonic decreasing) if it is exclusively composed of forward (backward) edges. A path p is monotonic if it is either monotonic increasing or monotonic decreasing. A path p with endpoints u and v is bitonic if it consists of a monotonic increasing path from u to w and of a monotonic decreasing path from w to v; if \(u \ne w\) and \(v \ne w\), then the path p is strictly bitonic and w is the apex of p. An st-graph G is v-monotonic, v-bitonic, or strictly v-bitonic if the subgraph of G induced by the successors of v is, after the removal of possible transitive edges, a monotonic, bitonic, or strictly-bitonic path p, respectively. The apex of p, if any, is also called the apex of v in G. If p is monotonic and it is directed from u to w, then vertices u and w are the first successor of v in G and the last successor of v in G, respectively. If p is strictly bitonic, then its endpoints are the first successors of v in G. If p consists of a single vertex, then such a vertex is both the first and the last successor of v in G. Let G be an st-graph and let \(G^*\) be an st-graph obtained by augmenting G with directed edges. We say that the pair \(\langle G, G^* \rangle \) is v-monotonic, v-bitonic, or strictly v-bitonic if the subgraph of \(G^*\) induced by the successors of v in G is, after the removal of possible transitive edges, a monotonic, bitonic, or strictly-bitonic path, respectively.

Although Gronemann [16] didn’t state this explicitly, the following theorem immediately follows from the proof of his Lemma 4.

Theorem 4

([16]). A plane st-graph \(G=(V,E)\) admits a bitonic st-ordering if and only if it can be augmented with directed edges to a planar st-graph \(G^*\) such that, for each vertex \(v \in V\), the pair \(\langle G, G^* \rangle \) is v-bitonic. Further, any st-ordering of \(G^*\) is a bitonic st-ordering of G.

In the remainder of the section, we show how to test in linear-time whether it is possible to augment a biconnected st-graph G to an st-graph \(G^*\) in such a way that the pair \(\langle G, G^* \rangle \) is v-bitonic, for any vertex v of G. By virtue of Theorem 4, this allows us to test the existence of a bitonic pair \(\langle \mathcal{E},\pi \rangle \) for G. We perform a bottom-up visit of the SPQR-tree T of G rooted at the reference edge (st) and show how to compute an augmentation for the pertinent graph of each node \(\mu \in T\) together with an embedding of it, if any exists.

Note that each vertex in an st-graph is on a directed path from s to t. Further, by the choice of the reference edge, neither s nor t are internal vertices of the pertinent graph of any node of T. This leads to the next observation.

Observation 1

For each node \(\mu \in T\) with poles u and v, the pertinent graph \({{\mathrm{pert}}}(\mu )\) of \(\mu \) is an st-graph whose source and sink are u and v, or vice versa.

Let e be a virtual edge of \(skel(\mu )\) corresponding to a node \(\nu \) whose pertinent graph is an st-graph with source \(s_\nu \) and sink \(t_\nu \). By Observation 1, we say that e exits \(s_\nu \) and enters \(t_\nu \).

The outline of the algorithm is as follows. Consider a node \(\mu \in T\) and suppose that, for each child \(\mu _i\) of \(\mu \), we have already computed a pair \(\langle {{\mathrm{pert}}}^*(\mu _i), \mathcal{E}_i^* \rangle \) such that \({{\mathrm{pert}}}^*(\mu _i)\) is an augmentation of \({{\mathrm{pert}}}(\mu _i)\), \(\mathcal{E}_i^*\) is an embedding of \({{\mathrm{pert}}}^*(\mu _i)\), and \(\langle {{\mathrm{pert}}}(\mu _i),{{\mathrm{pert}}}^*(\mu _i)\rangle \) is v-bitonic, for each vertex v of \({{\mathrm{pert}}}(\mu _i)\). We show how to compute a pair \(\langle {{\mathrm{pert}}}^*(\mu ), \mathcal{E}^* \rangle>\) for node \(\mu \), such that (i) the pair \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu )\rangle \) is v-bitonic for each vertex v in \({{\mathrm{pert}}}(\mu )\), and (ii) the restriction of \(\mathcal{E}^*\) to \({{\mathrm{pert}}}^*(\mu _i)\) is \(\mathcal{E}_i^*\), up to a flip. In the following, for the sake of clarity, we first describe an overall quadratic-time algorithm. We will refine this algorithm to run in linear time at the end of the section.

For a node \(\mu \in T\), we say that the pair \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) is of Type B if it is strictly \(s_\mu \)-bitonic and it is of Type M if it is \(s_\mu \)-monotonic. For simplicity, we also say that node \(\mu \) is of Type B or of Type M when, during the traversal of T, we have constructed an augmentation \({{\mathrm{pert}}}^*(\mu )\) for \(\mu \) such that \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) is of Type B or of Type M, respectively. Figure 5 shows an example where an augmentation \(G^*\) of G contains an augmentation \({{\mathrm{pert}}}^*(\mu )\) for \(\mu \) which is replaced with an augmentation \({{\mathrm{pert}}}^+(\mu )\) such that \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu )\rangle \) is of Type B, \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^+(\mu )\rangle \) is of Type M, and \(G^*\) admits a bitonic st-ordering if and only if it still does after this replacement. The following lemma formally shows that this type of replacement is always possible.

Lemma 4

Let G be a biconnected st-graph and let \(G^*\) be an augmentation of G such that \(\langle G,G^* \rangle \) is v-bitonic, for each vertex v of G. Consider a node \(\mu \) of the SPQR-tree of G and let \({{\mathrm{pert}}}^*(\mu )\) be the subgraph of \(G^*\) induced by the vertices of \({{\mathrm{pert}}}(\mu )\). Suppose that \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) is of Type B and that \({{\mathrm{pert}}}(\mu )\) also admits an augmentation \({{\mathrm{pert}}}^+(\mu )\) such that \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^+(\mu ) \rangle \) is of Type M and it is v-bitonic, for each vertex v of \({{\mathrm{pert}}}(\mu )\). There exists an augmentation \(G^+\) of G such that \(\langle G,G^+ \rangle \) is v-bitonic, for each vertex v of G, and such that the subgraph of \(G^+\) induced by the vertices of \({{\mathrm{pert}}}(\mu )\) is \({{\mathrm{pert}}}^+(\mu )\).

Fig. 5.
figure 5

Illustration for Lemma 4.

Consider a node \(\mu \) of the SPQR-tree T of G. We now show how to test the existence of a pair \(\langle {{\mathrm{pert}}}^*(\mu ), \mathcal{E}^* \rangle \) such that (i) \(\mu \) is of Type M or, secondarily, of Type B, or report that no such a pair exists, and (ii) \(\mathcal{E}^*\) is a planar embedding of \({{\mathrm{pert}}}^*(\mu )\). In fact, by Lemma 4, an embedding of \(\mu \) of Type M would always be preferable to an embedding of Type B.

In any planar embedding \(\mathcal{E}\) of \({{\mathrm{pert}}}(\mu )\) in which the poles are on the outer face \(f_{out}\) of \(\mathcal{E}\), we call left path (right path) of \(\mathcal{E}\) the path that consists of the edges encountered in a clockwise traversal (in a counter-clockwise traversal) of the outer face of \(\mathcal{E}\) from \(s_\mu \) to \(t_\mu \).

The following observation will prove useful to construct embedding \(\mathcal{E}^*\).

Observation 2

Let \(\langle {{\mathrm{pert}}}^*(\mu ), \mathcal{E}^* \rangle \) be a pair such that \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) is \(s_\mu \)-bitonic and \(\mathcal{E}^*\) is a planar embedding of \({{\mathrm{pert}}}^*(\mu )\) in which \(s_\mu \) and \(t_\mu \) lie on the external face. We have that:

  1. (i)

    If \(\mu \) is of Type M, then the first and the last successors of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu )\) lie one on the left path and the other on the right path of \(\mathcal{E}^*\). In particular, if the first and the last successor of \(\mu \) are the same vertex, then such a vertex belongs to both the left path and the right path of \(\mathcal{E}^*\).

  2. (ii)

    If \(\mu \) is of Type B, then the two first successors of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu )\) lie one on the left path and the other on the right path of \(\mathcal{E}^*\).

We distinguish four cases based on whether node \(\mu \) is an S-, P-, Q-, or R-node.

Q-node. Here, \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}(\mu ) \rangle \) is trivially of Type M, i.e., \({{\mathrm{pert}}}^*(\mu ) = {{\mathrm{pert}}}(\mu )\).

S-node. Let \(e_1,\dots ,e_k\) be the virtual edges of \({{\mathrm{skel}}}(\mu )\) in the order in which they appear from the source \(s_\mu \) to the target \(t_\mu \) of \({{\mathrm{skel}}}(\mu )\), and let \(\mu _1,\dots ,\mu _k\) be the corresponding children of \(\mu \), respectively. We obtain \({{\mathrm{pert}}}^*(\mu )\) by replacing each virtual edge \(e_i\) in \({{\mathrm{skel}}}(\mu )\) with \({{\mathrm{pert}}}^*(\mu _i)\). Also, we obtain the embedding \(\mathcal{E}^*\) by arbitrarily selecting a flip for each embedding \(\mathcal{E}_i^*\) of \({{\mathrm{pert}}}^*(\mu _i)\). Clearly, node \(\mu \) is of Type M if and only if \(\mu _1\) is of Type M and it is of Type B, otherwise.

P-node. Let \(e_1,\dots ,e_k\) be the virtual edges of \({{\mathrm{skel}}}(\mu )\) and let \(\mu _1,\dots ,\mu _k\) be the corresponding children of \(\mu \), respectively.

First, observe that if there exists more than one child of \(\mu \) that is of Type B, then node \(\mu \) does not admit an augmentation \({{\mathrm{pert}}}^*(\mu )\) where \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) is \(s_\mu \)-bitonic. In fact, if there exist two such nodes \(\mu _i\) and \(\mu _j\), then both the subgraphs of \({{\mathrm{pert}}}^*(\mu _i)\) and \({{\mathrm{pert}}}^*(\mu _j)\) induced by the successors of \(s_\mu \) in \({{\mathrm{pert}}}(\mu _i)\) and in \({{\mathrm{pert}}}(\mu _j)\), respectively, contain an apex vertex. This implies that \(s_\mu \) would have more than one apex.

Second, observe that if there exists a child \(\mu _i\) of \(\mu \) of Type B and the edge \((s_\mu ,t_\mu )\) belongs to \({{\mathrm{pert}}}(\mu )\), then node \(\mu \) does not admit an augmentation \({{\mathrm{pert}}}^*(\mu )\) such that \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) is \(s_\mu \)-bitonic. In fact, \({{\mathrm{pert}}}^*(\mu _i)\) contains a apex of \(s_\mu \) different from \(t_\mu \); this is due to the fact that edge \((s_\mu ,t_\mu ) \notin {{\mathrm{pert}}}^*(\mu _i)\). Also, vertex \(t_\mu \) must be an apex of \(s_\mu \) in any augmentation \({{\mathrm{pert}}}^*(\mu )\) of \({{\mathrm{pert}}}(\mu )\) such that \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) is v-bitonic, for each vertex v of \({{\mathrm{pert}}}(\mu )\). Namely, any augmentation \({{\mathrm{pert}}}^*(\mu )\) of \({{\mathrm{pert}}}(\mu )\) yields an st-graph with source \(s_\mu \) and sink \(t_\mu \) and, as such, no directed path exits from \(t_\mu \) in \({{\mathrm{pert}}}^*(\mu )\). As for the observation in the previous paragraph, this implies that \(s_\mu \) would have more than one apex.

We construct \({{\mathrm{pert}}}^*(\mu )\) as follows. We embed \({{\mathrm{skel}}}(\mu )\) in such a way that the edge \((s_\mu ,t_\mu )\), if any, or the virtual edge corresponding to the unique child of \(\mu \) that is of Type B, if any, is the right-most virtual edge in the embedding. Let \(e_1,\dots ,e_k\) be the virtual edges of \({{\mathrm{skel}}}(\mu )\) in the order in which they appear clockwise around \(s_\mu \) in \({{\mathrm{skel}}}(\mu )\). Then, for each child \(\mu _i\) of \(\mu \), we choose a flip of embedding \(\mathcal{E}_i^*\) such that a first successor of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu _i)\) lies along the left path of \(\mathcal{E}_i^*\). Now, for \(i=1,\dots ,k-2\), we add an edge connecting the last successor of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu _i)\) and the first successor of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu _{i+1})\). Finally, we possibly add an edge connecting the last successor \(v_l\) of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu _{k-1})\) and a suitable vertex in \({{\mathrm{pert}}}^*(\mu _{k})\). Namely, if a node \(\mu _k\) is of Type B, then we add an edge between \(v_l\) and the first successor of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu _k)\) that lies along the left path of \(\mathcal{E}_k^*\). If \(\mu _k\) is of Type M and it is not a Q-node, then we add an edge between \(v_l\) and the first successor of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu _k)\). Otherwise \({{\mathrm{pert}}}^*(\mu _k) = (s_\mu ,t_\mu )\) and we add the edge \((v_l,t_\mu )\) if no such an edge belongs to \({{\mathrm{pert}}}^*(\mu _{k-1})\).

Observe that, the added edges do not introduce any directed cycle as there exists no directed path from a vertex in \({{\mathrm{pert}}}^*(\mu _{i+1})\) to a vertex in \({{\mathrm{pert}}}^*(\mu _i)\). Further, by Observation 2 the added edges do not disrupt planarity. Therefore, the obtained augmentation \({{\mathrm{pert}}}^*(\mu )\) of \({{\mathrm{pert}}}(\mu )\) is, in fact, a planar st-graph.

Finally, we have that node \(\mu \) is of Type M if and only if \(\mu _k\) is of Type M.

R-node. The case of an R-node \(\mu \) is detailed in [6]. For each node v of \({{\mathrm{skel}}}(\mu )\), we have to consider the virtual edges \(e_1,\dots ,e_k\) of \({{\mathrm{skel}}}(\mu )\) exiting v and the corresponding children \(\mu _1,\dots ,\mu _k\) of \(\mu \), respectively. Similarly to the P-node case, we pursue an augmentation of \({{\mathrm{pert}}}(\mu )\) by inserting edges that connect \({{\mathrm{pert}}}(\mu _i)\) with \({{\mathrm{pert}}}(\mu _{i+1})\), with \(i=1,\dots ,k-1\). Differently from the P-node case, however, more than one \({{\mathrm{pert}}}(\mu _i)\) may contain an edge between the poles of \(\mu _i\). Further, also the faces of \({{\mathrm{skel}}}(\mu )\) may play a role, introducing additional constraints on the existence and the choice of the augmentation.

We have the following theorem.

Theorem 5

It is possible to decide in linear time whether a planar st-graph G admits a bitonic pair \(\langle \mathcal{E}, \pi \rangle \).

Proof

Let \(\rho \) be the root of the SPQR-tree of G. The algorithm described above computes a pair \(\langle {{\mathrm{pert}}}^*(\rho ), \mathcal{E}^* \rangle \) for G, if any exists, such that (i) the st-graph \({{\mathrm{pert}}}^*(\rho )\) is an augmentation of G, (ii) for any vertex v of G, \(\langle {{\mathrm{pert}}}(\rho ),{{\mathrm{pert}}}^*(\rho ) \rangle \) is v-bitonic, and (iii) \(\mathcal{E}^*\) is a planar embedding of \({{\mathrm{pert}}}^*(\rho )\). Let \(\mathcal E\) be the restriction of \(\mathcal{E}^*\) to G. By Theorem 4, any st-ordering \(\pi \) of \({{\mathrm{pert}}}^*(\rho )\) is a bitonic st-ordering of G with respect to \(\mathcal E\). Hence, \(\langle \mathcal{E}, \pi \rangle \) is a bitonic pair of G.

We first show that the described algorithm has a quadratic running time. Then, we show how to refine it in order to run in linear time. For each node \(\mu \) of T, the algorithm stores a pair \(\langle {{\mathrm{pert}}}^*(\mu ), \mathcal{E} \rangle \). Processing a node takes \(O(|{{\mathrm{pert}}}^*(\mu )|)\) time. Since \(|{{\mathrm{pert}}}^*(\mu )| \in O(|{{\mathrm{pert}}}(\mu )|)\), the overall running time is \(O(|G|^2)\).

To achieve a linear running time, observe that we do not need to compute the embeddings of the augmented pertinent graphs \({{\mathrm{pert}}}^*(\mu )\), for each node \(\mu \) of T, during the bottom-up traversal of T. In fact, any embedding \(\mathcal{E}^*\) of \({{\mathrm{pert}}}^*(\rho )\) yields an embedding \(\mathcal{E}\) of G such that \(\pi \) is bitonic with respect to \(\mathcal E\). To determine the endpoints of the augmenting edges, we only need to associate a constant amount of information with the nodes of T. Namely, for each node \(\mu \) in T, we maintain (i) whether \(\mu \) is of Type B or of Type M, (ii) if \(\mu \) is of Type M, the first successor and the last successor of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu )\), and (iii) if \(\mu \) is of Type B, the two first successors of \(s_\mu \) in \({{\mathrm{pert}}}^*(\mu )\). Therefore, processing a node takes \(O(|{{\mathrm{skel}}}(\mu )|)\) time. Since the sum of the sizes of the skeletons of the nodes in T is linear in the size of G [7], the overall running time is linear.    \(\square \)

Corollary 2

It is possible to decide in linear time whether a planar st-graph G admits a monotonically decreasing pair \(\langle \mathcal{E}, \pi \rangle \).

Proof

The statement immediately follows from the fact that, in the algorithm described in this section, when computing a pair \(\langle {{\mathrm{pert}}}^*(\mu ), \mathcal{E}^* \rangle \) for each node \(\mu \) in T, a pair \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) of Type M is built whenever possible. Therefore, rejecting instances for which a pair \(\langle {{\mathrm{pert}}}(\mu ),{{\mathrm{pert}}}^*(\mu ) \rangle \) of Type B is needed yields the desired algorithm.    \(\square \)

In conclusion, we have the following main result.

Theorem 6

It can be tested in linear time whether a planar st-graph admits an upward- (upward-rightward-) planar L-drawing, and if so, such a drawing can be constructed in linear time.

Proof

We first test in linear time whether a planar st-graph admits a bitonic pair (Theorem 5) or a monotonically decreasing pair (Corollary 2). Then, Theorem 3 shows how to construct in linear time an upward- (upward-rightward-) planar L-drawing from a bitonic (monotonically decreasing) pair.    \(\square \)

5 Open Problems

Several interesting questions are left open: Can we efficiently test whether a directed plane graph admits a planar L-drawing? Can we efficiently recognize the directed graphs that are edge maximal subject to having a planar L-drawing (they have at most \(4n-6\) edges where n is the number of vertices—see [6]? Does every upward-planar graph have a (not necessarily upward-) planar L-drawing? Can we extend the algorithm for computing a bitonic pair in the variable embedding setting to single-source multi-sink di-graphs? Does every bimodal graph have a planar L-drawing?