1 Introduction

We consider the morphing problem from the perspective of geometric representations of graphs. While a lot of work has been done to understand how to planarly morph the standard node-link diagrams and to “rigidly” morphFootnote 1 configurations of geometric objects, comparatively little has been explicitly done regarding (non-rigid) morphing of alternative representations of planar graphs, e.g., contact systems of geometric objects such as disks or triangles. In this case, the planarity constraint translates into the requirement of continuously maintaining a representation of the appropriate type throughout the morph.

More formally, let \({\mathcal {F}}\) be a family of geometric objects homeomorphic to a disk. An \({\mathcal {F}}\)-contact representation of a plane graph G maps vertices to internally disjoint elements of \({\mathcal {F}}\), where we assume that a plane graph has a fixed set of faces and a fixed outer face (see, e.g., Fig. 1). We denote the geometric object representing a vertex v by \(\Delta (v)\). Objects \(\Delta (v)\) and \(\Delta (w)\) touch if and only if \(\{v,w\}\) is an edge. The contact system of the objects must induce the same faces and outer face as in G. A morph between two \({\mathcal {F}}\)-contact representations \(R_0\) and \(R_1\) of a plane graph G is a continuously changing family of \({\mathcal {F}}\)-contact representations \(R_t\) of G indexed by time \(t\in [0,1]\) which means in particular that the boundary points of the geometric objects move along continuous trajectories from their starting to their ending position. An implication of the existence of morphs between any two representations of the same type is that the topological space defined by such representations is connected. We are interested in elementary morphs, and in particular in linear morphs, where the boundary points of the geometric objects move at constant speed along straight-line trajectories from their starting to their ending position. A piecewise linear morph of length \(\ell \) between two \({\mathcal {F}}\)-contact representations \(R_0\) and \(R_{\ell }\) of a plane graph G is a sequence \(\langle R_0,\dots ,R_{\ell }\rangle \) of \({\mathcal {F}}\)-contact representations of G such that there is a linear morph between \(R_i\) and \(R_{i+1}\) for \(i = 0,\dots ,\ell -1\). For a background on the mathematical aspects of morphing, see, e.g., [3].

Fig. 1
figure 1

Two representations of the same plane graph G. a A node-link diagram of G and b a contact representation of G using right-angle triangles, i.e., an RT-representation

1.1 Morphs of Node-Link Diagrams

A node-link diagram is a drawing of a graph in the plane where each vertex is represented as a point and each edge as a Jordan arc connecting its end vertices. In a plane node-link diagram of a plane graph edges do not cross and both the set of faces and the outer face are maintained. Fáry’s theorem tells us that every plane graph has a plane node-link diagram where the edges are mapped to line segments. Of course, for a given plane graph G, there can be many such node-link diagrams of G, and the goal of the work in planar morphing is to study how (efficiently) one can create a smooth (animated) transition from one such node-link diagram to another while maintaining planarity. Already in the 1940’s Cairns [19] proved that, for plane triangulations, planar morphs exist between any pair of plane node-link diagrams. However, the construction involved exponentially-many morphing steps. Floater and Gotsman [33], and Gotsman and Surazhsky [39, 50] gave a different approach via Tutte’s graph drawing algorithm [53], but this involves non-linear trajectories of unbounded complexity. Thomassen [51] and Aronov et al. [11] independently showed that two plane node-link diagrams of the same plane graph have a compatible triangulationFootnote 2 thereby lifting Cairns’ result to plane graphs. Of particular interest is the study of linear morphs, where each vertex moves at a uniform speed along a straight-line. After several intermediate results to improve the complexity of the morphs [2, 7] and to remove the necessity of computing compatible triangulations [9], an algorithm to construct a planar morph between any pair of plane node-link diagrams of any n-vertex plane graph using \(\Theta (n)\) linear steps was presented [1]. Such a morph can be computed in \({\mathcal {O}}(n^2 \log n)\) time [41]. For triconnected planar graphs, a different approach to obtain a linear number of linear morphs was recently presented by Erickson and Lin [28].

Planar morphs of other specialized plane node-link diagrams have also been considered, e.g., planar orthogonal drawings [15, 36, 37], convex drawings [8, 28, 40, 41], upward planar drawings [25], small-area drawings of trees [13], and so-called Schnyder drawings [14]. In this latter result the lattice structure of all Schnyder woods of a plane triangulation [17, 29] is exploited in order to obtain a sequence of linear morphs within a grid of quadratic size. Finally, planar morphs on the surface of the sphere [42] or the torus [20, 28] and in three dimensions have been investigated [12]. Beyond planarity, morphs have been recently considered for subclasses of 1-planar graphs [6].

1.2 Morphs of Contact Representations

Similar to Fáry’s theorem, the well-known Koebe–Andreev–Thurston theorem [4, 44] states that every plane graph G has a coin representation, i.e., an \({\mathcal {F}}\)-contact representation where \({\mathcal {F}}\) is the set of all disks. Additionally, for the case of triangulated plane graphs, such coin representations of G are unique up to Möbius transformations [18]—see [31] for a modern treatment. There has been a lot of work on how to intuitively understand and animate such transformations (see, e.g., the work of Arnold and Rogness [10]), i.e., for our context, how to morph between two coin representations. Of course, ambiguity remains regarding how to formalize the complexity of such morphs. In particular, this connection to Möbius transformations appears to indicate that a theory of piecewise linear morphing for coin representations would be quite limited.

Fig. 2
figure 2

An illustration of a morph between two RT-representations \(R_0\) and \(R_1\) of the same plane triangulation. All the intermediate representations between any two consecutive RT-representations above are obtained by interpolating the corners of each triangle along linear trajectories

For this reason, we instead focus on contact representations of convex polygons. These shapes still allow for representing all plane triangulations, as a direct consequence of the Koebe–Andreev–Thurston theorem, but are more amenable to piecewise linear morphs, where the linearity is defined on the trajectories of the corners; see, for example, the morph depicted in Fig. 2. De Fraysseix et al. [35] showed that every plane graph G has a contact representation by triangles, and observed that these triangle-contact representations correspond to the 3-orientations (i.e., the Schnyder woods) of G. Schrenzenmaier [49] used Schnyder woods to show that each 4-connected triangulation has a contact representation with homothetic triangles. Gonçalves et al. [38] extended the triangle-contact results from triangulations [35] to 3-connected plane graphs, by showing that Felsner’s generalized Schnyder woods [29] correspond to primal-dual triangle-contact representations. Note that triangles and coins are not the only families of shapes that have been studied from the perspective of contact representations. Some further examples include boxes in \(\mathbb {R}^3\) [22, 30, 52], line segments [34, 43], and homothetic polygons [24, 32, 48]. Recently, the problem of morphing restricted contact representations of axis-parallel rectangles, more precisely so called rectangular duals, has been considered [21].

The construction of triangle-contact representations [35] (and the correspondence to 3-orientations) can be adjusted so that each triangle is the lower-right half of an axis-parallel rectangle. These right-triangle representations (RT-representations) are our focus; see Fig. 1.

1.3 Our Contribution and Outline

We characterize the pairs of RT-representations of the same plane graph G that admit a morph. This characterization is based on the relationship between (degenerate) RT-representations and the Schnyder woods of G, and involves the existence of a special path in the distributive lattice of the Schnyder woods of G. More precisely, we prove that a morph between two RT-representations exists if and only if the corresponding Schnyder woods can be obtained from each other by reversing oriented inner faces of the triangulation only. The characterization leads to an efficient decision algorithm to test for the existence of a morph. Furthermore, in the positive case, the algorithm constructs a piecewise linear morph of quadratic length. This implies that, although elementary, piecewise linear morphs are as “powerful” as general morphs.

The paper is organized as follows. We start with some definitions in Sect. 2 and describe the relationship between (degenerate) RT-representations and Schnyder woods of plane triangulations in Sect. 3. In particular, we show that any morph between two RT-representations can be associated with a special sequence of Schnyder woods (Theorem 3.4). In Sect. 4, we provide sufficient geometric conditions for a linear morph between two RT-representations. The first condition is that each corner c of a triangle touches the same side s of another triangle in the two representations. By the described relationship, this corresponds to the fact that the morph happens within the same Schnyder wood. The second condition ensures that the contact between c and s is maintained. This is fulfilled if s has the same slope in the two RT-representations or if the point of s hosting c is defined by the same convex combination of the end-points of s in both representations. In Sect. 5, we present our morphing algorithm. If the two input RT-representations correspond to different Schnyder woods, we consider a path (if any) between them in the lattice structure of all Schnyder woods, similar to [14], that satisfies the necessary properties stated in Theorem 3.4. When moving along this path, from a Schnyder wood to another, we construct intermediate RT-representations that simultaneously correspond to both woods. We provide an algorithm to construct such intermediate RT-representations that results in a linear morph at each step. Finally, in Sect. 6, we show how to decide whether there exists a path in the lattice structure that satisfies the required properties. This results in an efficient testing algorithm for the existence of a piecewise linear morph between two RT-representations of a plane triangulation; in the positive case, the computed piecewise linear morph has at most quadratic length. Consequently, for 4-connected plane triangulations, under a natural condition on the outer face of their RT-representations, the topological space defined by such RT-representations is connected.

2 Definitions and Preliminaries

2.1 Basics

Throughout this paper we consider simple graphs without loops and parallel edges. A plane triangulation is a maximal planar graph with a distinguished outer face. A directed acyclic graph (DAG) is an oriented graph with no directed cycles. A topological ordering of an n-vertex DAG \(G=(V,E)\) is a one-to-one map \(\tau :V\rightarrow \mathbb {\{}1,\dots ,n\}\) such that \(\tau (v)<\tau (w)\) for \((v,w)\in E\). Let p and q be two points in the plane. The line segment \(\overline{pq}\) is the set \({\{(1-\lambda ) p+\lambda q:0\le \lambda \le 1\}}\) of convex combinations of p and q. Considering \(\overline{pq}\) oriented from p to q, we say that x cuts \(\overline{pq}\) with the ratio \(\lambda \) if \(x= (1-\lambda ) p + \lambda q\).

In the case of polygons, a linear morph is completely specified by the initial and final positions of the corners of each polygon. If a corner p is at position \(p_0\) in the initial representation (at time \(t = 0\)) and at position \(p_1\) in the final representation (at time \(t = 1\)), then its position at time t during a linear morph is \({(1 - t) p_0 + t p_1}\) for any \(0 \le t \le 1\).

2.2 Schnyder Woods

A 3-orientation [17, 29] of a plane triangulation is an orientation of the inner edges such that each inner vertex has out-degree 3 and the three outer vertices have out-degree 0. A Schnyder wood T [47] of a plane triangulation G is a 3-orientation together with a partition of the inner edges into three color classes, such that the three outgoing edges of an inner vertex have distinct colors and all the incoming edges of an outer vertex have the same color. Moreover, the color assignment around the vertices must be as indicated in Fig. 3: The clockwise ordering of the colors of the three outgoing edges is the same for each inner vertex (say red, green, blue) and all incoming edges of a certain color are between the two outgoing edges of the other two colors (e.g. the red incoming edges, if any, are between the blue and the green outgoing edge). We say that a cycle in a Schnyder wood is oriented if it is a directed cycle.

