1 Introduction

One of the definitions of the word morph that can be found in English dictionaries is “to gradually change into a different image”. The Graph Drawing community defines the morph of graph drawings similarly. Namely, given two drawings \(\varGamma _0\) and \(\varGamma _1\) of a graph G, a morph between \(\varGamma _0\) and \(\varGamma _1\) is a continuously changing family of drawings of G indexed by time \(t \in [ 0,1 ]\), such that the drawing at time \(t=0\) is \(\varGamma _0\) and the drawing at time \(t=1\) is \(\varGamma _1\). Further, the way the Graph Drawing community adopted the word morph is consistent with its Ancient Greek root \(\mu \omega \rho \phi \acute{\eta }\), which means “shape” in a broad sense. Namely, if both \(\varGamma _0\) and \(\varGamma _1\) have a certain geometric property, it is desirable that all the drawings of the morph also have the same property. In particular, we talk about a planar, a straight-line, an orthogonal, or a convex morph if all the intermediate drawings of the morph are planar (edges do not cross), straight-line (edges are straight-line segments), orthogonal (edges are polygonal lines composed of horizontal and vertical segments), or convex (the drawings are planar and straight-line, and the faces are delimited by convex polygons), respectively.

The state of the art on planar morphs covers more than 100 years, starting from the 1914/1917 works of Tietze [25] and Smith [23]. The seminal papers of Cairns [13] and Thomassen [24] proved the existence of a planar straight-line morph between any two topologically-equivalent planar straight-line drawings of a graph. In the last 10 years, the attention of the research community focused on algorithms for constructing planar morphs with few morphing steps (see, e.g., [1,2,3,4,5,6,7, 11, 12, 21, 26]). Each morphing step, sometimes simply called step, is a linear morph, in which the vertices move along straight-line (possibly distinct) trajectories at uniform speed. A unidirectional morph is a linear morph in which the vertex trajectories are all parallel. It is known [2, 4] that a planar straight-line morph with a linear number of unidirectional morphing steps exists between any two topologically-equivalent planar straight-line drawings of the same graph, and that this bound is the best possible.

Upward planarity is usually regarded as the natural extension of planarity to directed graphs; see, e.g., [9, 10, 15, 16, 18]. A drawing of a directed graph is upward planar if it is planar and the edges are represented by curves monotonically increasing in the vertical direction. Despite the importance of upward planarity, up to now, no algorithm has been devised to morph upward planar drawings of directed graphs. This paper deals with the following question: Given two topologically-equivalent upward planar drawings \(\varGamma _0\) and \(\varGamma _1\) of an upward planar directed graph G, does an upward planar straight-line morph between \(\varGamma _0\) and \(\varGamma _1\) always exist? In this paper we give a positive answer to this question.

Problems related to upward planar graphs are usually more difficult than the corresponding problems for undirected graphs. For example, planarity can be tested in linear time [20] while testing upward planarity is NP-complete [18]; all planar graphs admit planar straight-line grid drawings with polynomial area [22] while there are upward planar graphs that require exponential area in any upward planar straight-line grid drawing [17]. Quite surprisingly, we show that, from the morphing point of view, the difference between planarity and upward planarity is less sharp; indeed, in some cases, upward planar straight-line drawings can be morphed even more efficiently than planar straight-line drawings.

More in detail, our results are as follows. Let \(\varGamma _0\) and \(\varGamma _1\) be topologically-equivalent upward planar drawings of an n-vertex upward plane graph G. We show algorithms to construct upward planar straight-line morphs between \(\varGamma _0\) and \(\varGamma _1\) with the following number of unidirectional morphing steps:

  1. i.

    O(1) steps if G is a reduced plane st-graph (see Sect. 4);

  2. ii.

    O(n) steps if G is a plane st-graph (see Sect. 4);

  3. iii.

    O(n) steps if G is a reduced upward plane graph (see Sect. 5);

  4. iv.

    \(O(n\cdot f(n))\) steps if G is a general upward plane graph, assuming that an O(f(n))-step algorithm exists to construct an upward planar morph between any two upward planar drawings of any n-vertex plane st-graph (see Sect. 5). This, together with Result ii., yields an \(O(n^2)\)-step upward planar morph for general upward plane graphs.

Further, we show (Sect. 3) that there exist two topologically-equivalent upward planar drawings of an n-vertex upward plane path such that any upward planar morph between them consists of \(\varOmega (n)\) morphing steps.

In order to prove Result i. we devise a technique that allows us to construct a morph in which each morphing step modifies either only the x-coordinates or only the y-coordinates of the vertices. Result ii. builds on the techniques in [2] and leverages on the arrangement of low-degree vertices in upward planar drawings in order to morph maximal plane st-graphs. We then exploit such morphs for general plane st-graphs. In order to prove Results iii. and iv. we use an inductive technique for reducing the geometric differences between \(\varGamma _0\) and \(\varGamma _1\).

Because of space limitations, some proofs are omitted or sketched. They can be found in the full version of the paper.

