1 Introduction

Continuous morphs of planar drawings have been studied for many years, starting as early as 1944, when Cairns [7] showed that there exists a planarity-preserving continuous morph between any two (compatible) triangulations that have the same outer triangle. These results were extended by Thomassen [10] in 1983, who gave a constructive proof of the fact that two compatible straight-line drawings can be morphed into each other while maintaining planarity. The resulting algorithm to compute such a morph takes exponential time (just as Cairns’ result). Thomassen also considered the orthogonal setting and showed how to morph between two rectilinear polygons with the same turn sequence. For planar straight-line drawings the question was settled by Alamdari et al.  [1], following work by Angelini et al.  [3]. They showed that O(n) uni-directional linear morphs are sufficient to morph between any compatible pair of planar straight-line drawings of a graph with n vertices while preserving planarity. The corresponding morph can be computed in \(O(n^3)\) time.

In this paper we consider the orthogonal setting, that is, we study planarity-preserving morphs between two planar orthogonal drawings \(\varGamma _I\) and \(\varGamma _O\) with maximum complexity n, of a graph G. Here the complexity of an orthogonal drawing is defined as the number of vertices and bends. All intermediate drawings must remain orthogonal, as to not disrupt the mental map of the reader. This immediately implies that the results of Alamdari et al.  [1] do not apply, since they do not preserve orthogonality. Biedl et al.  [5] described the first results in this setting, for so-called parallel drawings, where every edge has the same orientation in both drawings. They showed how to morph between two parallel drawings using O(n) linear morphs while maintaining parallelity and planarity. More recently, Biedl et al.  [4] showed how to morph between two planar orthogonal drawings using \(O(n^2)\) linear morphs, while preserving planarity, orthogonality, and linear complexity. Van Goethem and Verbeek [12] improved this bound further to O(n) linear morphs for a connected graph G. This bound is tight, based on the lower bound for straight-line graphs proven by Alamdari et al.  [1].

If the graph G is disconnected, then Aloupis et al.  [2] show how to connect G in a way that is compatible with both \(\varGamma _I\) and \(\varGamma _O\) while increasing the complexity of the drawings to at most \(O(n^{1.5})\). They also prove a matching lower bound if G has at most \(\frac{n}{4}\) connected components. This directly implies that Van Goethem and Verbeek require \(O(n^{1.5})\) linear morphs for a disconnected graph G.

Paper Outline. We show how to refine the approach by Van Goethem and Verbeek [12] to also morph between two planar orthogonal drawings of a disconnected graph G using O(n) linear morphs while preserving planarity, orthogonality, and linear complexity. In Sect. 2 we describe the necessary background. In particular, we discuss wires: equivalent sets of horizontal and vertical polylines that capture the x- and y-order of the vertices in \(\varGamma _I\) and \(\varGamma _O\). The spirality of these wires guides the morph. In Sect. 3 we show how to find sets of wires with linear spirality for equivalent orthogonal planar drawings \(\varGamma _I\) and \(\varGamma _O\) of a disconnected planar graph G. Van Goethem and Verbeek are agnostic of the connectivity of the graph once they create the wires. Hence, using the wires constructed in Sect. 3, we can directly apply their approach to disconnected graphs.

In the remainder of the paper we show how to “batch” intermediate morphs. We argue solely based on sets of wires, hence the results apply to both connected and disconnected graphs. In particular, in Sect. 4 we show how to combine all intermediate morphs that act on segments of spirality s into one single linear morph. Hence we need only s linear morphs to morph from \(\varGamma _I\) to \(\varGamma _O\). However, the rerouting and simplification operations introduced by van Goethem and Verbeek to lower the intermediate complexity are not compatible with batched linear morphs and hence intermediate drawings have complexity of \(O(n^3)\). In Sect. 5 we present refined versions of both operations which allow us to maintain linear complexity through the s linear morphs. The initial setup for these operations costs one additional morph, for a total of \(s+1\) linear morphs that preserve planarity, orthogonality, and linear complexity. We implemented our algorithm and believe that the resulting morphs are natural and visually pleasingFootnote 1. We restrict our arguments to proof sketches, all omitted details can be found in the full version [11].

2 Preliminaries