Fig. 3
figure 3

The two conditions for a Schnyder wood

The following well-known properties of Schnyder woods can directly be deduced from the work of Schnyder [47].

  1. (i)

    Every plane triangulation has a 3-orientation.

  2. (ii)

    For each 3-orientation of a plane triangulation there is exactly one partition of the inner edges into three color classes such that the pair yields a Schnyder wood.

  3. (iii)

    Each color class of a Schnyder wood induces a directed spanning tree rooted at an outer vertex.

  4. (iv)

    Reversing the edges of two color classes and maintaining the orientation of the third color class yields a directed acyclic graph.

  5. (v)

    The edges of an oriented triangle in a Schnyder wood have three distinct colors and every triangle composed of edges of three different colors is oriented.

We call the color classes red (r,), blue (b,), and green (g,). The symbols \(X_r\), \(X_b\), and \(X_g\) denote the red, blue, and green outer vertex of G, i.e., the outer vertices with incoming red, blue, and green edges, respectively. For an inner vertex v, let \(v_r\), \(v_b\), and \(v_g\) be the respective neighbors of v such that \((v,v_r)\) is red, \((v,v_b)\) is blue, and \((v,v_g)\) is green. Finally, let \({{\,\textrm{DAG}\,}}_r(T)\) (\({{\,\textrm{DAG}\,}}_b(T)\)) be the directed acyclic graph obtained from G by orienting all red (blue) edges as in T while all blue (red) and green edges are reversed.

Fig. 4
figure 4

A counter-clockwise flip of an oriented facial triangle C in a Schnyder wood

Let C be an oriented triangle of a Schnyder wood T. Reversing C yields another 3-orientation with its unique Schnyder wood \(T_C\). If C is a facial cycle, i.e., the boundary of an internal face, then T differs from \(T_C\) by recoloring the edges on C only. See Fig. 4 for an example. More precisely, the new outgoing edge of a vertex gets the color of the former outgoing edge of the same vertex. This procedure of reversing and recoloring is called flippingFootnote 3 an oriented triangle of a Schnyder wood. Any Schnyder wood can be converted into any other Schnyder wood of the same plane triangulation by flipping \(\mathcal O(n^2)\) oriented triangles [14, 17]. For two Schnyder woods \(T_0\) and \(T_\ell \), \(\langle C_1,\dots ,C_{\ell }\rangle \) is a flip sequence between \(T_0\) and \(T_\ell \) if there are Schnyder woods \(T_1,\dots ,T_{\ell -1}\) such that \(C_i\), \(i=1,\dots ,\ell \), is an oriented triangle in \(T_{i-1}\) and \(T_i\) is obtained from \(T_{i-1}\) by flipping \(C_i\). We say that a Schnyder wood \(T'\) can be obtained from a Schnyder wood T by a sequence of facial flips if there is a flip sequence between T and \(T'\) that contains only facial cycles.

3 RT-Representations of Plane Triangulations

Let R be an RT-representation of a plane triangulation G and let u be a vertex of G. Recall that the triangle \(\Delta (u)\) representing u is the lower-right half of an axis-parallel rectangle. We use , , and to denote the horizontal, vertical, and diagonal side of \(\Delta (u)\). The topmost vertex of R is the vertex v of G for which the y-coordinate of is maximum. Further, we let , and denote the left, right, and top corner of \(\Delta (u)\), respectively. If two triangles touch each other in their corners, we say that these two corners coincide. We call a face \(f= \left\langle u,v,w\right\rangle \) degenerate if , , pairwise coincide (in which case f corresponds to a single point), see Fig. 5(b). An RT-representation is degenerate if it contains a degenerate face; otherwise, it is non-degenerate. Let (cs) be a pair with and , we say that (cs) is a compatible pair if it belongs to the set . Observe that, if a corner c of a triangle \(\Delta (u)\) touches the interior of a side s of a triangle \(\Delta (v)\), with \((u,v)\in E(G)\), then (cs) is a compatible pair. On the other hand, when two corners coincide, there exist four different pairs composed of a corner and a side, two of which are compatible. E.g., if coincides with for two vertices u and v, then the two compatible pairs are and —even though also touches and touches .

In the next two subsections, we describe the relationship between RT-representations and Schnyder woods [35] and extend it to the case of degenerate RT-representations. Along the way we will establish a condition on the existence of a morph between RT-representations and prove its necessity (Theorem 3.4).

3.1 From RT-Representations to Schnyder Woods

Let \(G=(V,E)\) be a plane triangulation with a given RT-representation R. It is possible to orient and color the edges of G in order to obtain a Schnyder wood by considering the types of contacts between triangles in R as follows.

First, consider the non-degenerate case; refer to Fig. 5(a). Let \(e=\{u,v\} \in E\) be an inner edge such that a corner c of \(\Delta (u)\) touches a side s of \(\Delta (v)\). We use the following rules: We orient e from u to v, and color e blue if c is , green if c is , red if c is . Observe that due to this convention the topmost vertex is \(X_r\).

Lemma 3.1

[35, Thm. 2.2] The above assignment yields a Schnyder wood.

Assume now that there exist two triangles \(\Delta (u)\) and \(\Delta (v)\) whose corners coincide. Observe that the assignment of colors and directions to the edge \(\{u,v\}\) determined by the procedure above would be ambiguous. The next observation will be useful to resolve this ambiguity.

Observation 3.2

Consider an RT-representation of a plane triangulation and an edge \(\{u,v\}\) that is not on the outer face. If a corner of the triangle \(\Delta (u)\) coincides with a corner of the triangle \(\Delta (v)\) in a point p, then \(\{u,v\}\) is incident to a degenerate face.

Proof

Let \(f_\ell \) and \(f_r\) be the two triangular faces to the left and the right of \(\{u,v\}\), and let \(w_\ell \) and \(w_r\) be the vertex incident to \(f_\ell \) and \(f_r\), respectively, that is different from u and v. Then, \(\Delta (w_\ell )\) and \(\Delta (w_r)\) must both touch \(\Delta (u)\) and \(\Delta (v)\), and they must be on different sides of p, unless one of \(f_\ell \) and \(f_r\) is the outer face. This implies that either \(\Delta (w_\ell )\) or \(\Delta (w_r)\) has a corner on p.

An immediate consequence of Observation 3.2 is that whenever three triangles intersect in a common point then they bound a degenerate face. Consider now a degenerate face f. For each of the three edges bounding f, a choice of coloring and orientation corresponds to deciding which of the two triangles participates to the touching with its corner and which triangle with an extremal point of one of its sides, which in turn corresponds to choosing one of the two compatible pairs determined by the touching. This yields two options as indicated in Fig. 5(b), both resulting in a Schnyder wood. Note that the face f is cyclic in both these Schnyder woods, and each of them can be obtained from the other by flipping f.

Fig. 5
figure 5

From an RT-representation to a Schnyder wood

Summarizing, we get the following.

Observation 3.3

Given an RT-representation R of a plane triangulation G, let P be the set of points where three triangles intersect. Then, R corresponds to a set \(\mathcal {T}_R\) of \(2^{|P|}\) different Schnyder woods on G, the points of P correspond to |P| edge-disjoint oriented faces, and the Schnyder woods in \({\mathcal {T}}_R\) differ in flipping some of them.

Observe that there is always a planar morph between two RT-representations of a graph with three vertices. See Fig. 10. This is in general no longer true for triangulations with separating triangles.

Theorem 3.4

(necessary condition)  If there is a (not necessarily piecewise linear) morph between two RT-representations of a plane triangulation G with more than three vertices, then the corresponding Schnyder woods can be obtained from each other by a sequence of facial flips. In particular the topmost vertex is the same in both representations.

Proof

Let \(R_t\), \(t\in [0,1]\), be a morph between two RT-representations \(R_0\) and \(R_1\) of G. Consider moments in time \(t_1,\dots ,t_k\) defined as follows. Let \(t_1=0\) and \(t_k=1\). Given \(t_i<1\), let \(t_{i+1}\) be maximum such that \({\mathcal {T}}_{R_{t_i}}\cap \mathcal T_{R_{t_{i+1}}}\ne \emptyset \), where \({\mathcal {T}}_R\) is the set of Schnyder woods corresponding to an RT-representation R as defined in Observation 3.3. Such a \(t_{i+1}>t_i\) exists: First of all, observe that there exists a Schnyder wood \(T\in {\mathcal {T}}_{R_{t_i}}\) that also occurs at a later moment t, i.e., such that \(T\in {\mathcal {T}}_{R_t}\) for some \(t>t_i\). More precisely, since morphs are continuous there is always an \(\epsilon >t_i\) such that \({\mathcal {T}}_{R_{t_i}}\cap \mathcal T_{R_\epsilon }\ne \emptyset \). Second, we show that such a maximum moment in time exists. Let \(T\in {\mathcal {T}}_{R_{t_i}}\). The moments in time in which T occurs form closed intervals. The maxima of these intervals form an increasing sequence in a compact subset of the reals and, thus, converge to the supremum \(t_T\). Due to continuity there must exist an \(\epsilon >0\) such that \(\mathcal T_{R_t}\subseteq {\mathcal {T}}_{R_{t_T}}\) for \(t_T-\epsilon \le t\le t_T\). Since \(t_T\) is the supremum of moments in time in which the Schnyder wood T occurs it follows that \(T\in {\mathcal {T}}_{R_{t_T}}\). Since \(|{\mathcal {T}}_{R_{t_i}}|\) is finite, it follows that \(t_{i+1}=\max _{T\in {\mathcal {T}}_{R_{t_i}}}t_T\).

Now let \(T_i \in {\mathcal {T}}_{R_{t_i}} \cap \mathcal T_{R_{t_{i+1}}}\), \(i=1,\dots ,k-1\). Then \(T_{i+1}\) and \(T_i\) are both contained in \(T_{R_{t_{i+1}}}\). Thus, by Observation 3.3, \(T_{i+1}\) can be obtained from \(T_i\) by a sequence of edge-disjoint facial flips. Hence, any Schnyder wood of \(R_1\) can be obtained from any Schnyder wood of \(R_0\) by a sequence of facial flips.

The red outer vertex \(X_r\) cannot be changed by facial flips. Thus, the topmost vertex remains the same throughout the morph. Intuitively, changing the topmost vertex would require collapsing the outer 3-cycle into a single point. \(\square \)

We will show that the necessary condition is also sufficient (Sect. 5), and can be tested in quadratic time (Sect. 6).

3.2 From Schnyder Woods to RT-Representations