2 Preliminaries

We assume familiarity with graph drawing [15] and related concepts.

In this paper we only consider straight-line drawings. Thus, where it leads to no confusion, we will omit the term “straight-line”. Let \(\varGamma \) be a drawing of a graph G and let H be a subgraph of G. We denote by \(\varGamma [H]\) the restriction of \(\varGamma \) to the vertices and edges of H. Two planar drawings of a connected graph are topologically equivalent if they have the same circular order of the edges around each vertex and the same cycle bounding the outer face. A planar embedding is an equivalence class of planar drawings. A plane graph is a planar graph equipped with a planar embedding. In a planar straight-line drawing an internal face (the outer face) is strictly convex if its angles are all smaller (greater) than \(\pi \). A planar straight-line drawing is strictly convex if each face is strictly convex.

A y-assignment \(y_G: V(G) \rightarrow \mathbb {R}\) is an assignment of reals to the vertices of a graph G. A drawing \(\varGamma \) of G satisfies \(y_G\) if the y-coordinate in \(\varGamma \) of each vertex \(v \in V(G)\) is \(y_G(v)\). An x-assignment \(x_G\) for G is defined analogously.

In a directed graph G we denote by uv an edge directed from a vertex u to a vertex v; then v is a successor of u, and u is a predecessor of v. A directed path consists of the edges \(u_iu_{i+1}\), for \(i=1,\dots ,n-1\). The underlying graph of G is the undirected graph obtained from G by omitting the directions from its edges. A transitive edge in a directed graph G is an edge uv such that G contains a directed path from u to v different from the edge uv. A reduced graph is a directed graph that does not contain any transitive edges.

A drawing of a directed graph is upward planar if it is planar and each edge uv is drawn as a curve monotonically increasing in the y-direction from u to v. A directed graph is upward planar if it admits an upward planar drawing. Consider an upward planar drawing \(\varGamma \) of an upward planar graph G. Let uv, and w be three vertices consecutive and in this clockwise order along the boundary of a face f of G. We denote by \(\angle (u, v, w)\) the angle formed by the (undirected) edges (uv) and (vw) in the interior of f. Also, we say that v is a sink-switch (source-switch) of f if uv and wv (vu and vw) are edges of G. Furthermore, we say that v is a switch of G if it is either a sink-switch or a source-switch of some face of \(\varGamma \). Two switches u and v of a face f are clockwise (counter-clockwise) consecutive if traversing f clockwise (counter-clockwise) no switch is encountered in between u and v. The drawing \(\varGamma \) determines a large-angle assignment, that is, a labeling, for each face f and each three clockwise consecutive switches u, v, and w for f of the corresponding angle \(\angle (u, v, w)\) as large, if it is larger than \(\pi \) in \(\varGamma \), or small, it is smaller than \(\pi \) in \(\varGamma \) [9].

Two upward planar drawings of an upward planar graph G have the same upward planar embedding if they have the same planar embedding and the same large-angle assignment. We denote by \(\ell (G)\) the number of switches labeled large in G. A combinatorial characterization of upward planar embeddings in terms of large angles is given in [9]. An upward plane graph is an upward planar graph equipped with an upward planar embedding.

Let \(\varGamma _0\) and \(\varGamma _1\) be upward planar drawings of an upward plane graph G. An upward planar morph is a continuous transformation from \(\varGamma _0\) to \(\varGamma _1\) indexed by time \(t \in [0,1]\) in which the drawing at each time \(t \in [0,1]\) is upward planar.

A plane st-graph is an upward plane graph with a single source s and a single sink t, and with an upward planar embedding in which s and t are incident to the outer face. A plane st-graph always admits an upward planar straight-line drawing [16]. A cycle in an upward plane graph is an st-cycle if it consists of two directed paths. A face f of an upward plane graph is an st-face if it is delimited by an st-cycle; the directed paths delimiting an st-face f are called left and right boundary, where the edge of the left boundary incident to the source-switch \(s_f\) of f immediately precedes the edge of the right boundary incident to \(s_f\) in the clockwise order of the edges incident to \(s_f\). The following is well-known.

Lemma 1

An upward plane graph is a plane st-graph iff all its faces are st-faces.

An internal vertex v of a maximal plane st-graph G is simple if the neighbors of v induce a cycle in the underlying graph of G.

Lemma 2

(Alamdari et al. [2]). Any maximal plane st-graph contains a simple vertex of degree at most 5.

3 Slow Morphs and Fast Morphs

We start this section by proving the following lower bound.

Fig. 1.
figure 1

Illustration for Theorem 1. (a) P; (b) \(\varGamma _0\); and (c) \(\varGamma _1\). For the sake of readability \(\varGamma _0\) and \(\varGamma _1\) have curved edges. However, the x-coordinates of the vertices can be slightly perturbed in order to make \(\varGamma _0\) and \(\varGamma _1\) straight-line.

Theorem 1