Orthogonal Drawings. A drawing \(\varGamma \) of a graph \(G=(V,E)\) is a mapping from every vertex \(v\in V\) to a unique point \(\varGamma (v)\) in the Euclidean plane and from each edge (uv) to a simple curve in the plane starting at \(\varGamma (u)\) and ending at \(\varGamma (v)\). A drawing is planar if no two curves intersect in an internal point, and no vertices intersect a curve in an internal point. A drawing is orthogonal if each edge is mapped to an orthogonal polyline consisting of horizontal and vertical segments meeting at bends. In a straight-line drawing every edge is represented by a single line-segment. Two planar drawings \(\varGamma \) and \(\varGamma '\) are equivalent if there exists a homeomorphism of the plane that transforms \(\varGamma \) into \(\varGamma '\).

We consider morphs between two equivalent drawings of a graph G. To simplify the presentation, we assume that both drawings are straight-line drawings with n vertices. If this is not the case then we first unify \(\varGamma \) and \(\varGamma '\). We subdivide segments, creating additional virtual bends, to ensure that every edge is represented by the same number of segments in \(\varGamma \) and \(\varGamma '\). Next, we replace all bends with vertices. All edges of the resulting graph \(G^*\) are now represented by straight segments (horizontal or vertical) in both \(\varGamma \) and \(\varGamma '\).

Fig. 1.
figure 1

Two unified drawings \(\varGamma _I\) and \(\varGamma _O\) of G (black) plus equivalent wires (red/blue). (Color figure online)

A linear morph of two drawings \(\varGamma \) and \(\varGamma '\) can be described by a continuous linear interpolation of all vertices and bends, which are connected by straight segments. For each \(0\le t\le 1\) there exists an intermediate drawing \(\varGamma _t\) where each vertex v is drawn at \(\varGamma _t(v)=(1-t)\varGamma _v + t\varGamma '_v\) (\(\varGamma _0 = \varGamma \) and \(\varGamma _1 = \varGamma '\)). A linear morph maintains planarity (orthogonality, linear complexity, resp.), if every intermediate drawing \(\varGamma _t\) is planar (orthogonal, of linear complexity, resp.).

Wires. Following van Goethem and Verbeek [12] we use orthogonal polylines called wires as the main tool to determine the morph. Wires consist of horizontal or vertical segments called links. We use two sets of wires to capture the horizontal and vertical order of the vertices in \(\varGamma _I\) and \(\varGamma _O\). The lr-wires \(W_\rightarrow \) traverse the drawings from left to right, and the tb-wires \(W_\downarrow \) traverse the drawings from top to bottom. Since the horizontal and vertical order of the vertices in \(\varGamma _O\) are guiding our morph, the wires \(W_\rightarrow \) and \(W_\downarrow \) are simply horizontal and vertical lines in \(\varGamma _O\) separating consecutive vertices in the x- and y-order (only if their x- or y-coordinates are distinct). \(\varGamma _O\) and \(\varGamma _I\) are equivalent, hence there exist wires in \(\varGamma _I\) that are equivalent to the wires in \(\varGamma _O\): there is a one-to-one matching between the wires of \(\varGamma _O\) and \(\varGamma _I\) such that matching wires partition the vertices identically, and cross both the segments of the drawings and the links of the other wires in the same order (see Fig. 1). Any such two wires in \(\varGamma _I\) do not cross if they are from the same set and cross exactly once otherwise.

Van Goethem and Verbeek use the spirality of wires as a measure for the distance to \(\varGamma _O\) (where all wires are straight lines of spirality zero). Spirality is a well-established measure in the context of orthogonal drawings and is frequently used for bend-minimization [6, 8, 9]. Specifically, let \(w\in W_\rightarrow \) be a lr-wire, and \(\ell _1,\ldots ,\ell _k\) be the links ordered along w. Let \(b_i\) be the orientation of the bend from \(\ell _i\) to \(\ell _{i+1}\), where \(b_i=1\) for a left turn, \(b_i=-1\) for a right turn, and \(b_i=0\) otherwise. The spirality of a link \(\ell _i\) is defined as \(s(\ell _i)=\sum _{j=1}^{i-1}b_i\). A maximum-spirality link is any link with the largest absolute spirality. The spirality of a wire is the maximum absolute spirality of any link in the wire, the spirality of a set of wires is the maximum spirality of any wire in the set.

The spirality of a drawing \(\varGamma \) is not well defined: it is always relative to another drawing \(\varGamma '\) and the straight-line wires induced by \(\varGamma '\). Furthermore, there are possibly multiple sets of matching wires in \(\varGamma \) for the straight-line wires in \(\varGamma '\). Still, whenever the drawing \(\varGamma '\) and the matching set of wires in \(\varGamma \) are clear from the context, then by abuse of notation we will speak of the spirality of \(\varGamma \). Unless stated otherwise, we always consider spirality relative to \(\varGamma _O\).

Fig. 2.
figure 2

A drawing (black) with vertices (open marks) and bends (closed marks). (a) A zigzag-eliminating slide with center link \(\overline{\beta \gamma }\). (b) Introducing two additional bends in a crossing segment ensures orthogonality. (c) A bend-introducing slide.

Slides. Biedl et al.  [4] introduced slides as a particular type of linear morph that operates on the segments of the drawing. Van Goethem and Verbeek [12] extended this concept to wires. Slides on wires may be accompanied by the insertion or deletion of bends in the drawing. In the following we exclusively consider slides on wires. A zigzag consists of three consecutive links of a wire and two bends \(\beta \) and \(\gamma \) that form a left turn followed by a right turn or vice versa. Consider the horizontal zigzag with bends \(\beta \) and \(\gamma \) in Fig. 2(a). Let \(\mathcal {V}\) be the set of vertices and bends of both the drawing and the wires that are (1) above or at the same height as \(\beta \) and strictly to the left of \(\beta \), (2) that are strictly above \(\gamma \), and (3) \(\beta \). The corresponding region is shaded in Fig. 2. A zigzag-eliminating slide is a linear morph that straightens a zigzag on a wire by moving all vertices and bends in \(\mathcal {V}\) up by the initial distance between \(\beta \) and \(\gamma \).

By definition, wires do not contain any vertices or bends of the drawing or other wires. However, the center link \(\overline{\beta \gamma }\) might be crossed by a segment of the drawing or a link of a wire in the other set (see Fig. 2(b) for a crossing with a segment of the drawing). In this case we introduce two virtual bends in the segment or the link on the crossing and symbolically offset one to the right and one to the left. The left bend is thus included in \(\mathcal {V}\) while the right bend is not. We can prevent that multiple segments or links cross \(\overline{\beta \gamma }\) using so-called bend-introducing slides as discussed in [12] (see Fig. 2(c)).

3 Linear Morphs for Disconnected Graphs

Let \(\varGamma _I\) and \(\varGamma _O\) be two equivalent planar orthogonal drawings of a disconnected graph G. For a connected graph there is a unique homotopy class in \(\varGamma _I\) that contains all possible wires that match a given wire w from \(\varGamma _O\). This statement does not hold for disconnected graphs: there might be more than one homotopy class in \(\varGamma _I\) that matches w (see Fig. 3(a)). If we choose homotopy classes independently for the wires in \(\varGamma _I\) then their union might not be equivalent to the set of wires in \(\varGamma _O\), for example, wires might cross more than once (see Fig. 3(c)).

Below we show that we can choose homotopy classes for the wires in \(\varGamma _I\) incrementally, first for the lr-wires and then for the tb-wires, while maintaining the correct intersection pattern and hence equivalence with \(\varGamma _O\). For each of the resulting equivalence classes we add the shortest wire to the set of wires. It remains to argue that the resulting set of wires has spirality O(n) despite the interdependence of the homotopy classes and the fact that the arrangement of drawing and wires can have super-linear complexity (which invalidates the proofs from [12]). Below we consider only \(W_\rightarrow \), analogous results hold for \(W_\downarrow \).

Fig. 3.
figure 3

(a) A (straight-line) wire w in \(\varGamma _O\) (red) and two possible wires in \(\varGamma _I\) from different homotopy classes that both match w. (b) A graph with three connected components. (c) Wires in \(\varGamma _I\) that cross three times. (d) Set of wires equivalent to \(\varGamma _O\). (Color figure online)

Lemma 1

For each right-oriented link \(\ell _\rightarrow \) of a wire \(w\in W_\rightarrow \) with positive (negative) spirality s there exists a vertical line L and a subsequence of \(\varOmega (|s|)\) links of w crossing L, such that the absolute spiralities of the links in sequence are \([0,2,4,\ldots ,|s|-2,|s|]\), and when ordered top-to-bottom (bottom-to-top) along L form the sequence \([2,6,10,\ldots , |s|-2,|s|,|s|-4,\ldots ,4,0]\).

Figure 4(a) illustrates Lemma 1. Let \(\ell _\rightarrow \) be a right-oriented link on a wire w and w.l.o.g. let \(s > 0\) be the spirality of w. Further, let L be a vertical line through \(\ell _\rightarrow \) and S a subsequence from w with the properties guaranteed by Lemma 1. Finally, let \(\ell ^i\in S\) be the unique link with spirality \(0\le i\le s\) in S. We define the i-core for S (for \(4\le i \le s\) and \(i\pmod 4=0\)) as the region enclosed by the wire w from the intersection between \(\ell ^{i-4}\) and L to the intersection between \(\ell ^i\) and L and the straight line segment along L connecting them (see Fig. 4(b)). We define the i-layer for S (for \(4\le i \le s-4\) and \(i\pmod 4=0\)) as the difference of the i-core and the \((i+4)\)-core (see Fig. 4(c)).

Fig. 4.
figure 4

(a) Lemma 1 for a link \(\ell _\rightarrow \) and sequence \(S=(\ell _3,\ell _5,\ell _{13},\ell {15},\ell _\rightarrow )\). (b) The i-core of a spiral for a link \(\ell ^i\in S\) (gray). (c) The i-layer of the spiral (gray). (d) A layer cannot only contain wires as then we can shorten all wires.

Lemma 2

An equivalent set of lr-wires with spirality O(n) exists.

Proof

(Sketch). We prove by induction that we can add a new lr-wire with spirality O(n). If a wire w has \(\omega (n)\) layers, then we can argue via shortcuts (see Fig. 4(d)) that w was not shortest with respect to previously inserted wires.    \(\square \)

Lemma 3

An equivalent set of wires with spirality O(n) exists.

Proof

(Sketch). By Lemma 2 we can insert all lr-wires with spirality O(n). By Lemma 2 from [12] the spirality of intersecting links is the same. Apply Lemma 2 for the tb-wires in the regions between the intersections with lr-wires.    \(\square \)

Theorem 1

Let \(\varGamma _I\) and \(\varGamma _O\) be two unified planar orthogonal drawings of a (disconnected) graph G. We can morph \(\varGamma _I\) into \(\varGamma _O\) using \(\varTheta (n)\) linear morphs while maintaining planarity and orthogonality.

Proof

By Lemma 3 an equivalent set of wires with spirality \(s=O(n)\) exists. By Theorem 8 from [12] we can thus morph the drawings into each other using \(O(s) = O(n)\) linear morphs. The lower bound of \(\varOmega (n)\) follows from [1].    \(\square \)

4 Combining Intermediate Linear Morphs

The proof of Theorem 1 implies a morph between two unified planar orthogonal drawings \(\varGamma _I\) and \(\varGamma _O\) exists using O(s) linear morphs, where s is the spirality of \(\varGamma _I\). In this section we show how to combine consecutive linear morphs into a total number of only s linear morphs, while maintaining planarity and orthogonality.

The morphs we describe can be encoded by a sequence of drawings, starting with \(\varGamma _I\) and ending with \(\varGamma _O\), such that every consecutive pair of drawings can be linearly interpolated while maintaining planarity and orthogonality. For notational convenience let indicate that \(\varGamma _i\) occurs before \(\varGamma _j\) during the morph and that or \(\varGamma _i = \varGamma _j\).

Let an iteration of the original morph consist of all linear slides that jointly reduce spirality by one. Let the first drawing of iteration s be the first drawing in the original morph with spirality s and the last drawing be the first drawing with spirality \(s-1\). Consecutive iterations overlap in exactly one drawing. These drawings in the overlap of iterations are the intermediate steps of the final morph. Within this section let , where \(\varGamma _a\) is the first drawing with spirality s and \(\varGamma _b\) is the first drawing with spirality \(s-1\).

4.1 Staircases

Consider two distinct vertices v and w of the drawing. Define an x-inversion (y-inversion) of v and w between \(\varGamma _a\) and \(\varGamma _b\) when the sign (\(+\),−,0) of \(v.x - w.x\) (\(v.y - x.y\)) differs in \(\varGamma _a\) and \(\varGamma _b\). We say two vertices are x-inverted (y-inverted), or simply inverted. Two vertices v and w are separated in a drawing by a link \(\ell \) when they are both in the vertical (horizontal) strip spanned by \(\ell \), and v and w are on opposite sides of \(\ell \).

Lemma 4

Two vertices v and w can be inverted by a zigzag-removing slide along link \(\ell \), if and only if v and w are separated by \(\ell \).

figure a

A downward staircase is a sequence of horizontal links where: (1) the left-endpoints are x-monotone increasing and y-monotone decreasing, (2) the projection on the x-axis is overlapping or touching for a pair if and only if they are consecutive in the sequence, and (3) all links have positive spirality. Two vertices v and w are separated by a downward staircase if v is in the vertical strip spanned by the first link of the staircase and above it and w is in the vertical strip spanned by the last link and below it. Similar concepts can be defined for upwards staircases and for vertical links.

Fig. 5.
figure 5

Regions surrounding \(\ell _s\) in \(\varGamma _{i-1}\) and the matching regions in \(\varGamma _i\).

Fig. 6.
figure 6

Sets \(\mathcal {S}_L\) and \(\mathcal {S}_R\) in \(\varGamma _a\) and \(\varGamma _b\).

Lemma 5

Two vertices v and w that are x-inverted (y-inverted) first during a morph from \(\varGamma _a\) to \(\varGamma _b\), are separated by a horizontal (vertical) staircase of maximum spirality links in \(\varGamma _a\).

Proof

(Sketch). Assume w.l.o.g. that only one inversion occurs and it occurs from \(\varGamma _{b-1}\) to \(\varGamma _b\). By Lemma 4, v and w are separated by a link \(\ell \) in \(\varGamma _{b-1}\). Link \(\ell \) must have maximum absolute spirality as it was selected for the morph. We now prove inductively that a staircase exists in all drawings from \(\varGamma _a\) to \(\varGamma _{b-1}\) by “moving backwards” through the morph. To this end we define four rectangular regions ABCD surrounding \(\ell _s\) in \(\varGamma _{i-1}\) (see Fig. 5). During the linear slide from \(\varGamma _{i-1}\) to \(\varGamma _i\) two new regions F and G are created, which cannot contain vertices. Using these rectangular regions and a case distinction on the type of linear slide, we can argue inductively that a staircase separating v and w must also exist in \(\varGamma _{i-1}\).    \(\square \)

4.2 Inversions

We show that every pair of vertices is inverted along at most one axis during the morph from \(\varGamma _a\) to \(\varGamma _b\). We then prove that \(\varGamma _a\) has spirality one relative to \(\varGamma _b\).

Lemma 6

Two vertices v and w can be inverted along only one axis during the morph from \(\varGamma _a\) to \(\varGamma _b\).

Lemma 7

Each vertical (horizontal) line in \(\varGamma _b\) not crossing a vertex, can be matched to a y- (x-)monotone wire in \(\varGamma _a\).

Proof

(Sketch). Consider a vertical line \(L_\downarrow \) in \(\varGamma _b\) not intersecting any vertex. Line \(L_\downarrow \) partitions the set of vertices and vertical edges in \(\varGamma _b\) into two subsets \(\mathcal {S}_L\) and \(\mathcal {S}_R\). Consider a horizontal line \(L_\rightarrow \) in \(\varGamma _a\) and consider the maximal intervals formed along it by elements from the same set \(\mathcal {S}_L\) or \(\mathcal {S}_R\) (see Fig. 6). Set \(\mathcal {S}_L\) and \(\mathcal {S}_R\) form exactly two maximal intervals along \(L_\rightarrow \). Thus a y-monotone line exists correctly splitting \(\mathcal {S}_L\) and \(\mathcal {S}_R\). We can show that this y-monotone line must intersect horizontal edges in the correct order as well.   \(\square \)

Lemma 8

Drawing \(\varGamma _a\) has spirality one relative to \(\varGamma _b\).

4.3 Single Linear Morph

We now show that any two planar orthogonal drawings \(\varGamma _i\) and \(\varGamma _j\), where \(\varGamma _i\) has spirality one relative to \(\varGamma _j\), can be morphed into each other using a single linear morph while maintaining planarity. Two drawings are shape-equivalent if for each edge the sequence of left and right turns is identical and the orientation of the initial segment is identical in both drawings. We say two drawings are degenerate shape-equivalent if edges may contain zero-length segments but an assignment of orientations to the segments exists that is consistent with both drawings. Two (degenerate) shape-equivalent drawings are per definition also unified. We can make \(\varGamma _a\) degenerate shape-equivalent to \(\varGamma _b\) by adding zero-length edges whenever maximum absolute spirality links in \(\varGamma _a\) cross an edge. We say two points p and q on the drawing are split by a wire when p and q lie on different sides of the wire.

Lemma 9

Let \(\varGamma _I\) and \(\varGamma _O\) be two degenerate shape-equivalent drawings, where \(\varGamma _I\) has spirality one. There exists a single linear morph from \(\varGamma _I\) to \(\varGamma _O\) that maintains planarity and orthogonality.

Proof

(Sketch). The partition of the drawing by all wires defines cells: regions of the plane not split by any wire. For each cell containing at least one bend or vertex, we can linearly interpolate all vertices and bends in \(\varGamma _I\) to the unique vertex or bend location in \(\varGamma _O\). This directly defines a linear morph between \(\varGamma _I\) and \(\varGamma _O\). To argue planarity of this morph, we assume for contradiction that there exist two points p and q on an edge or vertex of the drawing that coincide during the morph (excluding \(\varGamma _I\) and \(\varGamma _O\)). Then p and q must be x- and y-inverted in \(\varGamma _O\) compared to \(\varGamma _I\) and there must be two vertices r and s that are x- and y-inverted and split by at least a tb-wire and a lr-wire. As the lr-wire and the tb-wire are monotone they cross at least three times (see Fig. 7). Contradiction.    \(\square \)

Fig. 7.
figure 7

(a) Two points p and q on vertical segments of the drawing that are inverted along both axes imply wires in \(\varGamma _I\) that are not equivalent to \(\varGamma _O\). (b) Points p and q on a horizontal and vertical segment. (c) Points p and q on horizontal segments.

Theorem 2

Let \(\varGamma _I\) and \(\varGamma _O\) be two unified planar orthogonal drawings of a (disconnected) graph G, where \(\varGamma _I\) has spirality s. We can morph \(\varGamma _I\) into \(\varGamma _O\) using exactly s linear morphs while maintaining planarity and orthogonality.

5 Linear Complexity of Intermediate Drawings

Van Goethem and Verbeek [12] describe rerouting and a simplification operations that reduce the complexity of intermediate drawings to O(n). These operations are not compatible with the batched linear morphs we described in Sect. 4. Below we show how to adapt these operations to the batched setting. These adaptations come at the cost of a single additional linear morph.

5.1 Rerouting

To avoid that the linear morphs introduce too many bends in a single iteration of the morph, we show how to route the wires such that only O(n) complexity is added to the drawing in each iteration. The initial rerouting of the wires in \(\varGamma _I\) increases the maximum spirality by one, but it prevents any increase of spirality during the morph. Thus, using Theorem 2, \(s+1\) morphs are sufficient to morph two equivalent drawings into each other while maintaining planarity and keeping complexity of the intermediate drawings to \(O(n^2)\).

We reroute the wires in \(W_\downarrow \) and \(W_\rightarrow \) as follows. Consider an edge e that is crossed by at least two wires in \(\varGamma _I\). By Lemma 9 from [12] all crossing links have the same spirality. Assume w.l.o.g. that this spirality is positive, otherwise mirror the rotations and replace right by left. Let \(\varepsilon \) be a small distance such that the \(\varepsilon \)-band above e is empty except for the links crossing e and that there is more than a \(2\varepsilon \) distance between the right-most crossing link and the right-endpoint of e (see Fig. 8(a)).

We insert an s-windmill of all crossing wires within the \(\varepsilon \)-band above e by rerouting the wires as follows. First disconnect all crossing links within the \(\varepsilon \)-band above e. Then reroute all wires in a parallel bundle to the right, beyond the right-most wire \(w_r\) crossing e. Now we spiral the bundle using right turns until the spirality of the links reaches zero. Next we unwind the bundle again within the spiral. Finally we reconnect the wires by routing back parallel to e to maintain the original crossing points (see Fig. 8(b)). This rerouting can be executed without introducing crossings between the wires. It does increase the spirality of the drawing by one.

Fig. 8.
figure 8

(a) An \(\varepsilon \)-band adjacent to the edge. (b) Inserting an s-windmill. (c–d) Reroute wires after linear slide without introducing new crossings.

We now change each iteration as follows. Consider a horizontal edge e crossed by \(k>1\) links of maximum absolute spirality s (assuming \(s > 0\)) at the start of the iteration. Instead of performing a linear slide on all crossing links, we perform a single linear slide only on the rightmost crossing link. This slide creates a new vertical segment (see Fig. 8(c)). Thanks to the introduction of the s-windmill, we can easily reroute the other crossing wires to intersect the new vertical segment instead of the horizontal segment without introducing other crossings (see Fig. 8(d)). The newly created crossing links must have spirality \(s-1\) as all links crossing the same segment have the same spirality (Lemma 9 from [12]). We can reduce all remaining spirality s links without introducing additional complexity in the drawing.

Lemma 10

At the start of iteration i of the morph, all wires crossing an edge e with links of spirality i form an i-windmill in an empty \(\varepsilon \)-band next to e.

Lemma 11

Let \(\varGamma _s\) be the first drawing of an iteration and \(\varGamma ^r_{s-1}\) the rerouted last drawing. The spirality of \(\varGamma _s\) relative to \(\varGamma ^r_{s-1}\) is one.

Proof

(Sketch). We can argue that rerouting wires does not eliminate staircases. A link that is rerouted may have been part of a staircase, but the new links replacing it do not break any staircase properties. As rerouting links maintains staircases, Lemmata 58 still apply.    \(\square \)

Drawing \(\varGamma ^r_{s-1}\) compared to \(\varGamma _s\) contains two additional bends in each edge crossed by maximum absolute spirality links in \(\varGamma _s\). We can make \(\varGamma _s\) and \(\varGamma ^r_{s-1}\) degenerate shape-equivalent by inserting an additional zero-length segment at the right-most (left-most for negative spirality) crossing link for each edge crossed by maximum absolute spirality links. By Lemmata 9 and 11 we can morph the resulting \(\varGamma _s\) into \(\varGamma ^r_{s-1}\) in a single linear morph while maintaining planarity.

As, independently of how many wires are crossing it, each edge only introduces two new bends, complexity increases by O(n) during each iteration. Thus the overall complexity is \(O(s\cdot n)\). We conclude that we can morph two drawings \(\varGamma _I\) and \(\varGamma _O\), where \(\varGamma _I\) has spirality s, into each other using \(s+1\) linear morphs while maintaining planarity and \(O(s\cdot n)\) complexity of the drawing.

5.2 Simplification

By using rerouting we can ensure that the complexity of the drawing increases by at most O(n) in every iteration, but its complexity may still grow to \(O(n^2)\) over O(n) iterations. In this section we show how to simplify the intermediate drawings to ensure that the complexity after each iteration is O(n).

We again consider a single iteration starting with \(\varGamma _s\) and ending with \(\varGamma _{s-1}\). Using rerouting we can find an alternative final drawing \(\varGamma ^r_{s-1}\) that also maintains planarity. We now introduce a redraw step that further simplifies \(\varGamma ^r_{s-1}\) into a straight-line drawing \(\varGamma '_{s-1}\) such that a linear morph from \(\varGamma _s\) to \(\varGamma '_{s-1}\) still maintains planarity. The redraw step works as follows.

For each vertex v in \(\varGamma ^r_{s-1}\), consider a \(6\varepsilon \)-sized square box surrounding v that contains only v and a \(3\varepsilon \)-part of each outgoing edge from v. If an incident edge e is crossed by a maximum absolute spirality link in \(\varGamma _s\), then we reroute e inside the \(6\varepsilon \)-box around v. Specifically, for an edge e leaving v rightwards, we reroute e within the \(6\varepsilon \)-box using the coordinates (\(v, v+(0,-\varepsilon ), v+(2\varepsilon ,-\varepsilon ), v+(2\varepsilon ,0), v+(3\varepsilon ,0)\)) (see Fig. 9(a)). Analogous rerouting can be done for edges leaving v in other directions. For an edge crossed by a negative spirality link invert the left and right turns.

Fig. 9.
figure 9

(a) A \(6\varepsilon \)-box surrounding a vertex v (dashed) with four redrawn edges. (b) Original drawing, rerouted drawing, and straightening the drawing.

Lemma 12

We can redraw all edges in \(\varGamma _{s-1}\) that were crossed by a maximum-spirality link in \(\varGamma _s\) within \(6\varepsilon \)-boxes while maintaining planarity of the drawing.

Proof

(Sketch). We can establish a relation between the spiralities of two segments incident at the same vertex. Using this relation we can argue that, after redrawing, no two edges leave a vertex in the same direction. As a result, there are no planarity violations within the \(6\varepsilon \)-boxes around vertices.    \(\square \)

Lemma 13

If \(\varGamma _s\) is a straight-line drawing with spirality \(s>0\) then there exists a straight-line drawing \(\varGamma '_{s-1}\) with spirality \(s-1\).

Proof

(Sketch). Let \(\varGamma ^r_{s-1}\) be the drawing obtained by applying rerouting to the last drawing of iteration s. Consider an edge e crossed by maximum absolute spirality links in \(\varGamma _s\). Edge e has three segments in \(\varGamma ^r_{s-1}\) due to the two introduced bends. The first and last segment do not cross any wires. We can apply the redraw step to e, resulting in three more segments at the start and end of e. Finally we eliminate all additional segments of e by performing zigzag-eliminating slides on these segments (see Fig. 9(b)).    \(\square \)

Lemma 14

The spirality of \(\varGamma '_{s-1}\) relative to \(\varGamma _{s}\) is one.

Proof

(Sketch). Let the main wire set be the set of wires used to compute the morph including rerouting from \(\varGamma _s\) to \(\varGamma ^r_{s-1}\). Consider a reference wire grid that is a straight-line wire grid in \(\varGamma _s\). Using Lemmata 78, and 11 but swapping the roles of \(\varGamma _a\) and \(\varGamma _b\), we obtain the result that there is an equivalent monotone set of wires in \(\varGamma ^r_{s-1}\) matching the reference grid in \(\varGamma _s\). Thus the spirality of \(\varGamma _s\) relative to \(\varGamma ^r_{s-1}\) is one.

When straightening \(\varGamma ^r_{s-1}\) to \(\varGamma '_{s-1}\) only zigzag-removing slides are performed on segments not crossed by a wire from the main wire set. As such a segment was not crossed by a wire from the main wire set, the orientation of the segment is unchanged in \(\varGamma ^r_{s-1}\). Specifically, any link of a wire from the reference wire grid that crosses such a segment must have spirality zero. When straightening \(\varGamma ^r_{s-1}\) to \(\varGamma '_{s-1}\) the zigzag-removing slides may insert additional bends in these reference wires, but the wires will remain monotone.    \(\square \)

We can make \(\varGamma _s\) degenerate shape-equivalent to \(\varGamma '_{s-1}\) as follows. For each edge e crossed by maximum absolute spirality links, we split e at the crossing with the right-most (or left-most if the links have negative spirality) crossing link and insert a zero-length segment. Furthermore, we add three zero-length segments at the endpoint of each such edge e coincident with the respective endpoint.

Theorem 3

Let \(\varGamma _I\) and \(\varGamma _O\) be two equivalent drawings of a (disconnected) graph G, where \(\varGamma _I\) has spirality s. We can morph \(\varGamma _I\) into \(\varGamma _O\) using \(s+1\) linear morphs while maintaining planarity, orthogonality, and linear complexity of the drawing during the morph.