Assume now that we are given a Schnyder wood T of a plane triangulation \(G=(V,E)\). We describe a technique for constructing an RT-representation of G corresponding to T in which the y-coordinate of the horizontal side of each triangle is prescribed by a function \(\tau :V \rightarrow {\mathbb {R}}\) satisfying some constraints. We would like to mention that in the non-degenerate case in [35], the function \(\tau \) assigning the y-coordinates is a topological ordering of \({{\,\textrm{DAG}\,}}_r(T)\), also called a canonical ordering of G.

We call \(\tau :V\rightarrow \mathbb {R}\) an Admissible Degenerate Topological labeling of the graph \({{\,\textrm{DAG}\,}}_r(T)\), for short ADT-labeling, if for each directed edge (uv) of \({{\,\textrm{DAG}\,}}_r(T)\), we have

  1. (i)

    \(\tau (u) \le \tau (v)\) and

  2. (ii)

    \(\tau (u)=\tau (v)\) only if (see Figs. 5(b) and 6(c)) the edge between u and v

    • is green and belongs to a clockwise oriented facial cycle, or

    • is blue and belongs to a counter-clockwise oriented facial cycle, and

  3. (iii)

    if \(\tau (v_b)=\tau (v) = \tau (v_g)\) for a vertex v, and \(v_1\) and \(v_2\) are vertices such that \(\langle v,v_g,v_1\rangle \) is a clockwise facial cycle and \(\langle v,v_b,v_2\rangle \) is a counter-clockwise facial cycle, then \(v_1\ne v_2\) (see Fig. 7).

Lemma 3.5

Let R be an RT-representation of a plane triangulation \(G=(V,E)\), let T be a Schnyder wood corresponding to R, and let \(\tau (v)\), \(v \in V\), be the y-coordinate of . Then, \(\tau \) is an ADT-labeling of \({{\,\textrm{DAG}\,}}_r(T)\).

Proof

Let (uv) be a directed edge of \({{\,\textrm{DAG}\,}}_r(T)\). By the definition of T, we get immediately that \(\tau (u)\le \tau (v)\) independently of whether (uv) is red, green, or blue. In fact, if (uv) is red, then it is oriented from u to v in \(T_r\). Thus, the compatible pair corresponding to such an edge in R is . Hence, lies strictly below . If (uv) is green (resp., blue), then it is oriented from v to u in T. Thus, the compatible pair corresponding to such an edge in R is (resp., ). Hence, does not lie above .

Assume that \(\tau (u)=\tau (v)\), which implies that (uv) is not red, as observed above. Suppose that (vu) is a green edge. Then, and  coincide. By Observation 3.2, there exists a vertex z such that coincides with and . Thus, \(\langle v,u,z\rangle \) is a clockwise oriented facial cycle. Similarly, when (vu) is a blue edge, there is a vertex z such that , , and  coincide. Therefore, \(\langle v,u,z\rangle \) is a counter-clockwise oriented facial cycle.

Finally, if \(\tau (v_b)=\tau (v)=\tau (v_g)\) and \(v_1\) and \(v_2\) are the vertices such that \(\langle v,v_g,v_1\rangle \) is a clockwise facial cycle and \(\langle v,v_b,v_2\rangle \) is a counter-clockwise facial cycle, then touches and touches . See Fig. 7. Thus, \(v_1\ne v_2\). \(\square \)

Lemma 3.6

Let T be a Schnyder wood of an n-vertex plane triangulation G, let \(\tau \) be an ADT-labeling of \({{\,\textrm{DAG}\,}}_r(T)\), and let \(R_o=\Delta (X_r)\cup \Delta (X_g)\cup \Delta (X_b)\) be an RT-representation of the outer face of G such that has y-coordinate \(\tau (X_i)\), with \(i\in \{r,g,b\}\). Then, there exists a unique RT-representation \({{\,\textrm{RT}\,}}(T,\tau ,R_o)\) of G corresponding to T in which has y-coordinate \(\tau (v)\), for each vertex v of G, and in which the outer face is drawn as in \(R_o\).

Fig. 6
figure 6

(a) A Schnyder wood T of a plane triangulation G; the edges connecting v with vertices \(v_r\), \(v_g\), and \(v_b\) are dashed. (b) Graph \({{\,\textrm{DAG}\,}}_r(T)\) with ADT-labeling \(\tau \). (c) An RT-representation of G constructed from T, \(\tau \), and an RT-representation \(R_o\) of the outer face

Fig. 7
figure 7

Illustration of (iii) of an ADT-labeling where \(\tau \)(\(v_b)\)  =  \(\tau \)(v)\(\,= \tau \)(\(v_g)\). Mind that, compared to Fig. 6, the faces f and h are flipped

Proof