There are two upward planar drawings of an n-vertex upward plane path such that any upward planar morph between them consists of \(\varOmega (n)\) steps.

Proof sketch

Assume, for the sake of simplicity, that n is even, and let \(n=2k\). Consider the n-vertex upward plane path P defined as follows (refer to Fig. 1a). The path P contains vertices \(u_i\) and \(v_i\), for \(i=1,\dots , k\), and directed edges \(u_iv_i\), for \(i=1,\dots , k\), and \(u_{i+1}v_i\), for \(i=1,\dots , k-1\). We fix the upward planar embedding of P as in Fig. 1b and c.

Let \(\varGamma _0\) and \(\varGamma _1\) be two upward planar straight-line drawings of P in which the bottom-to-top order of the vertices is \(u_1, \dots , u_k, v_k,\dots , v_1\) (see Fig. 1b) and \(u_k, \dots , u_1, v_1,\dots , v_k\) (see Fig. 1c), respectively. Let \(\langle \varGamma _0 = \varLambda _1,\varLambda _2,\dots ,\varLambda _{h+1}=\varGamma _1 \rangle \) be any upward planar morph from \(\varGamma _0\) to \(\varGamma _1\) that consists of h morphing steps. We have the following.

Claim 1.1

For each \(j=1,\dots ,h+1\), the vertices \(u_{j}, u_{j+1},\dots , u_{k-1}, u_k\) appear in this bottom-to-top order in \(\varLambda _{j}\).

By Claim 1.1 and since \(u_k,u_{k-1}\) appear in this bottom-to-top order in \(\varGamma _1=\varLambda _{h+1}\), we have that \(h+1>k-1\), hence \(h \in \varOmega (n)\).    \(\square \)

