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

Drawing directed graphs is a fundamental problem in graph drawing and has therefore received a considerable amount of attention in the past. Especially the so called upward planar drawings, a planar drawing in which the curve representing an edge has to be strictly y-monotone from its source to target. The directed graphs that admit such a drawing are called the upward planar graphs. Deciding if a directed graph is upward planar turned out to be NP-complete in the general case [11], but there exist special cases for which the problem is polynomial-time solvable [1, 2, 8, 16, 19, 20]. An important result in our context is from Di Battista and Tamassia [6]. They show that every upward planar graph is the spanning subgraph of a planar st-graph, that is, a planar directed acyclic graph with a single source and a single sink. They also show that every such graph has an upward planar straight-line drawing [6], but it may require exponential area which for some graphs cannot be avoided [5, 7].

If one allows bends on the edges, then every upward planar graph can be drawn within quadratic area. Di Battista and Tamassia [6] describe an approach that is based on the visibility representation of a planar st-graph. Every edge has at most two bends, therefore, the resulting drawing has at most \(6n-12\) bends with n being the number of vertices. With a more careful choice of the vertex positions and by employing a special visibility representation, the authors manage to improve this bound to \((10n - 31)/3\). Moreover, the drawing requires only quadratic area and can be obtained in linear time. Another approach by Di Battista et al. [7] uses an algorithm that creates a straight-line dominance drawing as an intermediate step. A dominance drawing, however, has much stronger requirements than an upward planar drawing. Therefore, the presented algorithm in [7] cannot handle planar st-graphs directly. Instead it requires a reduced planar st-graph, that is, a planar st-graph without transitive edges. In order to obtain such a graph, Di Battista et al. [7] split every transitive edge by replacing it with a path of length two. The result is a reduced planar st-graph for which a straight-line dominance drawing is obtained that requires only quadratic area and can be computed in linear time. Then they reverse the procedure of splitting the edges by using the coordinates of the inserted dummy vertices as bend points. Since a planar st-graph has at most \(2n-5\) transitive edges, the resulting layout has not more than \(2n-5\) bends and at most one bend per edge. To our knowledge, this bound is the best achieved so far.

These techniques are very different to the ones used in the undirected case. One major reason is the availability of canonical orderings for undirected graphs, introduced by de Fraysseix et al. [9] to draw every (maximal) planar graph straight-line within quadratic area. From there on this concept has been further improved and generalized [15, 17, 18]. Biedl and Derka [3] discuss various variants and their relation. Another similar concept that extends to non-planar graphs is the Mondshein sequence [21]. However, all these orderings have in common that they do not extend to directed graphs, that is, for every edge (uv), it holds that u precedes v in the ordering. An exception are st-orderings. While they are easy to compute for planar st-graphs, they lack a certain property compared to canonical orderings. In [13] we introduced for undirected biconnected planar graphs the bitonic st-ordering, a special st-ordering which has properties similar to canonical orderings. However, the algorithm in [13] uses canonical orderings for the triconnected case as a subroutine. Since finding a canonical ordering is in general not a trivial task, respecting the orientation of edges makes it even harder. Nevertheless, such an ordering is desirable, since one would be able to use incremental drawing approaches for directed graphs that are usually limited to the undirected case.

In this paper we extend the bitonic st-ordering to directed graphs, namely planar st-graphs. We start by discussing the consequences of having such an ordering available. Based on the observation that the algorithm of de Fraysseix et al. [9] can easily be modified to obtain an upward planar straight-line drawing, we show that for good reasons not every planar st-graph admits such an ordering. After deriving a full characterization of the planar st-graphs that do admit a bitonic st-ordering, we provide a linear-time algorithm that recognizes these and computes a corresponding ordering. For a planar st-graph that does not admit a bitonic st-ordering, we show that splitting at most \(n-3\) edges is sufficient to transform it into one for which then an ordering can be found. Furthermore, a linear-time algorithm is described that determines the smallest set of edges to split. By combining these results, we are able to draw every planar st-graph with at most one bend per edge, \(n-3\) bends in total within quadratic area in linear time. This improves the upper bound on the total number of bends considerably. Some proofs have been omitted and can be found in the full version [12] or in [14].

2 Preliminaries