Let \(\tau ':V \leftrightarrow \{1,2,\dots ,n\}\) be a topological ordering of \({{\,\textrm{DAG}\,}}_r(T)\). We process the vertices of G according to \(\tau '\). By the construction of \({{\,\textrm{DAG}\,}}_r(T)\), we have that \(\tau '(X_r)=n\) and either \(\tau '(X_b)=1\) and \(\tau '(X_g)=2\) or \(\tau '(X_g)=1\) and \(\tau '(X_b)=2\). Thus, in the first two steps and in the last step, we must draw triangles \(\Delta (X_b)\), \(\Delta (X_g)\), and \(\Delta (X_r)\) as in \(R_o\); see Fig. 6(c).

At each of the intermediate steps, we consider a vertex v, with \(\tau '(v)=i\), \(2<i<n\). Let \(R_{i-1}\) be the unique RT-representation of the subgraph \(G_{i-1}\) of G induced by the vertices preceding v in \(\tau '\) under the conditions required in the lemma. Since the y-coordinates of the horizontal sides of the triangles are determined by \(\tau \) and since must touch , we must draw \(\Delta (v)\) so that its horizontal side has y-coordinate \(\tau (v)\) and its top corner has y-coordinate \(\tau (v_r)\). It remains to assign the x-coordinates of and . We are going to perform this assignment based on \(\Delta (v_b)\) and \(\Delta (v_g)\), which have already been drawn in \(R_{i-1}\). Indeed, since the blue edge \((v_b,v)\) and the green edge \((v_g,v)\) are entering v in \({{\,\textrm{DAG}\,}}_r(T)\), we have that \(\tau '(v_b)<\tau '(v)\) and \(\tau '(v_g)<\tau '(v)\).

Before describing the assignment of the x-coordinates of and , we discuss some properties of \(R_{i-1}\). First, by condition (i) of ADT-labeling, we have that \(\tau (v_b)\le \tau (v)\) and \(\tau (v_g) \le \tau (v)\), and thus the horizontal side of \(\Delta (v)\) will not lie below the ones of \(\Delta (v_b)\) and \(\Delta (v_g)\). Also, we assume that the following two invariants hold in \(R_{i-1}\) and we will show that they also hold in \(R_i\) after drawing \(\Delta (v)\):

  1. (i)

    The y-coordinates of and are both greater than or equal to \(\tau (v)\).

  2. (ii)

    Let \(v_1=X_b,\dots ,v_q=X_g\) be the path along the outer face of \(G_{i-1}\). Then have increasing x-coordinates in \(R_{i-1}\).

The two invariants imply in particular that the horizontal line \(y= \tau (v)\) intersects both, \(\Delta (v_b)\) and \(\Delta (v_g)\), and that \(\Delta (v_b)\) is to the left of \(\Delta (v_g)\). Thus, \(\Delta (v)\) can only touch \(\Delta (v_b)\) and \(\Delta (v_g)\) if and are the intersection point of the line \(y= \tau (v)\) with and , respectively. This implies the uniqueness of the RT-representation, under the constraints imposed by the function \(\tau \) and the given RT-representation \(R_o\) of the outer face. We thus assign the x-coordinates of and accordingly, hence obtaining a representation \(R_i\). In the following, we prove that \(R_i\) is actually an RT-representation of \(G_i\) corresponding to the Schnyder wood T.

Since \(R_i\) contains \(R_{i-1}\), which is an RT-representation of \(G_{i-1}\), we only need to consider the touchings between v and its neighbors in \(G_i\). Since vertices of G are processed according to a topological ordering \(\tau '\) of \({{\,\textrm{DAG}\,}}_r(T)\), such neighbors of v are exactly \(v_b\), \(v_g\), and each vertex u such that \(u_r=v\). By construction, and  touch and , respectively. Next, we prove that touches for each vertex u such that \(u_r=v\). Namely, by construction, has y-coordinate equal to \(\tau (v)\), so it suffices to show that is between and . This is obvious if \(u_r=X_r\). Otherwise, this directly follows from invariant (ii), since u appears between \(v_b\) and \(v_g\) on the \(X_b\)-\(X_g\)-path along the outer face of \(G_{i-1}\). Thus, all corners touch the correct side of another triangle as required by the Schnyder wood T.

Then, we show that the horizontal side of \(\Delta (v)\) has positive length. This is clear if \(\tau (v)\) is strictly greater than both \(\tau (v_g)\) and \(\tau (v_b)\). So assume first that \(\tau (v_b)<\tau (v)=\tau (v_g)\). Then, by condition (ii) of ADT-labeling, there is a vertex u such that \(\langle v,v_g,u\rangle \) is a clockwise facial cycle. It follows that (uv) is an incoming red edge of v in T and thus lies between \(\Delta (v_b)\) and \(\Delta (v_g)\) on the horizontal line \(y=\tau (v)\), as discussed above. Since the horizontal side of \(\Delta (u)\) has a positive length in \(R_{i-1}\) and since \(\tau (v_b)<\tau (v)\), the vertical side of \(\Delta (v_b)\) must be strictly to the left of , and thus strictly to the left of . The case \(\tau (v_b)=\tau (v)>\tau (v_g)\) is analogous. Finally, we consider the case \(\tau (v_b)=\tau (v)=\tau (v_g)\). By condition (iii) of ADT-labeling, there exist two distinct vertices \(u_1\) and \(u_2\) such that \(\langle v,v_g,u_1\rangle \) is a clockwise facial cycle and \(\langle v,v_b,u_2\rangle \) is a counter-clockwise facial cycle. Since the horizontal side of \(\Delta (u_1)\) and \(\Delta (u_2)\) have positive length in \(R_{i-1}\), the right corner of \(\Delta (v_b)\) and the left corner of \(\Delta (v_g)\) cannot coincide.

This concludes the proof that \(R_i\) is an RT-representation of \(G_i\). We conclude by showing that the two invariants are maintained in \(R_i\).

  • Invariant (i) is fulfilled: We show that the top corner of \(\Delta (v_b)\) has y-coordinate greater than or equal to \(\tau (v)\). The arguments for \(\Delta (v_g)\) are analogous. If \(v_b = X_b\), this follows from the fact that has y-coordinate greater than or equal to \(\tau (X_r)\) in \(R_o\).

    Otherwise, recall that the y-coordinate of has been set equal to \(\tau (r)\), where r is the neighbor of \(v_b\) such that edge \((v_b,r)\) of \({{\,\textrm{DAG}\,}}_r(T)\) is red. Let \(w_1,\dots ,w_k\) (with \(w_1=v\) and \(w_k=r\)) be the neighbors of \(v_b\) such that edges \((v_b,w_1),\dots ,(v_b,w_k)\) appear in this counter-clockwise order around \(v_b\). See the figure to the right. Since \((v_b,w_1)\) is blue and entering \(v_b\) in T, while \((v_b, w_k)\) is red and exiting \(v_b\) in T, we have that each edge \((v_b, w_i)\), with \(2\le i\le k-1\), is blue and entering \(v_b\) in T.

    It follows that the edge \(e=(w_j, w_{j+1})\), for \(j=1, \dots , k-1\) is the next edge incident to \(w_j\) in clockwise direction after an outgoing blue edge. Thus, e is either red and exiting \(w_j\) in T or green and entering \(w_j\) in T. Hence, \(w_1,\dots ,w_k\) form a directed path from \(v_b\) to r in \({{\,\textrm{DAG}\,}}_r(T)\), where red edges maintain their orientation while green edges are reversed. Hence, \(\tau (r) \ge \tau (v)\). Thus, has y-coordinate larger than or equal to \(\tau (v)\), as desired.

  • Invariant (ii) is fulfilled: Let \(P_{i-1}:v_1=X_b,\dots ,v_q=X_g\) be the path along the outer face of \(G_{i-1}\). Since \(R_{i-1}\) satisfies invariant (ii), we have that have increasing x-coordinates in \(R_{i-1}\). Let \(1\le \ell <k\le q\) be such that \(v_b=v_j\) and \(v_g=v_k\). Then, the path \(P_i\) along the outer face of \(G_i\) is obtained from \(P_{i-1}\) by replacing the sequence \(v_j,\dots ,v_k\) by \(v_j,v,v_k\). Since we place v between \(v_j=v_b\) and \(v_k=v_g\), the invariant holds in \(R_i\).

As both invariants trivially hold in the given drawing of \(\Delta (X_b)\) and \(\Delta (X_g)\), the lemma follows.\(\square \)

4 Geometric Tools

In this section, we provide geometric lemmata that will be exploited in the subsequent sections. We first show that the incidence of a point and a line segment is maintained during a linear morph if the line segment is moved in parallel (with a possible stretch, but keeping the orientation) or the ratio with which the point cuts the segment is maintained; see Fig. 8.

Lemma 4.1

For \(i=0,1\) let \(p_i,q_i\) be two points in the plane and let \(x_i \in \overline{p_iq_i}\). For \(0< t < 1\), further let \({p_t = (1-t) p_0 + t p_1}\) and \({q_t = (1-t) q_0 + t q_1}\). Then, \({x_t = (1-t) x_0 + t x_1 \in \overline{p_t q_t}}\) if

  • \(\overline{p_0 q_0}\) and \(\overline{p_1 q_1}\) are parallel with the same direction, or

  • \(x_0\) cuts \(\overline{p_0q_0}\) with the same ratio as \(x_1\) cuts \(\overline{p_1q_1}\).

Moreover, in both cases, if \(x_t=p_t\) for some \(t \in [0,1]\) then \(x_0=p_0\) and \(x_1=p_1\).

Proof

Assume first that \(\overline{p_0q_0}\) and \(\overline{p_1q_1}\) are parallel. If \(\overline{p_0q_0}\) and \(\overline{p_1q_1}\) are collinear, we may assume that they are both contained in the x-axis, that \(p_i,q_i\), \(i=0,1\), are real numbers, and that \(p_0 <q_0\). Since \(\overline{p_0q_0}\) and \(\overline{p_1q_1}\) have the same direction, this implies that \(p_1 < q_1\). Since \(x_i\), \(i=0,1\), is a point in \(\overline{p_iq_i}\), it follows that \(p_i \le x_i \le q_i\). Hence, we get for \(t\in [0,1]\) that

$$\begin{aligned} {\underbrace{(1-t) p_0+t p_1}_{p_t} \le \underbrace{(1-t) x_0+tx_1}_{x_t} \le \underbrace{(1-t) q_0+t q_1}_{q_t},} \end{aligned}$$

where equality holds if and only if \(x_0=p_0\) and \(p_1=x_1\), or \(x_0=q_0\) and \(x_1=q_1\), respectively.

If \(\overline{p_0 q_0}\) and \(\overline{p_1 q_1}\) are parallel with the same direction but not collinear, then the polygon \(\langle p_0,q_0,q_1,p_1\rangle \) is convex. Thus, \(\overline{x_0 x_1}\) must intersect \(\overline{p_t q_t}\), for any t. Also, \(\overline{p_t q_t}\) and \(x_t\) both lie on the same line \(\ell _t\). More precisely, let d be the distance between the lines through segments \(\overline{p_0 q_0}\) and \(\overline{p_1q_1}\). Then, \(\ell _t\) is the line with distance td from \(\overline{p_0 q_0}\). Moreover, due to the convexity of \(\langle p_0,q_0,q_1,p_1\rangle \) , we have that \(x_t=p_t\) implies \(x_0=p_0\) and \(x_1=p_1\).

Finally, if \(x_0\) cuts \(\overline{p_0q_0}\) with the same ratio \(\lambda \) as \(x_1\) cuts \(\overline{p_1q_1}\), then it follows that \({x_t = (1-t)((1-\lambda )} p_0 +\lambda q_0)+t ((1-\lambda ) p_1+\lambda q_1)=(1-\lambda ) p_t+\lambda q_t\in \overline{p_tq_t}\). Moreover, \(x_t=p_t\) if and only if \(\lambda =0\), and, thus, \(x_0=p_0\) and \(x_1=p_1\). \(\square \)

Fig. 8
figure 8

Morphing a segment and a point

Lemma 4.1 implies the following sufficient criterion for a linear morph. For an illustration of the special shape assumed for the outer face in the following lemma see, e.g., Fig. 2.

Lemma 4.2

Let \(R_0\) and \(R_1\) be two RT-representations of a triangulation G corresponding to the same Schnyder wood such that the triangles of the outer face pairwise touch in their corners. The pair \(\langle R_0,R_1\rangle \) defines a linear morph if, for any two adjacent vertices u and v such that a corner \(c_i(v)\), \(i\in \{0,1\}\), of v touches a side \(s_i(u)\) of u, where and , one of the following holds:

  1. (i)

    \(s_0(u)\) and \(s_1(u)\) are parallel.

  2. (ii)

    \(c_0(v)\) cuts \(s_0(u)\) with the same ratio as \(c_1(v)\) cuts \(s_1(u)\).

Proof

Let \(R_t\) be the representation at time instant t of the linear morph from \(R_0\) to \(R_1\), with \(t\in [0,1]\), i.e., the set of triangles obtained by interpolating the corners of each triangle in \(R_0\) to \(R_1\). It suffices to show that \(R_t\) is an RT-representation of G.

We start by proving that, for every vertex u of G, the triangle \(\Delta _t(u)\) representing u in \(R_t\) is the lower-right half of an axis-parallel rectangle with positive area. Consider the triangles \(\Delta _0(u)\) and \(\Delta _1(u)\) representing u in \(R_0\) and \(R_1\), respectively. Since and are vertical segments with lying above , with \(i=0,1\), we have that is a vertical segment with lying above . A similar argument applies to prove that is a horizontal segment with lying to the left of . Since all these segments have positive length, the claim follows.

Next, we prove that \(R_t\) is an RT-representation of G, i.e., we show that any two triangles touch in \(R_t\) if and only if the corresponding vertices of G are adjacent, and that no two triangles share more than one point.

First, consider two vertices u and w that are adjacent in G. We show that \(\Delta _t(u)\) and \(\Delta _t(w)\) touch in exactly one point. Let \(c_0(u)\) with and \(s_0(w)\) with be the corner of \(\Delta _0(u)\) and the side of \(\Delta _0(w)\), respectively, that touch in \(R_0\). Since \(R_0\) and \(R_1\) correspond to the same Schnyder wood, and since the triangles of the outer face pairwise touch in their corners, we have that the corner \(c_1(u)\) of \(\Delta _1(u)\) touches the side \(s_1(w)\) of \(\Delta _1(w)\) in \(R_1\). This, together with Lemma 4.1, implies that the corner \(c_t(u)\) of \(\Delta _t(u)\) touches the side \(s_t(w)\) of \(\Delta _t(w)\) in \(R_t\). The fact that no other points are shared between \(\Delta _t(u)\) and \(\Delta _t(w)\) derives from the possible corner-side pairs (cs) that may appear in an RT-representation. This also implies that \(R_t\) induces the same Schnyder wood as \(R_0\) and \(R_1\).

Second, consider two vertices u and w that are not adjacent in G. We show that \(\Delta _t(u)\) and \(\Delta _t(w)\) do not share any point in \(R_t\). We are going to exploit the following property of a Schnyder wood T of G [5, 27, 46]: Let \(T_r,T_g,T_b\), respectively, be the subtree of T induced by the red, green, and blue edges, respectively. There exists a vertex z, possibly \(z=w\), such that \(T_i\) contains a path \(P_{u,z}\) from u to z and \(T_j\) contains a path \(P_{w,z}\) from w to z, for some \(i\ne j\in \{r,g,b\}\). We will show that \(\Delta _t(u)\) and \(\Delta _t(w)\) are in different quadrants of . See Fig. 9 for an illustration.

Fig. 9
figure 9

The three quadrants containing triangles on a red, green, or blue path to z

Consider a path P to z such that every edge has the same color. Then any corner-side pair determined by any edge in P is of the same type, more precisely, of type if P is green, of type if P is blue, and of type if P is red. Let a be a vertex. If there is a green a-z-path then \(\Delta _t(a)\) is in the upper left quadrant of , including the boundary above or to the left of . If there is a blue a-z-path then \(\Delta _t(a)\) is in the upper right quadrant of , including the boundary between and . Finally, if there is a red a-z-path then \(\Delta _t(a)\) is in the lower-left quadrant of , including the boundary between and . The only three points where triangles of these three regions could intersect are the three corners of \(\Delta _t(z)\). Assume that a corner of \(\Delta _t(u)\) and a corner of \(\Delta _t(w)\) coincide with the same corner of \(\Delta _t(z)\). But then the last statement of Lemma 4.1 would imply that the same corners would also coincide in \(R_0\) and \(R_1\)—contradicting that u and w were not adjacent. \(\square \)

Fig. 10
figure 10

Morphing an RT-representation of a triangle to a labeled canonical form: First, cut the extruding parts of the triangles, maintaining the slopes of the diagonal sides. Then, scale the triangles such that the horizontal and vertical sides have length one. Finally, keep rotating the triangles until the topmost vertex is as desired

5 A Morphing Algorithm

In this section, we prove that the necessary conditions in Theorem 3.4 are also sufficient and show how to construct a piecewise linear morph if the conditions are fulfilled.

Theorem 5.1

(sufficient condition)  Let \(R_1\) and \(R_2\) be two RT-representations of an n-vertex plane triangulation G corresponding to the Schnyder woods \(T_1\) and \(T_2\), respectively. If \(T_2\) can be obtained from \(T_1\) by a sequence of \(\ell \) facial flips, then there exists a piecewise linear morph between \(R_1\) and \(R_2\) of length \({\mathcal {O} (n+\ell )}\). Such a morph can be computed in \({\mathcal {O} (n (n+\ell ))}\) time, provided that the respective sequence of \(\ell \) facial flips is given.

Since there is always a piecewise linear morph between two RT-representations of a plane triangle (see Fig. 10), we will assume that G has at least four vertices. The fact that \(T_1\) can be obtained from \(T_2\) by a sequence of facial flips implies in particular that the topmost vertex, which always coincides with \(X_r\), is the same in \(R_1\) and \(R_2\).

In Sect. 5.1, we introduce our main procedure adjust, which moves a triangle in an RT-representation along an incident diagonal and adjusts the remaining triangles so that the result is a linear morph. Repeatedly applying adjust, we first morph \(R_1\) to a non-degenerate RT-representation that still corresponds to \(T_1\) (Sect. 5.3); then, we perform a sequence of linear morphs to geometrically realize the \(\ell \) facial flips (Sect. 5.2), hence obtaining an RT-representation corresponding to \(T_2\), which we finally morph to \(R_2\) (Sect. 5.3). See Fig. 11 for an illustration.

Fig. 11
figure 11

Construction pipeline: First, (b) we trim the outer face into a canonical form (three steps) and (c) make the inner faces non-degenerate (one step per face). Then, (d) + (e) we perform the facial flips on the faces indicated by striped triangles (two steps per flip). Finally, (f) we morph to the target RT-representation (linear number of steps)

5.1 Moving a Triangle Along a Diagonal

Let \(G=(V,E)\) be a plane triangulation and let R be an RT-representation of G corresponding to a Schnyder wood T of G. Given an inner vertex \(\sigma \) of G and a real value y with some properties, adjust computes a new RT-representation \(R'\) of G corresponding to T in which has y-coordinate y and \(\Delta (\sigma _g)\) remains unchanged, such that \(\langle R,R'\rangle \) is a linear morph.

To achieve this goal, the y-coordinate of , for some vertex , may also change; however, the ratio with which cuts does not change, thus satisfying (ii) of Lemma 4.2. See Fig. 12 for an illustration. The y-coordinates of the horizontal sides are encoded by a new ADT-labeling \(\tau \) of G, and \(R'\) is the unique RT-representation \({{{\,\textrm{RT}\,}}(T,\tau ,R_o)}\) of G that is obtained by applying Lemma 3.6 with input G, T, \(\tau \), and the representation \(R_o\) of the outer face of G in R.

Fig. 12
figure 12

Moving down along . The gray triangles are not changed at all, the y-coordinates \(\tau \) of the bases of the light green triangles is adjusted such that the ratio with which the incident diagonal is cut is maintained. The y-coordinates of the bases of the light blue and light red triangles do not change—however their height (light blue) or width (light red) changes

For a vertex \(w\in V\), we let \(\text {top}(w)\) denote the y-coordinate of ; recall that, in our construction, we have \(\text {top}(w)=\tau (w_r)\), if w is an inner vertex. Also, let \(v_1,\dots ,v_\ell \) be the neighbors of w such that appear in this order from to along . For a fixed \(i \in \{1,\dots ,\ell \}\), we say that moving to \(y_0\in \mathbb {R}\) respects the order along if

  1. (i)

    \(i=1\) and \(\tau (w)\le y_0<\tau (v_2)\) (where equality is only allowed if does not lie on ),

  2. (ii)

    \(i=2,\dots ,\ell -1\) and \(\tau (v_{i-1})<y_0<\tau (v_{i+1})\), or

  3. (iii)

    \(i=\ell \) and \(\tau (v_{i-1}) < y_0 \le \text {top}(w)\) and \(y_0< \text {top}(v_\ell )\).

Further, for a vertex v, we consider the ratio \(\lambda (v)\) with which cuts the incident diagonal side, i.e., \(\lambda (v)=({\tau (v) - \tau (v_g)})/({\text {top}(v_g) - \tau (v_g)})\), if either v is an inner vertex or \(v \in \{X_b,X_r\}\), is on , and \(v_g:=X_g\).

For the vertex \(\sigma \) and the y-coordinate y that are part of the input of adjust, we assume that moving \(\sigma \) to y respects the order along . This allows to set \(\tau (\sigma )\leftarrow y\) without changing the contact point between and for any other vertex v such that \(v_g = \sigma _g\). On the other hand, setting \(\tau (\sigma )\leftarrow y\) may have other implications on the neighbors of \(\sigma \), as follows:

Type 1.:

For every vertex v such that \(\sigma = v_g\), the value of \(\tau (v)\) has to be modified to ensure that the ratio \(\lambda (v)\) with which cuts is maintained;

Type 2.:

for every vertex u such that \(\sigma = u_r\), we have to set \(\text {top}(u)=y\) to maintain the contact between \(\Delta (u)\) and \(\Delta (\sigma )\).

Let v and u be two vertices that have been modified according to Types 1 and 2, respectively. Since these modifications may change the diagonal side of \(\Delta (v)\) and \(\Delta (u)\), they may trigger analogous implications for the neighbors of v and u. Observe that, since the y-coordinate of is not changed, only a Type 1 implication may be triggered for the neighbors of u. Further, the two implications correspond to following either a red or a green edge, respectively, in reverse direction with respect to the one in T. Hence, the vertices whose triangles may need to be adjusted are those that can be reached from the vertex \(\sigma \) by a reversed directed path in T using only red and green edges, but no two consecutive red edges; see Fig. 13. Note that, since the green and the red edges have opposite orientation in T and in \({{\,\textrm{DAG}\,}}_b(T)\), which is acyclic, this implies that adjust terminates.

figure z

The procedure adjust (see Algortihm 1 for its pseudo-code and Fig. 12 for an illustration) first finds all the triangles that may need to be adjusted, by performing a simple graph search from \(\sigma \) following the above described paths of red and green edges. In a second pass, it performs the adjustment of each triangle \(\Delta (w)\), by modifying \(\tau (w)\) so that \(\lambda (w)\) is maintained for \(w\ne \sigma \). We ensure that the new value of \(\tau (w)\) is computed only after the triangle \(\Delta (w_g)\) has already been adjusted.

Lemma 5.2

Let \(R_1\) be an RT-representation of a plane triangulation \(G=(V,E)\) corresponding to the Schnyder wood T and let the y-coordinate of be \(\tau _1(v)\), \(v \in V\). Let \(\sigma \in V\) be an inner vertex and let \(y\in \mathbb {R}\) be such that moving \(\sigma \) to y respects the order along . Let \(\tau _2\) be the output of \(\textsc {adjust} (\tau _1,T,\sigma ,y)\). The following conditions hold.

  1. (i)

    \(\tau _2(\sigma )=y\).

  2. (ii)

    \(\lambda (v)\) is maintained for any vertex \(v \ne \sigma \).

  3. (iii)

    \(\tau _2 \) is an ADT-labeling of \({{\,\textrm{DAG}\,}}_r(T)\).

  4. (iv)

    The morph between \(R_1\) and \(R_2={{\,\textrm{RT}\,}}(T,\tau _2,R_o)\) is linear, where \(R_o=\Delta _1(X_b)\cup \Delta _1(X_g)\cup \Delta _1(X_r)\).

Proof

The fact that \(\tau _2(\sigma )=y\) and that \(\lambda (v)\) is maintained for any vertex \(v \ne \sigma \) follows by construction. This establishes conditions (i) and (ii). To prove that \(\tau _2\) is an ADT-labeling, condition (iii), we first determine a cycle \(C'\) bounding a subgraph of G containing all the vertices whose \(\tau \) might be modified by procedure adjust (see Fig. 13). We then prove condition (iii) by induction on a suitable ordering of the edges in \({{\,\textrm{DAG}\,}}_r(T)\). We finally exploit Lemma 4.2 to establish that \(\langle R_1,R_2\rangle \) is a linear morph, i.e., condition (iv. \(\square \)

Fig. 13
figure 13

Let u be the neighbor of \(\sigma \) following \(\sigma _g\) in clockwise order. Then, the cycle \(C'\) composed of the blue u-\(X_b\)-path \(p_b\), the edge \(\{u\),\(\sigma \}\), the red \(\sigma \)-\(X_r\)-path \(p_r\), and the edge \(\{X_r,X_b\}\) encloses all vertices for which \(\tau \) is changed. Vertex \(\sigma \) is the only vertex on \(C'\) for which \(\tau \) is changed

A cycle \(\mathbf {C'}\) enclosing all vertices where \(\tau \) might change. Let u be the neighbor of \(\sigma \) following \(\sigma _g\) in clockwise order around \(\sigma \). Observe that either \(\sigma =u_r\) or \(u=\sigma _b\). Consider the blue u-\(X_b\)-path \(p_b\) and the red \(\sigma \)-\(X_r\)-path \(p_r\) of G (see Fig. 13). Let \(C'\) be the cycle composed by \(X_b,p_b,u,\sigma ,p_r,X_r\). Let \(v\ne \sigma \) be a vertex such that \(\tau _2(v)\ne \tau _1(v)\). We claim that v lies in the interior of \(C'\). In fact, adjust sets \(\tau _2(v)\ne \tau _1(v)\) only if there exists in \({{\,\textrm{DAG}\,}}_b(T)\) a directed red-green-path p with no two consecutive red edges starting at \(\sigma \) and ending with a green edge at v. This is due to the fact that, when processing a vertex w, procedure adjust might choose to process a neighbor v of w only if T contains the green edge (vw) and then it might choose to process a neighbor u of v only if T contains the red edge (uv). Recall that green and red edges have opposite orientation in T and \({{\,\textrm{DAG}\,}}_b(T)\).

Note that p starts at \(\sigma \), which lies along \(C'\) and, after possibly reaching u via a red edge, it necessarily enters the interior of \(C'\) via a green edge. In the following steps p can reach again a vertex z of \(C'\); however this can only happen if z belongs to \(p_b\) and it is reached via a red edge. This implies that the next edge of p is green and hence p enters again the interior of \(C'\). Thus, v lies in the interior of \(C'\).

\(\tau _\textbf{2}\) is an ADT-labeling. If \(y=\tau _1(\sigma )\) then \(\tau _1 = \tau _2\) is an ADT-labeling. Otherwise, distinguishing the cases \(y<\tau _1(\sigma )\) and \(y>\tau _1(\sigma )\) we will prove by induction on a suitable ordering of the edges in \({{\,\textrm{DAG}\,}}_r(T)\) the following property.

  • Property DTL: \(\tau _2(v) \le \tau _2(w)\) for any edge (vw) of \({{\,\textrm{DAG}\,}}_r(T)\) where equality may only hold if

  1. (i)

    \(\tau _1(v) = \tau _1(w)\),

  2. (ii)

    \(w=\sigma \), \(v=\sigma _g\), and \(\langle \sigma ,\sigma _g,v_b\rangle \) is a clockwise oriented facial cycle in T, or

  3. (iii)

    \(v=\sigma =w_b\) and \(\langle w,\sigma ,\sigma _g\rangle \) is a counter-clockwise oriented facial cycle in T.

Fig. 14
figure 14

If the horizontal sides of the solid triangles are on one line in \(R_2\) then the two dashed triangles closing a counter-clockwise facial cycle with \((w,w_b)\) and a clockwise facial cycle with \((w,w_g)\), respectively, are distinct. Situation drawn with respect to \(R_1\)

This immediately establishes condition (i) of ADT-labeling for \(\tau _2\). In order to prove (ii), let \(e=(v,w)\) be an edge of \({{\,\textrm{DAG}\,}}_r(T)\) with \(\tau _2(v)=\tau _2(w)\). We have to show that the edge between v and w in the Schnyder wood T is green and belongs to a clockwise oriented facial cycle, or blue and belongs to a counter-clockwise oriented facial cycle. If \(\tau _1(v)=\tau _1(w)\), this follows immediately from the fact that \(\tau _1\) is an ADT-labeling of \({{\,\textrm{DAG}\,}}_r(T)\). Otherwise, conditions (ii) and (iii) of Property DTL immediately guarantee the right color of the edge and the right direction of the facial cycle. Recall that green and blue edges have different directions in T and in \({{\,\textrm{DAG}\,}}_r(T)\).

Finally, we have to prove that condition (iii) of an ADT-labeling is fulfilled. To this end, consider a vertex w with \(\tau _2(w_b)=\tau _2(w)=\tau _2(w_g)\) and let \(u_1\) and \(u_2\) be two vertices such that \(\langle w,w_g,u_1\rangle \) is a clockwise facial cycle and \(\langle w,w_b,u_2\rangle \) is a counter-clockwise facial cycle. We have to show that \(u_1\ne u_2\). If neither (ii) nor (iii) of Property DTL holds for the edges \((w_b,w)\) and \((w_g,w)\) of \({{\,\textrm{DAG}\,}}_r(T)\), i.e., if neither \(w=\sigma \) nor \(w_b=\sigma \), then condition (i) of Property DTL implies \(\tau _1(w_b)=\tau _1(w)=\tau _1(w_g)\). Since \(\tau _1\) is an ADT-labeling, it follows that \(u_1\ne u_2\). So assume that \(\sigma \in \{w,w_b\}\). We distinguish the last two cases of Property DTL (see Fig. 14).

Assume first that \(\sigma =w\) (condition (ii) of Property DTL) and the clockwise facial cycle incident to \((w,w_g)\) in T is \(\langle w,w_g,u_2\rangle =\langle \sigma ,\sigma _g,u_2\rangle \) for some vertex \(u_2\). This implies that \((\sigma _g,u_2)\) is blue, \((u_2,\sigma )\) is red, and \(y=\tau _2(\sigma )=\tau _2(w)=\tau _2(w_g)=\tau _2(\sigma _g)=\tau _1(\sigma _g)=\tau _1(w_g)\). Since in this case neither (ii) nor (iii) of Property DTL holds for the edge \((w_b,w)\) of \({{\,\textrm{DAG}\,}}_r(T)\), \(\tau _2(w_b)=\tau _2(w)\) implies \(\tau _1(w_b)=\tau _1(w)\). The vertex \(u_1\in V\) for which \(\langle w,w_b,u_1\rangle \) is a counter-clockwise facial cycle fulfills . Since moving \(\sigma \) to \(y=\tau _2(\sigma _g)=\tau _1(\sigma _g)\) respects the order along (condition (i)), it follows that is not on . Thus \(u_1\ne u_2\).

Assume now that \(\sigma =w_b\) (condition (iii) of Property DTL) and that \(\langle w,\sigma ,\sigma _g\rangle =\langle w,w_b,\sigma _g\rangle \) is the counter-clockwise oriented facial cycle in T incident to the edge \((w,w_b)\), i.e., \(u_1=\sigma _g\). In this case w and \(w_g\) are outside the cycle \(C'\) and, thus, \(\tau _1(w)=\tau _2(w)\) and \(\tau _1(w_g)=\tau _2(w_g)\). Since moving \(\sigma \) to \(y=\tau _2(\sigma )=\tau _2(w_b)=\tau _2(w)=\tau _1(w)=\text {top}(\sigma _g)\) respects the order along (condition (iii)), it follows that is not on and is strictly above . It follows that \(\tau _1(w) = \tau _2(w)=\tau _2(w_g) = \tau _1(w_g)\). Thus the clockwise facial cycle incident to \((w,w_g)\) is \(\langle w,w_g,u_2\rangle \) with . It follows that \(u_1 =\sigma _g\ne u_2\).

Fig. 15
figure 15

Property DTL in the case \(y < \tau (\sigma )\)

It remains to show Property DTL. In order to do so, we will use induction. Observe that for some already considered edge \(e=(v,w)\) of \({{\,\textrm{DAG}\,}}_r(T)\) the inductive hypothesis implies in particular that \(\tau _1(v) = \tau _1(w)\) if \(\tau _2(v) = \tau _2(w)\) unless \(w=\sigma \) and e is green, or \(v=\sigma \) and e is blue. This implies in particular that \(\tau _2(v) < \tau _2(w)\) if e is red.

  • Case \({y} < \tau _{1}(\sigma )\): Note that, in this case, procedure adjust does not increase \(\tau \) for any vertex, that is, \(\tau _2(v) \le \tau _1(v)\) for every vertex v. We use induction on the following lexicographical ordering of the edges of \({{\,\textrm{DAG}\,}}_r(T)\): Consider any ordering \(\prec \) extending the partial order given by \({{\,\textrm{DAG}\,}}_r(T)\). An edge \((v_1,w_1)\) is considered before an edge \((v_2,w_2)\) if \(w_1 \prec w_2\), or \(w_1 = w_2 =: w\) and \(v_1\) comes before \(v_2\) in the clockwise order around w starting from \((w_g,w)\).

    Let (vw) be an edge of \({{\,\textrm{DAG}\,}}_r(T)\). Since \(\tau _1\) is an ADT-labeling of \({{\,\textrm{DAG}\,}}_r(T)\), it follows that \(\tau _1(v) \le \tau _1(w)\). Moreover, \(\tau \) did not increase for any vertex. Thus, if \(\tau (w)\) does not change thenFootnote 4 for any descendant v of w. This is especially true if w is the first vertex with incoming edges with respect to \(\prec \), i.e., the first vertex after \(X_b\) and \(X_g\).

    Let now (vw) be an edge of \({{\,\textrm{DAG}\,}}_r(T)\) such that \(\tau (w)\) changes. Assume first that (vw) is a green edge, i.e., \(v=w_g\). There are two cases. Either \(w=\sigma \), and \(\tau _2(v) =\tau _2(\sigma _g) = \tau _1(\sigma _g) \le y = \tau _2(\sigma ) = \tau _2(w)\) (where equality is only allowed if is the bottommost corner on , and and are not both on the vertical side of the same triangle, i.e., if \(\langle \sigma ,\sigma _g,v_b\rangle \) is an oriented face in T). Or \(\tau (w)\) is changed according to the ratio on  and, thus, the relationship is maintained.

    Consider now the case that (vw) is an incoming red edge of w or an outgoing (in T) blue edge of w. Let \(v = v_0, v_1, \dots , v_k = w_g\) be the neighbors of w in counter-clockwise order from v to \(w_g\). Observe that \((v_i,w)\), \(i=1,\dots ,k-1\), (if any) are red. By induction, we have \(\tau _2(v_i) \le \tau _2(w)\), \(i=1,\dots ,k\). Observe further that for any \(i=1,\dots ,k\) either \((v_{i-1},v_{i})\) is a green edge or \((v_{i},v_{i-1})\) is a blue edge. See Fig. 15.

    Assume first that \(k=1\), i.e., \(v_1=w_g\). First observe that by induction, if \((w_g,v)\) is blue, and by construction, if \((v,w_g)\) is green. If \(w=\sigma \), then \(\tau _2(v)\le \tau _1(v)<y=\tau _2(\sigma )\), since moving to y must respect the order along \(w_g=\sigma _g\) and \(\tau _1(v)<\tau _1(w)\). If \(w\ne \sigma \) and \((v,w_g)\) is green, then both \(\tau (v)\) and \(\tau (w)\) have been modified according to the ratio on . Hence, the relationship \(\tau (v)<\tau (w)\) is maintained. Finally, if \((w_g,v)\) is blue then \(\tau _2(v) \le \tau _2(w_g) < \tau _2(w)\).

    If \(k\ge 1\) and \((v_{1},v)\) is blue, then we can apply the inductive hypothesis on both, \((v,v_1)\) and the red edge \((v_1,w)\), and get \(\tau _2(v) \le \tau _2(v_1) < \tau _2(w)\). Finally, if \(k>1\) and \((v,v_1)\) is green, then either \(\sigma =v\) or \(\tau (v)\) was set according to the ratio on , which implies especially that \(\tau _2(v) \le \tau _2((v_1)_r) = \tau _2(w)\) with equality if and only if \(\tau _1(v)=\tau _1(w)\).

  • Case \({y}>\tau _{1}(\sigma )\): Note that, in this case, procedure adjust does not decrease \(\tau \) for any vertex, that is, \(\tau _2(v)\ge \tau _1(v)\) for every vertex v. We use the following order for the induction. An edge \((v_1,w_1)\) is considered before an edge \((v_2,w_2)\) if \(v_2\prec v_1\), or \(v_1=v_2=:v\) and \(w_1\) comes before \(w_2\) in the counter-clockwise order around v starting from \((v,v_g)\).

    Note that \(y < \tau (X_r)\) and \(\tau \) is always updated according to the ratio on the incident diagonal. Thus, by induction on the order in which the vertices are processed it follows immediately that \(\tau _2(v) < \tau _2(X_r)\) for all vertices \(v \ne X_r\). Hence, this is especially true if v is the last vertex according to \(\prec \) before \(X_r\).

    Further, since \(\tau \) did not decrease for any vertex, if (vw) is an edge of \({{\,\textrm{DAG}\,}}_r(T)\) and \(\tau (v)\) was not changed, then we have . Assume now that \(w \ne X_r\) and that \(\tau (v)\) has changed.

    If (vw) is a green edge in \({{\,\textrm{DAG}\,}}_r(T)\), i.e., if \(v=w_g\) then \(\tau (w)\) is changed accordingly to the ratio on the diagonal of \(\Delta (v)\). Thus, the relationship is maintained.

    Consider now the case that (vw) is an outgoing red edge of v or an incoming (in T) blue edge of v. Let \(w = w_0, w_1, \dots , w_k=v_g\) be the neighbors of v in clockwise order from w to \(v_g\)—where \(k=1\) is possible. Observe that \((w_i,v)\), \(i=1,\dots ,k-1\), (if any) are blue. See Fig. 16. Observe further that for any \(i=1,\dots ,k\) either \((w_{i-1},w_{i})\) is a green edge or \((w_{i},w_{i-1})\) is a red edge.

    If \(k=1\) and \(v=\sigma \) then \(\tau _2(v)=y\le \tau _1(w)\le \tau _2(w)\), where \(y=\tau _1(w)\) is only possible if (wv) is blue and \((v_g,w)\) is red. We distinguish four more cases: (\(k=1\) and \(v\ne \sigma \)) and \(k>1\) and for each of them whether the edge between w and \(w_1\) is green or red. We start with \(k=1\): If \((w,v_g)\) is red then \(\tau _2(v) \le \tau _2((v_g)_r)=\tau _2(w)\) with equality if and only if \(\tau _1(v)=\tau _1((v_g)_r)\). If \((w,v_g)\) is green then w and v are both neighbors on and the relationship \(\tau (v) < \tau (w)\) is maintained.

    Consider now \(k>1\): Since \(w_i\), \(i=1,\dots ,k-1\) is before w in the counter-clockwise ordering around v after \(v_g\), we have by induction that \(\tau _2(v) \le \tau _2(w_1)\) with equality only if \(\tau _1(v) = \tau _1(w_1)\) or \(\langle v=\sigma ,v_g,w_1\rangle \) is a counter-clockwise cycle. If \((w_1,w)\) is red, we observe that \(v \prec w_1\) and we have again by induction that \(\tau _2(w_1) < \tau _2(w)\).

    If \((w,w_1)\) is green then the relationship is maintained (even if \(w=\sigma \), since \(\tau \) does not decrease). It follows that \(\tau _2(v) \le \tau _2(w_1) \le \tau _2(w)\). Observe that if \(\langle v=\sigma ,v_g,w_1\rangle \) is a counter-clockwise cycle and \(\tau _1(w_1) = \tau _1(w)\), then \(\tau _2(v) = y < \tau _1(v_r) = \tau _1(w) = \tau _1(w_1) = \tau _2(w_1) = \tau _2(w)\) since moving \(\sigma \) to y respects the order along (condition (iii)). Thus, \(\tau _2(v) = \tau _2(w)\) only if \(\tau _1(v) = \tau _1(w)\).

Thus, in both cases, we have that Property DTL holds. This completes the proof that \(\tau _2\) is an ADT-labeling (condition (iii)).

Fig. 16
figure 16

Property DTL in the case \(y > \tau (\sigma )\)

. Observe that all descendants of \(\sigma _g\) in \({{\,\textrm{DAG}\,}}_r(T)\) are on the blue path \(p_b\) or in the exterior of the cycle \(C'\). Further, observe that the horizontal sides of the vertices in \(p_b\) can be constructed without knowing anything about the interior of \(C'\). Thus does not change. Since \((\sigma _g)_r\) is also in the exterior of \(C'\) or on \(C'\) it follows that also the height of \(\Delta (\sigma _g)\) remains unchanged. Thus is not changed.

\(\langle R_1,R_2\rangle \) is a linear morph. Case (i) in Lemma 4.2 is always fulfilled if the side is vertical or horizontal. Thus it suffices to consider the diagonal sides. The only vertex v for which the ratio \(\lambda (v)\) changed was \(v=\sigma \). However, since did not change it follows that and are parallel. Thus, Lemma 4.2 implies that \(\langle R_1,R_2\rangle \) is a linear morph. \(\square \)

5.2 A Flipping Algorithm

Recall that, given a Schnyder wood T and an oriented triangle C in T, the Schnyder wood \(T_C\) is obtained from T by flipping C. In the following theorem we show how to realize this flip geometrically with two linear morphs in the case in which C is a facial cycle.

Theorem 5.3

Let \(R_1\) be a non-degenerate RT-representation of a plane triangulation G corresponding to a Schnyder wood T. Let C be an oriented facial cycle in T. We can construct a sequence of two linear morphs \(\langle R_1,R_2,R_3\rangle \) such that \(R_3\) is a non-degenerate RT-representation of G corresponding to a Schnyder wood \(T_C\).

Proof

For the oriented facial cycle C, let \(C_r\), \(C_g\), and \(C_b\) be the vertices with outgoing red, green, and blue edge, respectively, in C. In order to flip C, we move \(C_g\) along the respective incident diagonal sides as sketched in the following figure.

More precisely, let \(\tau _1\) be the y-coordinates of the horizontal sides in \(R_1\). We first compute \(\tau _2\leftarrow \textsc {adjust}(\tau _1,T,C_g,\tau _1(C_b))\). If C is clockwise oriented, we then compute

$$\begin{aligned} \tau _3\leftarrow \textsc {adjust}\biggl (\tau _2,T_C,C_g,\frac{\tau _2(C_g) +\max {\{\tau _2(u):u=C_r\ \text {or}\ u_g = C_r\}}}{2}\biggr ). \end{aligned}$$

If C is counter-clockwise oriented, we proceed as follows.

$$\begin{aligned} \tau _3\leftarrow \textsc {adjust} \biggl (\tau _2,T_C,C_g,\frac{\tau _2(C_g) + \min {\{\tau _2(u):u=(C_b)_r\ \text {or}\ u_g = C_b\}}}{2}\biggr ). \end{aligned}$$

In each case the new y-coordinates y for \(C_g\) are chosen such that moving \(C_g\) to y respects the order along the respective incident diagonal. Thus, adjust can be applied. Also, \(\tau _2\) is an ADT-labeling of both, \({{\,\textrm{DAG}\,}}_r(T)\) and \({{\,\textrm{DAG}\,}}_r(T_C)\), and \(\tau _3\) is an ADT-labeling of \({{\,\textrm{DAG}\,}}_r(T_C)\). Let \(R_2={{\,\textrm{RT}\,}}(T,\tau _2,R_o)={{\,\textrm{RT}\,}}(T_C,\tau _2, R_o)\) and let \(R_3={{\,\textrm{RT}\,}}(T_C, \tau _3,R_o)\). Since \(\tau _2\) and \(\tau _3\) are produced by adjust, by Lemma 5.2, both \(\langle R_1,R_2\rangle \) and \(\langle R_2,R_3\rangle \) are linear morphs. \(\square \)

5.3 Morphing Representations with the Same Schnyder Wood

In this section, we consider RT-representations corresponding to the same Schnyder wood.

Theorem 5.4

Let \(R_1\) and \(R_2\) be two RT-representations of an n-vertex plane triangulation corresponding to the same Schnyder wood T. Then, there is a piecewise linear morph between \(R_1\) and \(R_2\) of length at most 2n.

The idea is to first transform the outer face to a canonical form, and then to move one vertex v per step to a new y-coordinate y such that the ratio \(\lambda (v)\) is set to how it should be in \(R_2\). The order in which we process the vertices is such that \(\textsc {adjust}\) can be applied to the vertex v and the y-coordinate y. Recall that adjust does not alter the ratio \(\lambda \), except for the currently processed vertex v.

Lemma 5.5

Let \(P=\{p_1< \ldots < p_n\}\) and \(Q=\{q_1< \ldots < q_n\}\) be two sets of n reals each. If \(P \ne Q\) then there is an \(i \in \{1, \dots , n\}\) such that \(p_i \ne q_i\) and P has no element between \(p_i\) and \(q_i\).

Proof

We prove the lemma by induction on n. There is nothing to show if \(n=1\). If \(n>1\) and P and Q only differ in the last element \(p_n\) and \(q_n\) then let \(i=n\). Otherwise, we apply the inductive hypothesis to \(P\setminus \{p_n\}\) and \(Q\setminus \{q_n\}\) which yields \(p_i\ne q_i\), \(i < n\), such that no element of \(P \setminus \{p_n\}\) is between \(p_i\) and \(q_i\). If \(p_n\) is not between \(p_i\) and \(q_i\) we are done. Otherwise we have \(\ldots< p_i< \ldots< p_n< \ldots< q_i< \ldots < q_n\). Thus, \(p_n\ne q_n\) and no element of P can be between \(p_n\) and \(q_n\). \(\square \)

Corollary 5.6

Let P and Q each be a set of n points on a segment s. We can move P to Q in n steps by moving one point per step and by maintaining the ordering of the points on s.

Proof of Theorem 5.4

Let \(\tau '\) be a topological ordering of the inner vertices of \({{\,\textrm{DAG}\,}}_r(T)\). We extend \(\tau '\) to an ADT-labeling of \({{\,\textrm{DAG}\,}}_r(T)\) by setting \(\tau '(X_b)=0=\tau '(X_g)\), and \(\tau '(X_r)=n-2\). With a sequence of at most n linear morphs we transform \(R_i\), \(i=1,2\), into an RT-representation \(R'={{\,\textrm{RT}\,}}(T,\tau ',R_o)\), where \(R_o\) has the following canonical form: , , , and each of and  has length one. In the first morph, we cut the extruding parts of the outer triangles. In the second morph, we independently scale the x- and y-coordinates of the corners and translate the drawing, to fit the corners as indicated. In the third step, we adjust the lengths of and . In the first morph the slope of no side is changed, in the second morph no ratio is changed, and in the third morph there are only four sides that are changed, which are not incident to any other triangle. Thus, by Lemma 4.2, the three morphs are linear. Let the resulting RT-representation be \(R_i'\).

We now process the vertices in a reversed topological ordering on \({{\,\textrm{DAG}\,}}_b(T)\). This will ensure that once a vertex has been processed, it will not be modified by adjust anymore; this is because the vertices modified by adjust are determined by the red and green edges, which are both reversed in \({{\,\textrm{DAG}\,}}_b(T)\). We process a vertex w as follows. Let \(\tau \) be the function describing the current y-coordinates of the horizontal sides. Let \({\mathcal {G}}(w) = \{v \in V:w=v_g\}\) and let \(P = \{\tau (v):v \in {\mathcal {G}}(w)\}\). For \(v \in {\mathcal {G}}(w)\), let y(v) be such that

$$\begin{aligned} \frac{y(v)-\tau (w)}{\tau (w_r)-\tau (w)}=\frac{\tau '(v)-\tau '(w)}{\tau '(w_r)-\tau '(w)}, \end{aligned}$$

i.e., placing , \(v \in \mathcal G(w)\), on the y-coordinate y(v) cuts with the same ratio as in \(R'\). Let \(Q=\{y(v):v \in \mathcal G(w)\}.\) By Corollary 5.6, we can order \(\mathcal {G}(w)=\{v_1,\dots ,v_k\}\) such that replacing in the ith step \(\tau (v_i)\) by \(y(v_i)\) maintains the ordering of \(\{\tau (v):v \in \mathcal {G}(w)\}.\) Since \(\tau '\) is a topological ordering, we will not move to an end vertex of . For \(i=1,\dots ,k\) we now call \(\tau \leftarrow \textsc {adjust} (\tau ,T,v_i,y(v_i))\). By Lemma 5.2, each such call yields a single linear morph.

After processing all vertices w in a reversed topological ordering of \({{\,\textrm{DAG}\,}}_b(T)\) and all vertices in \({\mathcal {G}}(w)\) in the order given above, we have obtained an RT-representation R in which any right corner cuts its incident diagonal with the same ratio as in \(R'\). Since the outer face is fixed, this implies that \(R=R'\). Observe that \({\mathcal {G}}(w)\), \(w \in V\), is a partition of the set of inner vertices. Hence, we get at most one morphing step for each of the \(n-3\) inner vertices. This ends the proof.\(\square \)

Combining the results of Sects. 5.1, 5.2, and 5.3 yields the main result of the section.

Proof of Theorem 5.1

First, we transform \(R_1\) into a non-degenerate RT-representation R with Schnyder wood \(T_1\) and a canonical form of the outer face in \({\mathcal {O}}(n)\) linear morphing steps, by Theorem 5.4. Then, we perform the \(\ell \) facial flips. As described in Theorem 5.3, we can do so using two linear morphs for each flip. This yields an RT-representation \(R'\) with Schnyder wood \(T_2\). Finally, we transform \(R'\) into \(R_2\) in \({\mathcal {O}}(n)\) linear morphing steps, by Theorem 5.4. This yields a total of \({\mathcal {O}} (n+\ell )\) linear morphs. Each linear morph can be computed by one application of \(\textsc {adjust}\), which runs in linear time. \(\square \)

6 Finding a Sequence of Facial Flips

It follows from Theorems 3.4 and 5.1 that there is a piecewise linear morph between two RT-representations of a plane triangulation if and only if the respective Schnyder woods can be obtained from each other by flipping internal faces only. Note that this condition is always satisfied if the triangulation is 4-connected and the topmost vertex is the same in both RT-representations. On the other hand, if the graph contains separating triangles, we have to decide whether there is such a sequence of facial flips. We will show in Lemma 6.3 that this can be decided efficiently and that, in the positive case, there exists a sequence whose length is at most quadratic in the number of vertices. In the proof of Lemma 6.4, we then show how such a sequence of facial flips can also be computed in quadratic time. With the run time from Theorem 5.1, this establishes our final result.

Theorem 6.1

Let \(R_1\) and \(R_2\) be two RT-representations of an n-vertex plane triangulation. We can decide in \({\mathcal {O}}(n^2)\) time whether there is a morph between \(R_1\) and \(R_2\) and, if so, a piecewise linear morph with \({\mathcal {O}}(n^2)\) linear morphing steps can be computed in \({\mathcal {O}}(n^3)\) time.

Corollary 6.2

There is a piecewise linear morph with \({\mathcal {O}}(n^2)\) linear morphing steps between two RT-representations of a 4-connected plane triangulation if and only if the topmost vertex is the same in both RT-representations.

Since there is a one-to-one correspondence between Schnyder woods of a plane triangulation and its 3-orientations, we will omit the colors in the following. A careful reading of Brehm [17] and Felsner [29] reveals the subsequent properties of 3-orientations. The set of 3-orientations of a triangulation forms a distributive lattice with respect to the following ordering. \(T_1\le T_2\) if and only if \(T_1\) can be obtained from \(T_2\) by a sequence of flips on some counter-clockwise triangles. The minimum element is the unique 3-orientation without counter-clockwise cycles. Moreover, given a 3-orientation T and a triangle t, the number of occurrences of t in any flip-sequence between T and the minimum 3-orientation is the same—provided that the flip sequence contains only counter-clockwise triangles. Let this number be the potential \(\pi _T(t)\). See Fig. 17 for an example.

Fig. 17
figure 17

The lattice of all 3-orientations of a graph. The whole graph is only drawn in the minimum 3-orientation. The dashed edges are not repeated in the other drawings—they do not change their direction. Face labels indicate potentials. Observe that the inner solid face is actually a separating triangle (there are not-drawn dashed edges inside)

Fig. 18
figure 18

RT-representations corresponding to orientations I, II, and III of Fig. 17, which are not morphable one into the other

Observe that \(\pi _T\) is distinct for distinct T. Moreover, given a triangle t, the potential of the meet \(T_1\wedge T_2\) (i.e., the infimum) of two 3-orientations \(T_1\) and \(T_2\) is \(\min (\pi _{T_1}(t),\pi _{T_2}(t))\) while the potential of the join \(T_1\vee T_2\) (i.e., the supremum) of \(T_1\) and \(T_2\) is \(\max (\pi _{T_1}(t),\pi _{T_2}(t))\). The potential \(\pi _{T}\) can be computed in quadratic time for a fixed 3-orientation T of an n-vertex triangulation: At most \({\mathcal {O}}(n^2)\) flips have to be performed in order to reach the minimum 3-orientation. With a linear-time preprocessing, we can store all initial counter-clockwise triangles in a list. After each flip, the list can be updated in constant time.

Lemma 6.3

Let \(T_1\) and \(T_2\) be two 3-orientations of an n-vertex triangulation. \(T_1\) can be obtained from \(T_2\) by a sequence of facial flips if and only if \(\pi _{T_1}(t)-\pi _{T_2}(t)=0\) for all separating triangles t. Moreover, if \(T_1\) can be obtained from \(T_2\) by a sequence of facial flips, then any sequence of counter-clockwise flips between \(T_1\) and the meet \(T_1\wedge T_2\) followed by any sequence of clockwise flips to \(T_2\) consists of \({\mathcal {O}}(n^2)\) facial flips.

Proof

Observe that going from \(T_1\) to the meet \(T_1 \wedge T_2\) involves

$$\begin{aligned} \pi _{T_1}(t) - \min (\pi _{T_1}(t),\pi _{T_2}(t)) \in \{0,\pi _{T_1}(t)-\pi _{T_2}(t)\} \end{aligned}$$

counter-clockwise flips on triangle t, and going from the meet \(T_1 \wedge T_2\) to \(T_2\) involves

$$\begin{aligned} \pi _{T_2}(t) - \min (\pi _{T_1}(t),\pi _{T_2}(t)) \in \{0,\pi _{T_2}(t)-\pi _{T_1}(t)\} \end{aligned}$$

clockwise flips on triangle t. Thus, if \(\pi _{T_1}(t) - \pi _{T_2}(t) = 0\) for all separating triangles t, then no flip must be performed on a separating triangle. Then, the total number of flips is bounded by \(\sum _{t\ face }(\pi _{T_1}(t) + \pi _{T_2}(t))\in {\mathcal {O}}(n^2)\).

Assume now that there is a sequence \(T_1=T_0',T_1',\dots ,T_\ell ',T_{\ell +1}'=T_2\) of 3-orientations such that \(T_{i+1}'\), \(i=0,\dots ,\ell \), is obtained from \(T'_i\) by a (clockwise or counter-clockwise) facial flip. We show by induction on \(\ell \) that \(\pi _{T_1}(t) - \pi _{T_2}(t)=0\) for all separating triangles t. If \(\ell =0\), let \(t_0\) be the triangle that has to be flipped in order to go from \(T_1\) to \(T_2\). Then, \(t_0\) is a face and \(\pi _{T_1}(t) - \pi _{T_2}(t) = 0\) for \(t \ne t_0\). Assume now that \(\ell \ge 1\). Let t be a separating triangle. Then

$$\begin{aligned} \pi _{T_1}(t) - \pi _{T_2}(t)= \underbrace{\pi _{T_1}(t) - \pi _{T'_\ell }(t)}_{=\,0\, by IH } + \underbrace{\pi _{T'_\ell }(t) - \pi _{T_2}(t)}_{=\ 0 \ by IH } = 0. \end{aligned}$$

\(\square \)

While a sequence of counter-clockwise flips from a 3-orientation \(T_1\) to the minimum of the lattice can always be found by iteratively flipping any counter-clockwise triangle, this is no longer true if we want to find a path from \(T_1\) to the meet \(T_1 \wedge T_2\) of two 3-orientations \(T_1\) and \(T_2\). Here we have to follow the potential difference:

Lemma 6.4

Let \(T_1\) and \(T_2\) be two 3-orientations of an n-vertex triangulation. If \(T_2\) can be obtained from \(T_1\) by a sequence of facial flips then such a sequence can be computed in \(\mathcal O(n^2)\) time.

Proof

We construct the sequence of facial flips as follows: Starting with \(T_1\) we first find a sequence of flips down to the meet and then up again to \(T_2\). By the proof of Lemma 6.3, this sequence consists of facial flips only. Since \(\pi _{T_1\wedge {T}_2}(t)=\min (\pi _{T_1}(t),\pi _{T_2}(t))\) for all facial triangles and since distinct 3-orientations have distinct potentials, such a path can be found as follows.

Let \(T=T_1\). While \(\pi _T(t) > \pi _{T_2}(t)\) for some counter-clockwise facial cycle t, pick such a cycle and flip it. Now \(T= T_1 \wedge T_2\). While \(\pi _T(t) < \pi _{T_2}(t)\) for some clockwise facial cycle t, pick such a cycle and flip it.

At most \({\mathcal {O}}(n^2)\) flips have to be performed to reach the meet. In the first while-loop, we only store the counter-clockwise facial cycles with \(\pi _T(t) > \pi _{T_2}(t)\) in a list and in the second while-loop the clockwise facial cycles with \(\pi _T(t) < \pi _{T_2}(t)\). This list can still be updated in constant time after each flip. \(\square \)

Observe that there might be a piecewise linear morph between two RT-representations even though a separating triangle in the respective Schnyder woods is oriented in opposite directions. E.g., consider the 3-orientations II and III of the graph in Figs. 17 and 18. Moreover, there might be two RT-representations such that any separating triangle is oriented in the same way in the two respective Schnyder woods, however, there is no piecewise linear morph between the two representations. E.g., consider the 3-orientations III and I of the graph in Figs. 17 and 18, every path in the lattice between them passes through a 3-orientation in which the unique separating triangle is flipped.

7 Conclusions and Open Problems

In this paper, we initiated the study of morphs between contact representations of graphs. In particular, we have studied morphs between RT-representations of plane triangulations. We have shown that if such a morph exists, then there is a piecewise linear morph of length \(\mathcal {O}(n^2)\). It would be interesting to explore lower bounds on the length of a piecewise linear morph. Observe that the worst-case minimum length of a flip sequence containing only facial cycles does not have to be a lower bound for the length of a piecewise linear morph, since some flips could be parallelized. Additionally, bounds on the resolution throughout our morphs would be worth investigating; however, it is unclear whether the “ratio fixing” we use in the procedure adjust would allow nice bounds. A major open direction is whether our results can be lifted to general plane graphs, e.g., through the use of compatible triangulations [11, 51]. Note that such compatible triangulations would need to be formed while preserving the conditions for the existence of a morph, i.e., without introducing the need to flip a separating triangle.

Finally, beyond the context of RT-representations, many other families of geometric objects could be considered. For example, morphing degenerate contact representations of line segments generalizes planar morphing, by treating contact points as vertices.