We now establish a tool that will allow us to design efficient algorithms for morphing upward planar drawings. Consider two planar straight-line drawings \(\varGamma '\) and \(\varGamma ''\) of a plane graph G with the same y-assignment. Since the drawings are straight-line and have the same y-assignment, a horizontal line \(\ell \) intersects a vertex or an edge of G in \(\varGamma '\) if and only if it intersects the same vertex or edge in \(\varGamma ''\). We say that \(\varGamma '\) and \(\varGamma ''\) are left-to-right equivalent if, for any horizontal line \(\ell \), for any vertex or edge \(\alpha \) of G, and for any vertex or edge \(\beta \) of G such that \(\ell \) intersects both \(\alpha \) and \(\beta \) (in \(\varGamma '\) and in \(\varGamma ''\)), we have that the intersection of \(\alpha \) with \(\ell \) is to the left of the intersection of \(\beta \) with \(\ell \) in \(\varGamma '\) if and only if the intersection of \(\alpha \) with \(\ell \) is to the left of the intersection of \(\beta \) with \(\ell \) in \(\varGamma ''\). The definition of bottom-to-top equivalent drawings is analogous. We have the following.

Lemma 3

Any two upward planar drawings \(\varGamma '\) and \(\varGamma ''\) of a plane st-graph G with the same y-assignment are left-to-right equivalent.

Proof

Since G is a plane st-graph, the drawings \(\varGamma '\) and \(\varGamma ''\) have the same faces. By Lemma1 such faces are st-faces. Also, every horizontal line \(\ell \) crosses an st-face f at most twice, and the left-to-right order of these crossings along \(\ell \) is the same in \(\varGamma '\) and \(\varGamma ''\) because the left and right boundaries of f are the same in \(\varGamma '\) and \(\varGamma ''\). The statement follows.    \(\square \)

Lemma 4 is due to [2]. We extend it in Lemma 5.

Lemma 4

([2], Corollary 7.2). Consider a unidirectional morph acting on points p, q, and r. If p is on one side of the oriented line through \(\overline{qr}\) at the beginning and at the end of the morph, then p is on the same side of the oriented line through \(\overline{qr}\) throughout the morph.

Lemma 5

Let \(\varGamma '\) and \(\varGamma ''\) be two left-to-right or bottom-to-top equivalent planar drawings of a plane graph. Then the linear morph \(\mathcal M\) from \(\varGamma '\) to \(\varGamma ''\) is unidirectional and planar.

Proof

Since \(\varGamma '\) and \(\varGamma ''\) have the same y-assignment (x-assignment), given that they are left-to-right (bottom-to-top) equivalent, it follows that all the vertices move along horizontal (vertical) trajectories. Thus, \(\mathcal M\) is unidirectional. Also, since \(\varGamma '\) and \(\varGamma ''\) are left-to-right (bottom-to-top) equivalent, each horizontal (vertical) line crosses the same sequence of vertices and edges in both \(\varGamma '\) and \(\varGamma ''\). Thus, by Lemma 4, \(\mathcal M\) is planar.    \(\square \)

Lemma 5 allows us to devise a simple morphing technique between any two upward planar drawings \(\varGamma _0\) and \(\varGamma _1\) of the same upward plane graph G, when a pair of upward planar drawings of G with special properties can be computed. We say that the pair \((\varGamma _0,\varGamma _1)\) is an hvh-pair if there exist upward planar drawings \(\varGamma '_0\) and \(\varGamma '_1\) of G such that: (i) \(\varGamma _0\) and \(\varGamma '_0\) are left-to-right equivalent, (ii) \(\varGamma '_0\) and \(\varGamma '_1\) are bottom-to-top equivalent, and (iii) \(\varGamma '_1\) and \(\varGamma _1\) are left-to-right equivalent. Our morphing tool is expressed by the following lemma.

Lemma 6

(Fast morph). Let \((\varGamma _0,\varGamma _1)\) be an hvh-pair of upward planar drawings of an upward plane graph G. There is a 3-step upward planar morph from \(\varGamma _0\) to \(\varGamma _1\).

Proof sketch

We define the morph \(\mathcal M\) as \(\langle \varGamma _0, \varGamma '_0, \varGamma '_1, \varGamma _1 \rangle \). The drawings \(\varGamma '_0\) and \(\varGamma '_1\) exist by hypothesis. Lemma 5 guarantees that \(\mathcal M\) is unidirectional and planar. We use Lemma 4 to prove that \(\mathcal M\) is upward.    \(\square \)

The next lemma will allow us to restrict our attention to biconnected graphs.

Lemma 7

Let \(\varGamma _0\) and \(\varGamma _1\) be two upward planar drawings of an n-vertex upward plane graph G whose underlying graph is connected. There exist upward planar drawings \(\varGamma '_0\) and \(\varGamma '_1\) of an O(n)-vertex upward plane graph \(G'\) that is a supergraph of G, whose underlying graph is biconnected, and such that \(\varGamma '_0[G]=\varGamma _0\) and \(\varGamma '_1[G]=\varGamma _1\). Further, if G is reduced or an st-graph, then so is \( G'\).

Proof sketch

We iteratively apply the following procedure. Consider a cutvertex v of G and two edges that belong to distinct blocks of G and that are consecutive in the circular order of the edges incident to v. Let u and w be the end-vertices of such edges different from v. We add to G a vertex \(v'\) and two edges connecting \(v'\) with u and w; these edges are oriented as the ones connecting v with u and w, respectively. By placing \(v'\) and its incident edges inside the face of G incident to v, u, and w, we obtain an upward plane supergraph of G with one block less than G. Upward planar drawings of this graph extending \(\varGamma _0\) and \(\varGamma _1\) can be easily obtained. The repetition of this procedure proves the lemma.    \(\square \)

4 Plane st-Graphs

In this section, we show algorithms for constructing upward planar morphs between upward planar drawings of plane st-graphs.

4.1 Reduced Plane st-Graphs

We first consider plane st-graphs without transitive edges. We have the following.

Lemma 8

Any two upward planar drawings \(\varGamma _0\) and \(\varGamma _1\) of a reduced plane st-graph G form an hvh-pair.

Proof sketch

By Lemma 7 we can assume that G is biconnected. We construct two upward planar drawings \(\varGamma '_0\) and \(\varGamma '_1\) that, together with \(\varGamma _0\) and \(\varGamma _1\), satisfy Conditions (i)–(iii) of the definition of hvh-pair. We construct \(\varGamma '_0\) and \(\varGamma '_1\) as follows. First, we draw the left boundary of the outer face of G so that each vertex has the same y-coordinate in \(\varGamma '_i\) as in \(\varGamma _i\), for \(i=0,1\). In both \(\varGamma '_0\) and \(\varGamma '_1\) the x-coordinates of all the vertices of this path are 0. Then, we add to \(\varGamma '_0\) and \(\varGamma '_1\) the right boundaries of the st-faces of G one by one, following a topological sorting of the oriented dual graph of G. In \(\varGamma '_0\) (in \(\varGamma '_1\)) we assign to the internal vertices of each right boundary the same y-coordinates they have in \(\varGamma _0\) (\(\varGamma _1\)); since G is reduced, the set of these vertices is non-empty. All the internal vertices of each right boundary get the same x-coordinate, which is used in both \(\varGamma '_0\) and \(\varGamma '_1\); this x-coordinate is sufficiently large so that no crossing is introduced.    \(\square \)

Combining Lemma 6 with Lemma 8 we obtain the following result.

Theorem 2

Let \(\varGamma _0\) and \(\varGamma _1\) be any two upward planar drawings of a reduced plane st-graph. There is a 3-step upward planar morph from \(\varGamma _0\) to \(\varGamma _1\).

4.2 General Plane st-Graphs

We now turn our attention to general plane st-graphs. We restate here, in terms of plane st-graphs, a result by Hong and Nagamochi [19] that was originally formulated in terms of hierarchical plane (undirected) graphs.

Theorem 3

([19], Theorem 8). Consider an internally 3-connected plane st-graph G and let \(y_G\) be a y-assignment of the vertices of G such that each vertex v is assigned a value \(y_G(v)\) that is greater than those assigned to its predecessors. There exists a strictly-convex upward planar drawing of G satisfying \(y_G\).

We use Theorem 3 to prove the following theorem, which allows us to restrict our attention to maximal plane st-graphs.

Theorem 4

Let \(\varGamma _0\) and \(\varGamma _1\) be two upward planar drawings of an n-vertex plane st-graph G. Suppose that an algorithm \(\mathcal A\) exists that constructs an f(r)-step upward planar morph between any two upward planar drawings of an r-vertex maximal plane st-graph. Then there exists an O(f(n))-step upward planar morph from \(\varGamma _0\) to \(\varGamma _1\).

Proof sketch

By Lemma 7 we can assume that G is biconnected. We augment G to a maximal plane st-graph \(G^*\) by inserting a vertex \(v_f\) into each face f of G and by inserting a directed edge from the source-switch \(s_f\) of f to \(v_f\) and directed edges from \(v_f\) to every other vertex incident to f. We define a y-assignment \(y^0_{G^*}\) for \(G^*\) by setting \(y^0_{G^*}(v)=y^0_{G}(v)\) for each vertex \(v\in V(G)\) and by setting, for each vertex \(v_f\in V(G^*)\setminus V(G)\), a value for \(y^0_{G^*}(v_f)\) that is larger than \(y^0_{G^*}(s_f)\) and smaller than \(y^0_{G^*}(v)\), for every other vertex v incident to f. We similarly define a y-assignment \(y^1_{G^*}\) using the y-coordinates of \(\varGamma _1\). We use Theorem 3 to construct upward planar drawings \(\varGamma ^*_0\) and \(\varGamma ^*_1\) of \(G^*\) satisfying \(y^0_{G^*}\) and \(y^1_{G^*}\), respectively. By Lemma 3 we have that \(\varGamma ^*_0[G]\) and \(\varGamma _0\) (\(\varGamma ^*_1[G]\) and \(\varGamma _1\)) are left-to-right equivalent. Therefore, by Lemma 5, the linear morph \(\mathcal M'_0\) from \(\varGamma _0\) to \(\varGamma ^*_0[G]\) (\(\mathcal M'_1\) from \(\varGamma ^*_1[G]\) to \(\varGamma _1\)) is unidirectional and planar. Such a morph is also upward since both \(\varGamma _0\) and \(\varGamma ^*_0[G]\) (\(\varGamma _1\) and \(\varGamma ^*_1[G]\)) are upward planar and left-to-right equivalent. Then, we apply algorithm \(\mathcal A\) to construct a morph from \(\varGamma ^*_0\) to \(\varGamma ^*_1\) and restrict such a morph to a morph \(\mathcal M''\) from \(\varGamma ^*_0[G]\) to \(\varGamma ^*_1[G]\). The morph from \(\varGamma _0\) to \(\varGamma _1\) is the concatenation of \(\mathcal M'_0\), \(\mathcal M''\), and \(\mathcal M'_1\).    \(\square \)

The kernel of a polygon P is the set of points p inside or on P such that, for any point q on P, the open segment \(\overline{pq}\) lies inside P.

Lemma 9

(Convexify). Let \(\varGamma \) be an upward planar drawing of an internally 3-connected plane st-graph G, let f be an st-face of G, and let P be the polygon representing f in \(\varGamma \). There exists an upward planar drawing \(\varGamma '\) of G such that the polygon representing the boundary of f is strictly-convex and \(\mathcal M = \langle \varGamma , \varGamma ' \rangle \) is a unidirectional upward planar morph. Further, if v is a vertex incident to f that is in the kernel of P in \(\varGamma \), then v is in the kernel of the polygon representing the boundary of f throughout \(\mathcal M\).

Proof

Denote by \(y_G\) the y-assignment for the vertices of G induced by \(\varGamma \). By Theorem 3, there exists a strictly-convex upward planar drawing \(\varGamma '\) of G satisfying \(y_G\). Thus, by Lemma 3 and since G is a plane st-graph, \(\varGamma \) and \(\varGamma '\) are left-to-right-equivalent drawings. By Lemma 5, the linear morph \(\mathcal M\) from \(\varGamma \) to \(\varGamma '\) is unidirectional and planar. Since \(\varGamma \) and \(\varGamma '\) are upward, \(\mathcal M\) is upward as well.

Consider now a vertex v incident to f that is in the kernel of P in \(\varGamma \). Since the polygon representing the boundary of f in \(\varGamma '\) is strictly-convex, v is also in the kernel of such a polygon. Augment G to a graph \(G_*\) by introducing (suitably oriented) edges connecting v to the vertices incident to f that are not already adjacent to v. Since v is in the kernel of the polygon representing the boundary of f both in \(\varGamma \) and in \(\varGamma '\), this results in two left-to-right equivalent upward planar drawings \(\varGamma _*\) and \(\varGamma _*'\) of \(G_*\). By the same arguments used for \(\mathcal M\), we have that the linear morph \(\mathcal M_* = \langle \varGamma _*, \varGamma _*'\rangle \) is planar. Hence, v is in the kernel of the polygon representing the boundary of f throughout \(\mathcal M\).    \(\square \)

Given two upward planar straight-line drawings \(\varGamma _0\) and \(\varGamma _1\) of a maximal plane st-graph G, our strategy for constructing an upward planar morph from \(\varGamma _0\) to \(\varGamma _1\) is as follows: (1) we find a simple vertex v of G of degree at most 5; (2) we remove v and its incident edges from G, \(\varGamma _0\), and \(\varGamma _1\), obtaining upward planar drawings \(\varGamma '_0\) and \(\varGamma '_1\) of an upward plane graph \(G'\); (3) we triangulate \(G'\), \(\varGamma '_0\), and \(\varGamma '_1\) by inserting edges incident to a former neighbor u of v, obtaining upward planar drawings \(\varGamma ''_0\) and \(\varGamma ''_1\) of a maximal plane st-graph \(G''\); (4) we apply induction in order to construct an upward planar morph \(\mathcal M''\) from \(\varGamma ''_0\) to \(\varGamma ''_1\); and (5) we remove the edges incident to u that are not in G and insert v and its incident edges in \(\mathcal M''\), thus obtaining an upward planar morph \(\mathcal M\) from \(\varGamma _0\) to \(\varGamma _1\). In order for this strategy to work, we need u to satisfy certain properties, which are expressed in the upcoming definition of distinguished neighbor; further, we need to perform one initial (and one final) unidirectional upward planar morph so to convexify the polygon representing what will be called a characteristic cycle.

Let v be a simple vertex with degree at most 5 in a maximal plane st-graph G. Let G(v) be the subgraph of G induced by v and its neighbors. A predecessor u of v in G is a distinguished predecessor if, for each predecessor w of v, there is a directed path in G(v) from w to v through u. A successor u of v in G is a distinguished successor if, for each successor w of v, there is a directed path in G(v) from v to w through u. A neighbor of v is a distinguished neighbor if it is a distinguished predecessor or successor of v. Examples of distinguished neighbors are in Fig. 2.

Fig. 2.
figure 2

Distinguished predecessors (enclosed by red squares), distinguished successors (enclosed by red circles), and characteristic cycles (filled yellow). (Color figure online)

Lemma 10

The vertex v has at most one distinguished predecessor, at most one distinguished successor, and at least one distinguished neighbor.

We define the characteristic cycle C(v) as follows. Let \(c_G(v)\) be the subgraph of G induced by the neighbors of v. Since v is simple, the underlying graph of \(c_G(v)\) is a cycle. If \(c_G(v)\) is an st-cycle, then \(C(v):=c_G(v)\); this is always the case if v has degree 3. Otherwise, \(c_G(v)\) has two sources \(s_1\) and \(s_2\) and two sinks \(t_1\) and \(t_2\). Suppose that G contains the edges \(s_1v\) and \(vs_2\), the cases in which it contains the edges \(s_2v\) and \(vs_1\), or \(t_1v\) and \(vt_2\), or \(t_2v\) and \(vt_1\) are analogous. Suppose also, w.l.o.g., that \(s_1, t_1, s_2\), and \(t_2\) appear in this clockwise order along \(c_G(v)\). If v has degree 4, then we define C(v) as the st-cycle composed of the edges \(s_1v\), \(vs_2\), \(s_2t_2\), and \(s_1t_2\). Otherwise, v has degree 5. Consider the directed path \(P_1 = (v_1, v, v_2)\), where \(v_1\) (\(v_2\)) is the distinguished predecessor (successor) of v or, if such a node does not exist, the source \(s_1\) (\(s_2\)). Then \(P_1\) splits \(c_G(v)\) into two paths \(P_2\) and \(P_3\) with length 2 and 3, respectively. Cycle C(v) is defined as the st-cycle composed of \(P_1\) and \(P_3\). We have the following structural lemma.

Lemma 11

The characteristic cycle C(v) is an st-cycle which contains all the distinguished neighbors of v. Further, all the vertices of \(c_G(v)\) not belonging to C(v) are adjacent to all the distinguished neighbors of v.

Characteristic cycles are used in order to prove the following.

Lemma 12

There is a unidirectional upward planar morph \(\langle \varGamma , \varGamma ' \rangle \), where in \(\varGamma '\) the distinguished neighbors of v are in the kernel of the polygon representing \(c_G(v)\).

Proof sketch

If C(v) is convex in \(\varGamma \), then by Lemma 11 the distinguished neighbors of v already are in the kernel of the polygon representing \(c_G(v)\). Otherwise, we remove the interior of C(v) and use Lemma 9 to make C(v) convex. Then, we suitably reinsert the interior of C(v) to obtain the desired morph.    \(\square \)

The following concludes our discussion on maximal plane st-graph.

Theorem 5

Let \(\varGamma _0\) and \(\varGamma _1\) be two upward planar drawings of an n-vertex maximal plane st-graph. There is an O(n)-step upward planar morph from \(\varGamma _0\) to \(\varGamma _1\).

Proof sketch

If \(n=3\), then the desired morph is constructed as in Lemma 6. If \(n > 3\), then by Lemma 2 a simple vertex v exists in G with degree at most 5. By Lemma 10, v has a distinguished neighbor u. By Lemma 12, unidirectional upward planar morphs \(\langle \varGamma _0, \varLambda _0 \rangle \) and \(\langle \varLambda _1, \varGamma _0 \rangle \) exist, where \(\varLambda _0\) and \(\varLambda _1\) are upward planar drawings of G in which u lies in the kernels of the polygons representing C(v). Remove v from G, \(\varLambda _0\), and \(\varLambda _1\), and insert (suitably oriented) edges between u and the former neighbors of v that are not already adjacent to u, thus obtaining upward planar drawings \(\varGamma ''_0\) and \(\varGamma ''_1\) of an \((n-1)\)-vertex maximal plane st-graph \(G''\). Recursively compute an upward planar morph \(\mathcal M''\) from \(\varGamma ''_0\) to \(\varGamma ''_1\). Finally, remove the edges incident to u that are not in G and insert v and its incident edges in \(\mathcal M''\), obtaining an upward planar morph \(\mathcal M\) from \(\varLambda _0\) to \(\varLambda _1\). This, together with \(\langle \varGamma _0, \varLambda _0 \rangle \) and \(\langle \varLambda _1, \varGamma _0 \rangle \), provides the desired morph from \(\varGamma _0\) to \(\varGamma _1\).    \(\square \)

We finally get the following.

Corollary 1

Let \(\varGamma _0\) and \(\varGamma _1\) be two upward planar drawings of an n-vertex plane st-graph. There exists an O(n)-step upward planar morph from \(\varGamma _0\) to \(\varGamma _1\).

Proof

The statement follows by Lemma 7, Theorem 4, and Theorem 5.    \(\square \)

5 Upward Plane Graphs

Let G be an upward plane graph, let f be a face of G, and let u, v, and w be three clockwise consecutive switches of f. Also, let \(v_1\) (\(v_2\)) be the neighbor of v clockwise preceding (succeeding) v along f, and let \(u_1\) (\(u_2\)) be the neighbor of u clockwise preceding (succeeding) u along f. We say that [uvw] is a pocket for f if \(\angle (v_1, v, v_2)= \texttt {small}\) and \(\angle (u_1, u, u_2) = \texttt {large}\). The following is well-known.

Lemma 13

([9]). Let G be an upward plane graph and let f be a face of G that is not an st-face. Then, there exists a pocket [uvw] for f.

Next, we give a lemma that shows how to “simplify” a face of an upward plane graph that is not an st-graph, by removing one of its pockets.

Lemma 14

Let G be an n-vertex (reduced) upward plane graph, let [uvw] be a pocket for a face f of G, and let \(\varGamma \) be an upward planar drawing of G. Suppose that an algorithm \(\mathcal A\) (\(\mathcal A_R\)) exists that constructs an f(r)-step (\(f_R(r)\)-step) upward planar morph between any two upward planar drawings of an r-vertex (reduced) plane st-graph. Then, there exists an O(f(n))-step (\(O(f_R(n))\)-step) upward planar morph from \(\varGamma \) to an upward planar drawing \(\varGamma ^*\) of G in which w and u have direct visibility and such that u lies below w, if a directed path exists in f from v to u, and it lies above w, if a directed path exists in f from u to v.

Proof sketch

Suppose that a directed path \(p_{vu}\) exists in f from v to u (see Fig. 3a); the case in which a directed path exists in f from u to v can be treated symmetrically. We first show that there exists an upward planar drawing \(\varGamma '\) of G such that (i) it is possible to add to \(\varGamma '\) an upward planar drawing of two directed paths \(p'\) and \(p''\) from u to w that form an st-face (see Fig. 3b), and (ii) there exists an O(f(n))-step (\(O(f_R(n))\)-step) upward planar morph \(\mathcal M'\) from \(\varGamma \) to \(\varGamma '\). We then show that there exists an upward planar drawing \(\varGamma ^*\) of G such that (iii)vertices w and u have direct visibility and u lies below w (see Fig. 3c), and (vi)there exists an O(f(n))-step (\(O(f_R(n))\)-step) upward planar morph \(\mathcal M^*\) from \(\varGamma '\) to \(\varGamma ^*\). Composing \(\mathcal M'\) and \(\mathcal M^*\) yields an upward planar morph from \(\varGamma \) to \(\varGamma ^*\).    \(\square \)

Fig. 3.
figure 3

Illustrations for the proof of Lemma 14.

Theorem 6

Let \(\varGamma _0\) and \(\varGamma _1\) be two upward planar drawings of an n-vertex (reduced) upward plane graph G. Suppose that an algorithm \(\mathcal A\) (\(\mathcal A_R\)) exists that constructs an f(r)-step (\(f_R(r)\)-step) upward planar morph between any two upward planar drawings of an r-vertex (reduced) plane st-graph. There exists an \(O(n\cdot f(n))\)-step (an \(O(n \cdot f_R(n))\)-step) upward planar morph from \(\varGamma _0\) to \(\varGamma _1\).

Proof sketch

By Lemma 7, we can assume that G is biconnected. In order to prove the statement, we show that there exists a \(((2\ell (G)+1) \cdot f(n))\)-step (a \(((2\ell (G)+1) \cdot f_R(n))\)-step) upward planar morph from \(\varGamma _0\) to \(\varGamma _1\), if G is a (reduced) upward plane graph. Since \(\ell (G) \in O(n)\), the statement follows.

The proof is by induction on \(\ell (G)\). In the base case \(\ell (G)=0\) and thus G is a (reduced) plane st-graph. Hence, by applying algorithm \(\mathcal A\) (\(\mathcal A_R\)) to \(\varGamma _0\) and \(\varGamma _1\), we obtain an f(n)-step (an \(f_R(n)\)-step) upward planar morph from \(\varGamma _0\) to \(\varGamma _1\).

In the inductive case \(\ell (G)>0\). Then there exists a face f of G that is not an st-face. Thus, by Lemma 13, there exists a pocket [uvw] for f. By Lemma 14, we can construct upward planar drawings \(\varGamma '_0\) and \(\varGamma '_1\) of G in which u and w have direct visibility and u lies below w (assuming that a directed path exists in f from v to u, the other case being symmetric), and such that there exists an f(n)-step (an \(f_R(n)\)-step) upward planar morph \(\mathcal M_{start}\) from \(\varGamma _0\) to \(\varGamma '_0\) and an f(n)-step (an \(f_R(n)\)-step) upward planar morph \(\mathcal M_{finish}\) from \(\varGamma '_1\) to \(\varGamma _1\).

Let \(G^*\) be the plane graph obtained from G by splitting f with a directed edge uw. Graph \(G^*\) is an upward plane graph whose upward planar embedding is constructed by assigning to each switch in \(G^*\) the same label small or large it has in G. Also, \(\ell (G^*) = \ell (G)-1\), since u is not a switch in \(G^*\). Further, \(G^*\) is reduced if G is reduced, since there exists no directed path from u to w in G (due to the fact that [uvw] is a pocket of f). Let \(\varGamma ^*_0\) and \(\varGamma ^*_1\) be the planar straight-line drawings of \(G^*\) obtained by drawing the directed edge uw as a straight-line segment connecting u and w in \(\varGamma '_0\) and in \(\varGamma '_1\), respectively. It is easy to see that \(\varGamma ^*_0\) and \(\varGamma ^*_1\) are upward planar drawings of \(G^*\). Therefore, by the inductive hypothesis and since \(V(G^*)=V(G)\), we can construct a \(((2\ell (G^*)+1)\cdot f(n))\)-step (a \(((2\ell (G^*)+1)\cdot f_R(n))\)-step) upward planar morph from \(\varGamma ^*_0\) to \(\varGamma ^*_1\). Observe that, since \(G \subset G^*\), restricting each drawing in \(\mathcal M^*\) to G yields a \(\big ( (2\ell (G)-1)\cdot f(n) \big )\)-step upward planar morph \(\mathcal M^-\) of G from \(\varGamma '_0\) to \(\varGamma '_1\). Therefore, by concatenating morphs \(\mathcal M_{start}\), \(\mathcal M^-\), and \(\mathcal M_{finish}\), we obtain a \(\big ( (2\ell (G)+1) \cdot f(n) \big )\)-step (a \(\big ( (2\ell (G)+1) \cdot f_R(n) \big )\)-step) upward planar morph of G from \(\varGamma _0\) to \(\varGamma _1\).    \(\square \)

Theorems 2, 4, and 6, imply the following main result.

Theorem 7

Let \(\varGamma _0\) and \(\varGamma _1\) be two upward planar drawings of the same n-vertex (reduced) upward plane graph. There exists an \(O(n^2)\)-step (an O(n)-step) upward planar morph from \(\varGamma _0\) to \(\varGamma _1\).

6 Conclusions and Open Problems

In this paper, we addressed for the first time the problem of morphing upward planar straight-line drawings. We proved that an upward planar morph between any two upward planar drawings of the same upward plane graph always exists. It easy to see that all our algorithms can be implemented in polynomial time.

Several problems remain open. In our opinion the most interesting question is whether an O(1)-step upward planar morph between any two upward planar drawings of the same plane st-graph exists. In case of a positive answer, by Theorem 6, an optimal O(n)-step upward planar morph would exist between any two upward planar drawings of the same n-vertex upward plane graph. In case of a negative answer, it would be interesting to find broad classes of upward plane graphs that admit upward planar morphs with a sub-linear number of steps. We proved that reduced plane st-graphs have this property and we ask whether the same is true for series-parallel digraphs [8, 14].