In this work we are solely concerned with a special type of directed graph, the so-called planar st-graph, that is, a planar acyclic directed graph \(G= (V,E)\) with a single source \(s \in V\), a single sink \(t \in V\) and no parallel edges. It should be noted that some definitions assume that \((s,t) \in E\), we explicitly do not require this edge to be present. However, we assume a fixed embedding scenario such that s and t are on the outer face. Under such constraints, planar st-graphs possess the property of being bimodal, that is, the incoming and outgoing edges appear as a consecutive sequence around a vertex in the embedding. Given an edge \((u,v) \in E\), we refer to v as a successor of u and call u a predecessor of v. Similar to [13], we define for every vertex \(u \in V\) a list of successors \(S(u) = \{ v_1, \ldots , v_m\}\), ordered by the outgoing edges \((u,v_1), \ldots , (u,v_m)\) of u as they appear in the embedding clockwise around u. For S(s) we choose \(v_1\) and \(v_m\) such that \(v_m, s, v_1\) appear clockwise on the outer face. A central problem will be the existence of paths between vertices. Therefore, we refer to a path from u to v and its existence with \(u \rightsquigarrow v \in G\). With a few exceptions, G is clear from the context, thus, we omit it. If there exists no path \(u \rightsquigarrow v\), we may abbreviate it by writing .

Let \(G = (V,E)\) be a planar st-graph and \(\pi : V \mapsto \{1, \ldots , |V| \}\) be the rank of the vertices in an ordering \(s = v_1, \ldots , v_n = t\). \(\pi \) is said to be an st-ordering, if for all edges \((u,v) \in E\), \(\pi (u) < \pi (v)\) holds. In case of a (planar) st-graph such an ordering can be obtained in linear time by using a simple topological sorting algorithm [4]. We are interested in a special type of st-ordering, the so called bitonic st-ordering introduced in [13]. We say an ordered sequence \(A = \{ a_1, \ldots , a_n \}\) is bitonic increasing, if there exists \(1 \le h \le n\) such that \(a_1 \le \cdots \le a_h \ge \cdots \ge a_n\) and bitonic decreasing, if \(a_1 \ge \cdots \ge a_h \le \cdots \le a_n\). Moreover, we say A is bitonic increasing (decreasing) with respect to a function f, if \(A' = \{ f(a_1), \ldots , f(a_n) \}\) is bitonic increasing (decreasing). In the following, we restrict ourselves to bitonic increasing sequences and abbreviate it by just referring to it as being bitonic. An st-ordering \(\pi \) for G is a bitonic st-ordering for G, if at every vertex \(u \in V\) the ordered sequence of successors \(S(u) = \{ v_1, \ldots , v_m \}\) as implied by the embedding is bitonic with respect to \(\pi \), that is, there exists \(1 \le h \le m\) with \(\pi (v_1)< \cdots < \pi (v_h)> \cdots > \pi (v_m)\). Notice that the successors of a vertex are distinct and so are their labels in an st-ordering.

3 Upward Planar Straight-Line Drawings and Bitonic st-orderings

We start by assuming that we are given a planar st-graph \(G = (V,E)\) together with a bitonic st-ordering \(\pi \). The idea is to use the straight-line algorithm from [13] which is based on the one in [15] to produce an upward planar straight-line layout. Due to space constraints, we omit details here and only sketch the two modifications that are necessary. For a full pseudocode listing, an example and a detailed description, see the full version [12] or [14]. When using a bitonic st-ordering to drive the planar straight-line algorithm of de Fraysseix et al. [9], the only critical case is the one in which a vertex \(v_k\) must be placed that has only one neighbor, say \(w_i\), in the subgraph drawn so far. In [13] we use the idea of Harel and Sardas [15] who guarantee with their ordering that the edges preceding or following \((w_i, v_k)\) in the embedding around \(w_i\) have already been drawn. Hence one may just pretend that \(v_k\) has a second neighbor either to the right or left of \(w_i\). The idea is illustrated in Fig. 1a where \(v_k\) uses \(w_{i+1}\), the successor of \(w_i\) on the contour, as second neighbor. The following lemma captures the required property and shows that a bitonic st-ordering complies with it.

Fig. 1.
figure 1

(a) A vertex \(v_k\) with only one predecessor \(w_i\) using the vertex \(w_{i+1}\) as second neighbor. Vertices in grey have not been drawn yet. The two dummy vertices \(v_L, v_R\) remain the left- and rightmost ones. (b) Example of an upward planar straight-line drawing on seven vertices.

Lemma 1

Let \(G = (V,E)\) be an embedded planar st-graph with a corresponding bitonic st-ordering \(\pi \). Moreover, let \(v_k\) be the k-th vertex in \(\pi \) and \(G_k=(V_k,E_k)\) the subgraph induced by \(v_1, \ldots , v_k\). For every \(1 < k \le |V|\) the following holds:

  1. 1.

    \(G_{k}\) and \(G-G_{k}\) are connected,

  2. 2.

    \(v_k\) is in the outer face of \(G_{k-1}\),

  3. 3.

    For every vertex \(v \in V_k\), the neighbors of v that are not in \(G_k\) appear consecutively in the embedding around v.

Sketch of Proof

The first two properties hold for all st-orderings. For the third, assume to the contrary, contradicting that S(v) is bitonic with respect to \(\pi \).    \(\square \)

Due to the third statement we can always choose a second neighbor either to the left or right, since otherwise the grey vertices in Fig. 1a would not be consecutive in the embedding around \(w_i\). The second modification solves a problem that arises in the initialization phase of the drawing algorithm. Recall that in [9] the first three vertices are drawn as a triangle. This of course works in the case of a canonical ordering, but requires extra care when using a bitonic st-ordering. In order to avoid subcases and keep things simple, we add two isolated dummy vertices \(v_L\) and \(v_R\) that take the roles of the first two vertices and pretend to form a triangle with \(v_1 = s\). This has another side effect: It avoids distinguishing between subcases when we have to find a second neighbor at the boundary of the contour, because \(v_L\) is always the first, and \(v_R\) always the last vertex on every contour during the incremental construction. See the example in Fig. 1b.

Theorem 1

Given an embedded planar st-graph \(G = (V,E)\) and a corresponding bitonic st-ordering \(\pi \) for G. An upward planar straight-line drawing for G of size \((2|V|-2) \times (|V|-1)\) can be obtained from \(\pi \) in linear time.

Proof

The upward property is obtained by the following observation: The original planar straight-line algorithm installs every vertex \(v_k\) with \(k > 2\) above its predecessors. Since we start with \(v_L, v_R, v_1\), the drawing is upward. It remains to bound the area. Notice that the input consists of the two additional vertices \(v_L,v_R\). The original algorithm, without any area improvements, produces a drawing with a size of \(2((|V|+2) - 4) \times (|V|+2) - 2\) = \(2|V| \times |V|\). However, \(v_L\) and \(v_R\) are dummy vertices and can be removed anyway. Moreover, every other vertex is located above them. Hence, their removal yields a smaller drawing of size \((2|V|-2) \times (|V|-1)\).    \(\square \)

Now the first question that comes to mind is, if we can always find a bitonic st-ordering. Although every planar st-graph admits an upward planar straight-line drawing [6], there exist some classes for which it is known that they require exponential area [5, 7]. Since Theorem 1 clearly states that the drawing requires only polynomial area, these graphs cannot admit a bitonic st-ordering.

Corollary 1

Not every planar st-graph admits a bitonic st-ordering.

While this had to be expected, we now have to solve an additional problem. Before we think about how to compute a bitonic st-ordering, we must first be able to recognize planar st-graphs that admit such an ordering.

4 Characterization, Recognition and Ordering

We proceed as follows: As a first step, we identify a necessary condition that a planar st-graph has to meet for admitting a bitonic st-ordering. Then we exploit this condition to compute a bitonic st-ordering which proves sufficiency. We start with an alternative characterization of bitonic sequences. Since we will use the labels of an st-ordering, we can assume that the elements are pairwise distinct.

Lemma 2

An ordered sequence \(A = \{ a_1, \ldots , a_n \}\) of pairwise distinct elements is bitonic increasing if and only if the following holds:

$$ \forall 1 \le i< j< n \; : \; a_{i} < a_{i+1} \vee a_{j} > a_{j+1}. $$

Sketch of Proof

For “\(\Rightarrow \)”, assume to the contrary which yields \(i \ge j\). For “\(\Leftarrow \)”, we choose, if exists, \(h = \min \{j \; | \; a_j > a_{j+1}\}\), otherwise we set \(h = n\).   \(\square \)

In general a planar st-graph may have many st-orderings, some of them being bitonic while others are not. To deal with this in a more formal manner, we introduce some additional notation. Given an embedded planar st-graph \(G = (V,E)\), we refer with \(\varPi (G)\) to all feasible st-orderings of G, that is,

$$ \varPi (G) = \{ \pi : V \mapsto \{1, \ldots , |V|\} \;| \;\pi \text { is an}\,\, st-\text {ordering for } G \}. $$

Furthermore, let \(\varPi _b(G)\) be the subset of \(\varPi (G)\) that contains all bitonic st-orderings. By definition, we can describe \(\varPi _b(G)\) by

$$\begin{aligned} \varPi _b(G) = \{ \pi \in \varPi (G) \mid \forall u \in V \; : \; S(u) \text { is bitonic with respect to } \pi \}. \end{aligned}$$

Applying the alternative characterization of bitonicity from Lemma 2 to the bitonic property of the successor lists S(u) yields the following expression for the existence of a bitonic st-ordering:

$$\begin{aligned} \begin{aligned} \exists \pi \in \varPi _b(G) \Leftrightarrow&\;\exists \pi \in \varPi (G) \quad \forall u \in V \text { with } S(u)=\{v_1, \ldots , v_m \}\\&\;\forall \,1\le i< j< m \;:\; \pi (v_{i}) < \pi (v_{i+1}) \vee \pi (v_{j}) > \pi (v_{j+1}). \end{aligned} \end{aligned}$$
(1)
Fig. 2.
figure 2

(a) A successor list \(S(u) = \{ \ldots , v_i, v_{i+1}, \ldots , v_j, v_{j+1}, \ldots \}\) with \(i < j\) and a forbidden configuration of paths \(v_{i+1} \rightsquigarrow v_{i}\) and \(v_j \rightsquigarrow v_{j+1}\). (b)–(d) The three cases at a face between two successors \(v_i\) and \(v_{i+1}\) of the face-source u: (b) \(v_{i+1}\) is the sink of the face indicating the existence of a path from \(v_{i}\) to \(v_{i+1}\). (c) A path from \(v_{i+1}\) to \(v_{i}\) results in a face having \(v_i\) as sink. (d) There exists no path between \(v_i\) and \(v_{i+1}\), if and only if neither \(v_i\) nor \(v_{i+1}\) is the face-sink.

Next we translate this expression from st-orderings to the existence of paths. Consider a path from some vertex u to some other vertex v in G, then for every \(\pi \in \varPi (G)\), by the definition of st-orderings, \(\pi (u) < \pi (v)\) holds. Now it is not hard to imagine that if there exists \(\pi \in \varPi _b(G)\), then there must exist configurations of paths that are forbidden. To clarify this, let us rewrite the last part of the condition in Eq. 1, that is, \(\pi (v_{i}) < \pi (v_{i+1}) \vee \pi (v_{j}) > \pi (v_{j+1})\), using a simple boolean transformation, which yields \(\lnot (\pi (v_{i}) > \pi (v_{i+1}) \wedge \pi (v_{j}) < \pi (v_{j+1}))\). So if there exists a path from \(v_{i+1}\) to \(v_i\) and one from \(v_j\) to \(v_{j+1}\) with \(i < j\), then this expression evaluates to false for every \(\pi \in \varPi (G)\). Therefore, we may refer to the pair of paths \(v_{i+1} \rightsquigarrow v_i\) and \(v_j \rightsquigarrow v_{j+1}\) with \(i < j\) as a forbidden configuration of paths. See Fig. 2a for an illustration.

We may state now that in case there exists a bitonic st-ordering, the aforementioned configuration of paths cannot exist:

Conversely, if we find an u with \(v_i\) and \(v_j\) in a graph for which these paths exist, then we can safely reject it as one that does not admit a bitonic st-ordering. The following well-known property of planar st-graphs will prove itself useful when it comes to testing for the existence of a path between two vertices.

Lemma 3

Let F be the subgraph of an embedded planar st-graph \(G = (V,E)\) induced by a face that is not the outer faceFootnote 1, and uv two vertices of F, that is, u and v are on the boundary of the face. Then there exists a path from u to v in G, if and only if there exists such a path in F.

There are several ways to prove this result, one proof can be found in the work of de Fraysseix et al. [10]. Notice that Lemma 3 is concerned with every pair of vertices incident to the face. But we are only interested in paths between two consecutive successors \(v_{i}\) and \(v_{i+1}\) of a vertex u. Notice that \(v_{i}, v_{i+1}\) and u share a common face which is not the outer face and in which u is the face-source. Figure 2b–d illustrates all three possible cases: \(v_i \rightsquigarrow v_{i+1}\) (b), \(v_{i+1} \rightsquigarrow v_{i}\) (c), and no path at all (d). Hence, we can decide the existence of a path based on the sink of the common face.

To prove that the absence of forbidden configurations is sufficient for the existence of a bitonic st-ordering, we require the following technical proposition.

Proposition 1

Given an embedded planar st-graph \(G = (V,E)\) and a vertex \(u \in V\) with successor list \(S(u) = \{v_1, \ldots , v_m \}\). If it holds that

then there exists \(1 \le h \le m\) such that

holds. In other words, there exists at least one \(v_h\) in S(u) whose preceding vertices in S(u) are only connected by paths in clockwise direction, whereas paths between following vertices are directed counterclockwise.

Sketch of Proof

If exists, set \({ h = \min \{ i \mid v_{i+1} \rightsquigarrow v_{i} \} }\), otherwise set \(h = m\).    \(\square \)

Fig. 3.
figure 3

(a) Paths orientations between consecutive successors of u. All of them directed towards \(v_h\) as described by Proposition 1. (b) The augmented graph \(G'\) in the proof of Lemma 4 obtained by adding edges between consecutive successors of u such that they are oriented towards \(v_h\).

The idea is now the following: If we have a graph that satisfies our necessary condition, then we can find for every \(u \in V\) with \(u \ne t\) a successor \(v_h\) with the property as described in Proposition 1. The intuition behind this property is that all paths that exist between successors of u, are directed in some way towards \(v_h\). See Fig. 3a for an illustration. The next lemma exploits this property to obtain a bitonic st-ordering, which proves that this condition is indeed sufficient for the existence of a bitonic st-ordering.

Lemma 4

Given a planar st-graph \(G=(V,E)\) with a fixed embedding. If at every vertex \(u \in V\) with successor list \(S(u)=\{v_1, \ldots , v_m \}\) the following holds:

then G admits a bitonic st-ordering \(\pi \in \varPi _b(G)\).

Proof

To show that there exists \(\pi \in \varPi _b(G)\), we augment G into a new graph \(G'\) by inserting additional edges that we refer to as \(E'\). These edges ensure that between every pair of consecutive successors in G, there exists a path in \(G' = (V, E \cup E')\). Afterwards, we show that every st-ordering \(\pi \in \varPi (G')\) for \(G'\) is a bitonic st-ordering for G.

For every vertex u with successor list \(S(u) = \{v_1, \ldots , v_m\}\), we may assume by Proposition 1 that there exists \(1 \le h \le m\) such that for every \(1 \le i < h\) there exists no path from \(v_{i+1}\) to \(v_{i}\), and for every \(h \le i < m\) no path from \(v_{i}\) to \(v_{i+1}\) in G. Our goal is to add specific edges to fill the gaps such that there exist two paths in \(G'\), \(v_1 \rightsquigarrow v_2 \rightsquigarrow \cdots \rightsquigarrow v_h \in G'\) and \(v_m \rightsquigarrow v_{m-1} \rightsquigarrow \cdots \rightsquigarrow v_h \in G'\). Figure 3b illustrates the idea. More specifically, for every \(1 \le i < m\), there are three cases to consider: (i) There already exists a path between \(v_i\) and \(v_{i+1}\) in G, that is, \(v_i \rightsquigarrow v_{i+1} \in G\) or \( v_{i+1} \rightsquigarrow v_{i} \in G\). Proposition 1 ensures that the path is directed towards \(v_h\), thus, we just skip the pair. (ii) If there exists no path between \(v_i\) and \(v_{i+1}\) in G and \(i < h\) holds, we add an edge from \(v_i\) to \(v_{i+1}\). (iii) When there also exists no path between \(v_i\) and \(v_{i+1}\), but now \(h \le i < m\) holds, we add the reverse edge \((v_{i+1}, v_i)\) to \(E'\).

Before we continue, we show that \(G' = (V, E \cup E')\) is st-planar. Consider a single edge in \(E'\) which has been added either by case (ii) or (iii) while traversing the successors S(u) of some vertex \(u \in V\). This edge will be added to a face in which u is the source, and since every face has only one source, only one edge will be added to the corresponding face, hence, planarity is preserved. Since case (ii) and (iii) only apply, when there exists no path between the two vertices, adding this edge will not generate a cycle. Induction on the number of added edges yields then st-planarity for \(G'\).

Consider now an st-ordering \(\pi \in \varPi (G')\). Since clearly \(E' \subseteq E \cup E'\) holds, \(\pi \) is also an st-ordering for G, that is, \(\varPi (G') \subseteq \varPi (G)\) holds. Recall that we constructed \(G'\) such that for every \(u \in V\) with \(S(u) = \{v_1, \ldots , v_m\}\), there exists \(v_1 \rightsquigarrow v_2 \rightsquigarrow \cdots \rightsquigarrow v_h \in G'\) and \(v_m \rightsquigarrow v_{m-1} \rightsquigarrow \cdots \rightsquigarrow v_h \in G'\). It follows that for every \(\pi \in \varPi (G')\)

$$ \forall \,1 \le i< h : \pi (v_{i})< \pi (v_{i+1}) \; \wedge \; \forall \,h \le i < m : \pi (v_{i}) > \pi (v_{i+1}) $$

holds, which implies that S(u) is bitonic with respect to \(\pi \). Since this holds for all \(u\in V\), it follows that \(\varPi (G') \subseteq \varPi _b(G)\). Moreover, \(G'\) has at least one st-ordering, that is, \(\varPi (G') \ne \emptyset \), thus, there exists \(\pi \in \varPi _b(G)\).    \(\square \)

Let us summarize the implications of the lemma. The only requirement is that the graph complies with our necessary condition, that is, the absence of forbidden configurations. If this is the case, then Lemma 4 provides us with a bitonic st-ordering, which in turn proves that this condition is sufficient.

figure a

With a full characterization now at our disposal and in combination with Lemma 3, we are able to describe a simple linear-time algorithm (Algorithm 1) which tests a given graph and in case it admits a bitonic st-ordering, computes one. We iterate over S(u) and as long as there is no path \(v_{i+1} \rightsquigarrow v_i\), we assume \(i < h\) and fill possible gaps. Once we encounter a path \(v_{i+1} \rightsquigarrow v_i\) for the first time, we implicitly set \(h = i\) via the flag and continue to add edges, but now the reverse ones. But in case we find a path \(v_{i} \rightsquigarrow v_{i+1}\), then it forms with \(v_{h+1} \rightsquigarrow v_h\) a forbidden configuration and the graph can be rejected. If we succeed in all successor list, an st-ordering for \(G'\) is computed, which is a bitonic one for G. Since \(G'\) is st-planar and has the same vertex set as G, we can claim that the overall runtime is linear. Let us state this as the main result of this section.

Theorem 2

Deciding whether an embedded planar st-graph G admits a bitonic st-ordering \(\pi \) or not is linear-time solvable. Moreover, if G admits such an ordering, \(\pi \) can be found in linear time.

Next we will consider the case in which no bitonic st-ordering exists. Although our initial motivation was to create upward planar straight-line drawings, we now allow bends and shift our efforts to upward planar poly-line drawings.

5 Upward Planar Poly-line Drawings with Few Bends

We start with a simple observation. Consider a forbidden configuration consisting of two paths \(v_{i+1} \rightsquigarrow v_{i}\) and \(v_{j} \rightsquigarrow v_{j+1}\) with \(i < j\) between successors of a vertex u as shown in Fig. 2a. Notice that \((u,v_i)\) and \((u,v_{j+1})\) are transitive edges. Since a reduced planar st-graph has no transitive edges, we can argue the following.

Corollary 2

Every reduced planar st-graph admits a bitonic st-ordering.

This leads to the idea to use the same transformation as Di Battista et al. [7] in their dominance-based approach. We can split every transitive edge to obtain a reduced planar st-graph and draw it upward planar straight-line. Replacing the dummy vertices with bends results in an upward planar poly-line drawing with at most \(2|V|-5\) bends, at most one bend per edge and quadratic area.

But we can do better using the following idea: If we have a single forbidden configuration, it suffices to split only one of the two transitive edges. More specifically, if we split in Fig. 2a the edge \((u,v_i)\) into two new edges \((u,v'_i)\) and \((v'_i, v_i)\) with \(v'_i\) being the dummy vertex, then \(v'_i\) replaces \(v_i\) in S(u). But now there exists no path from \(v_{i+1}\) to \(v'_i\), hence, the forbidden configuration has been destroyed at the cost of one split. Moreover, a pair of transitive edges does not necessarily induce a forbidden configuration. At this point the question arises how such a split affects other successor lists and if it may even create new forbidden configurations. The following trivial observation is helpful in this regard.

Lemma 5

Let \(G' = (V',E')\) be the graph obtained from splitting an edge (uv) of a graph \(G = (V,E)\) by inserting a dummy vertex \(v'\). More specifically, let \(V' = V \cup \{ v' \}\) and \(E' = (E - ( u,v )) \cup \{ (u,v'),(v',v) \}\). Then for all \(w, x \in V\) there exists a path \(w \rightsquigarrow x \in G\), if and only if there exists a path \(w \rightsquigarrow x \in G'\).

Since a forbidden configuration is solely defined by the existence of paths, we can argue now with Lemma 5 that a split does not create nor resolves forbidden configurations in other successor lists. However, one vertex that is not covered by the lemma is the dummy vertex itself, but it has only one successor which is insufficient for a forbidden configuration. This locality is of great value, because it enables us to focus on one successor list, instead of having to deal with a bigger picture. Next we prove an upper bound on the number of edges to split in order to resolve all forbidden configurations.

Lemma 6

Every embedded planar st-graph \(G = (V,E)\) can be transformed into a new one that admits a bitonic st-ordering by splitting at most \(|V|-3 \, edges\).

Proof

Consider a vertex u and its successor list \(S(u) = \{ v_1, \ldots , v_m \}\) that contains multiple forbidden configurations of paths. Instead of arguing by means of forbidden configurations, we use our second condition from Proposition 1, that is, the existence of a vertex \(v_h\) such that every path that exists between two consecutive successors \(v_i\) and \(v_{i+1}\), is directed from \(v_i\) towards \(v_{i+1}\) for \(i < h\), or from \(v_{i+1}\) towards \(v_{i}\) if \(i \le h\) holds. Of course h does not exist due to the forbidden configurations. But we can enforce its existence by splitting some edges.

Assume that we want \(v_h\) to be the first successor, that is, \(h = 1\). Then every path from \(v_i\) to \(v_{i+1}\) with \(1 \le i < m\) is in conflict with this choice. We can resolve this by splitting every edge \((u,v_{i+1})\) for which a path \(v_i \rightsquigarrow v_{i+1}\) exists. Clearly, the maximum number of edges to split is at most \(m-1\), that is the case in which for every \(1 \le i < m\), there exists a path from \(v_i\) to \(v_{i+1}\). However, there do not exist paths \(v_i \rightsquigarrow v_{i+1}\) and \(v_{i+1} \rightsquigarrow v_{i}\) at the same time, because G is acyclic. So, if the number of edges to split is more than \(\frac{m-1}{2}\), then there are less than \(\frac{m-1}{2}\) paths of the form \(v_{i+1} \rightsquigarrow v_{i}\). In that case, we may choose in a symmetric manner \(v_h\) to be the last successor (\(h = m\)), instead of being the first. Or in other words, we choose \(v_h\) to be the first or the last successor, depending on the direction of the majority of paths. And as a result, at most \(\frac{m-1}{2}\) edges have to be split. Notice that the overall length of all successor lists is exactly the number of edges in the graph. Hence, with \(m = |S(u)|\) we get \(\sum _{u \in V}{|S(u)|} = |E| \le 3|V| - 6\), and the claimed upper bound can be derived by

$$ \sum _{u \in V}{\frac{|S(u)|-1}{2}} \le \frac{3|V| - 6 - |V|}{2} = |V| - 3. $$

Moreover, the split procedure preserves st-planarity of G.    \(\square \)

Fig. 4.
figure 4

(a) Example of a graph with \(|V|-3\) forbidden configurations, each requiring one split to be resolved. (b) Example for finding the smallest set of edges to split. The numbers indicate how many splits are necessary when choosing the corresponding vertex to be \(v_h\). For \(v_5, v_6, v_8\) and \(v_9\) only two splits are necessary. Choosing \(h = 6\) results in \(E_{\text {split}} = \{ (u,v_1), (u,v_8)\}\). The squares indicate the result of the two splits, whereas the dotted edges represent \(E'\) in Algorithm 1.

One may wonder now if this bound can be improved. Unfortunately, the graph shown in Fig. 4a is an example that requires \(|V| - 3\) splits, hence, the bound is tight. It also shows that there exist graphs that can be drawn upward planar straight-line in polynomial area but do not admit a bitonic st-ordering. But we will push the idea of splitting edges a bit further from a practical point of view, and focus on the problem of finding a minimum set of edges to split.

In the following we describe an algorithm that solves this problem in linear time. To do so, we introduce some more notation. Let \(u \in V\) be a vertex with successor list \(S(u) = \{v_1, \ldots , v_m\}\). We define \(L(u,h) = |\{ i < h : v_{i+1} \rightsquigarrow v_{i} \}|\) and \(R(u,h) = |\{ i < h : v_{i} \rightsquigarrow v_{i+1} \}|.\) If we choose now a particular \(1 \le h \le m\) at u, then we have to split every edge \((u,v_{i+1})\) with \(i < h\) for which there exists a path \(v_{i+1} \rightsquigarrow v_{i}\), and every edge \((u,v_{i})\) with \(h \le i\) for which G contains a path \(v_{i} \rightsquigarrow v_{i+1}\), that is, we have to split \(L(u,h) + R(u,m) - R(u,h)\) edges. See Fig. 4b for an example. When now considering all successor lists, the minimum number of edge splits is

$$ \sum _{u \in V} \left( R(u,m) + \min _{1 \le h \le m }\left\{ L(u,h) - R(u,h)\right\} \right) . $$

Notice that the locality of a split allows us to minimize the number of edge splits for every successor list independently. From an algorithmic point of view, we are interested in the value of h and not in the number of splits, hence, we may drop R(um) and consider the problem of finding h for which \(L(u,h) - R(u,h)\) is minimum. Since this is now only a matter of counting paths for which we can again exploit Lemma 3, a linear-time algorithm becomes straightforward (see Algorithm 2). And as a result, we may state the following lemma without proof.

figure b

Lemma 7

Every embedded planar st-graph \(G = (V,E)\) can be transformed into a planar st-graph that admits a bitonic st-ordering by splitting every edge at most once. Moreover, the minimum number of edges to split is at most \(|V| - 3\) and they can be found in linear time.

Now we may use this to create upward planar poly-line drawings with few bends.

Theorem 3

Every embedded planar st-graph \(G = (V,E)\) admits an upward planar poly-line drawing within quadratic area having at most one bend per edge, at most \(|V|-3\) bends in total, and such a drawing can be obtained in linear time.

Proof

We use Lemma 7 to obtain a new planar st-graph \(G'=(V',E')\) with \(|V'| \le 2|V| -3\) and a corresponding bitonic st-ordering \(\pi \) with Algorithm 1. With Theorem 1, an upward planar straight-line layout of size \((2|V'|-2) \times (|V'|-1)\) for \(G'\) is computed. Replacement of the dummy vertices by bends, yields an upward planar poly-line drawing for G of size at most \((4|V|-8) \times (2|V|-4)\).    \(\square \)

Recall that every upward planar graph is a spanning subgraph of a planar st-graph [6]. Therefore, the bound of \(|V|-3\) translates to all upward planar graphs.

Corollary 3

Every upward planar graph \(G=(V,E)\) admits an upward planar poly-line drawing within quadratic area having at most one bend per edge and at most \(|V|-3\) bends in total.

6 Conclusion

In this work we have introduced the bitonic st-ordering for planar st-graphs. Although this technique has its limitations, it provides the properties of canonical orderings for the directed case. We have shown that this concept is viable by using a classic undirected incremental drawing algorithm for creating upward planar drawings with few bends.