    # How to Morph Graphs on the Torus

We present the first algorithm to morph graphs on the torus. Given two isotopic essentially 3-connected embeddings of the same graph on the Euclidean flat torus, where the edges in both drawings are geodesics, our algorithm computes a continuous deformation from one drawing to the other, such that all edges are geodesics at all times. Previously even the existence of such a morph was not known. Our algorithm runs in O(n^1+ω/2) time, where ω is the matrix multiplication exponent, and the computed morph consists of O(n) parallel linear morphing steps. Existing techniques for morphing planar straight-line graphs do not immediately generalize to graphs on the torus; in particular, Cairns' original 1944 proof and its more recent improvements rely on the fact that every planar graph contains a vertex of degree at most 5. Our proof relies on a subtle geometric analysis of 6-regular triangulations of the torus. We also make heavy use of a natural extension of Tutte's spring embedding theorem to torus graphs.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Computing a morph between two given geometric objects is a fundamental problem, with applications to questions in graphics, animation, and modeling. In general, the goal is twofold: ensure the morphs are as low complexity as possible, and ensure that the intermediate objects retain the same high level structure throughout the morph.

Morphs between planar drawings are well studied in the topology, graph drawing, and computer graphics literature, with many variants. A morph between two planar straight-line embeddings and  of the same planar graph is a continuous family of planar embeddings parametrized by time, starting at and ending at . In the most common formulation, all edges must be straight line segments at all times during the morph; there are then many variables of how to optimize the morph.

In this paper, we consider the more general setting of morphs between two isotopic embeddings of the same graph on the flat torus. To our knowledge, ours is the first algorithm to morph graphs on any higher-genus surface. In fact, it is the first algorithm to compute any form of isotopy between surface graphs; existing algorithms to test whether two graphs on the same surface are isotopic are non-constructive . Our algorithm outputs a morph consisting of steps; within each step, all vertices move along parallel geodesics at (different) constant speeds, and all edges remain geodesics (“straight line segments”). Our algorithm runs in ; the running time is dominated by repeatedly solving a linear system encoding a natural generalization of Tutte’s spring embedding theorem.

### 1.1 Prior Results (and Why They Don’t Generalize)

Cairns [18, 19] was the first to prove the existence of a straight-line continuous deformation between any two isomorphic planar straight-line triangulations. A long series of later works, culminating in papers by Alamdari et al.  and Kleist et al., improved and generalized Cairns’ argument to apply to arbitrary planar straight-line graphs, to produce morphs with polynomial complexity, and to derive efficient algorithms for computing those morphs. (For a more detailed history of these results, we refer the reader to Alamdari et al.  and Roselli .) Cairns’ inductive argument and its successors fundamentally rely on two simple observations: (1) Every planar graph has at least one vertex of degree at most five, and (2) Every polygon with at most five vertices has at least one vertex in its visibility kernel. Thus, every planar straight-line graph contains at least one vertex that can be collapsed to one of its neighbors while preserving the planarity of the embedding.

Unfortunately, the first of these observations fails for graphs on the torus; it is easy to construct a triangulation of the torus in which every vertex has degree . Moreover, not every star-shaped hexagon has a vertex in its visibility kernel. Thus, it is no longer immediate that in any geodesic toroidal triangulation, one can move a vertex to one of its neighbors while maintaining a proper geodesic embedding. (Indeed, the fact that we can actually collapse such an edge is the main topic of Section 4.)

Floater and Gotsman  described an alternative method for morphing planar triangulations using a generalization of Tutte’s spring-embedding theorem 

. Every interior vertex in a planar triangulation can be expressed as a convex combination of its neighbors. Floater and Gotsman’s morph linearly interpolates between the coefficients of these convex combinations; Tutte’s theorem implies that at all times, the interpolated coordinates are consistent with a proper straight-line embedding. Gotsman and Surazhsky later generalized Floater and Gotsman’s technique to arbitrary planar straight-line graphs

[70, 41, 69].

At its core, Floater and Gotsman’s algorithm relies on the fact that the system of linear equations expressing vertices as convex combinations of their neighbors has full rank. An analogous system of equations describes equilibrium embeddings of graphs on the torus [40, 34]; however, for graphs with  vertices, this linear system has equations over variables (the vertex coordinates), but its rank is only . If the linear system happens to have a solution, that solution is consistent with a proper embedding [27, 29, 55, 40]; unfortunately, the system is not always solvable.

When the coefficients associated with each edge are symmetric, the linear system has a two-dimensional set of solutions, which correspond to proper embeddings that differ only by translation. (See our Theorem 2.1 below.) Thus, if two given triangulations can both be described by symmetric coefficients, linearly interpolating those coordinates yields an isotopy 

. Otherwise, however, even if the initial and final coefficient vectors are feasible, weighted averages of those coefficients might not be. Steiner and Fisher

 modify the linear system by fixing one vertex, restoring full rank. However, while the solution to this linear system always describes a geodesic drawing of the graph, edges in that drawing can cross. In either setting, linearly interpolating the edge coefficients does not yield a morph.

Both of these approaches produce planar morphs that require high numerical precision to describe exactly. Barerra-Cruz et al.  describe an algorithm to morph between two isomorphic weighted Schnyder drawings of the same triangulation, each determined by a Schnyder wood together with an assignment of positive weights to the faces. The resulting morph consists of steps, where after each step, all vertices lie on a integer grid. The algorithm relies crucially on the fact that the set of Schnyder woods of a planar triangulation is a distributive lattice . Despite some initial progress by Barerra-Cruz , it is still an open question whether this algorithm can be extended to arbitrary planar triangulations, or even to arbitrary planar straight-line graphs. Beyond that, it is also not clear whether this result can be extended to toroidal graphs. Aleardi et al.  and Gonçalves and Lévêque  describe natural generalizations of Schnyder woods to graphs on the torus; however, the Schnyder woods (or 3-orientations) of a toroidal triangulation do not form a distributive lattice.

Considerably less is known about morphing graphs on higher-genus surfaces. Like earlier planar morphing algorithms, our algorithm follows the same inductive strategy as several earlier algorithms for transforming combinatorial embeddings into geodesic embeddings on the torus [57, 60, 48]. Our algorithm most closely resembles an algorithm of Kocay et al. , which transforms any essentially 3-connected toroidal embedding into an isotopic geodesic embedding, by repeatedly collapsing vertices with degree at most 5 until the embedding becomes a 6-regular triangulation.

### 1.2 Outline of Our Results

We begin by reviewing relevant definitions and background in Section 2. Most importantly, we review a natural generalization of Tutte’s spring embedding theorem  to graphs on the flat torus, first proved by Y. Colin de Verdière ; see Theorem 2.1. We present a technical overview of our contributions in Section 3, deferring details to later sections for clarity.

Like many previous planar morphing papers, most of our paper is devoted to computing pseudomorphs between triangulations. A pseudomorph is a continuous deformation in which vertices are allowed to coincide during the motion but edges are not allowed to cross. Our pseudomorph algorithm uses two different operations that reduce the complexity of the graph: direct collapses, which move one vertex to one of its neighbors, and spring collapses, which increase the weight of one edge to infinity while maintaining an equilibrium embedding, as described by Theorem 2.1. The heart of our result is a novel analysis of 6-regular toroidal triangulations in Section 4, which implies that every non-trivial toroidal triangulation contains at least one edge that can be directly collapsed without introducing any crossings. We regard this analysis as the main technical contribution of our paper. We describe and analyze spring collapses in Section 5, again relying on Theorem 2.1. We describe and analyze the base case of our pseudomorph algorithm in Section 6: a special class of triangulations we call zippers, where every vertex is incident to a loop.

In Section 7, we show that a mild generalization of techniques from Alamdari et al.  can be used to perturb our pseudomorph into a proper morph; this perturbation technique gives us our final morphing algorithm for triangulations. Finally, in Section 8, we describe a simple reduction from morphing essentially 3-connected geodesic toroidal embeddings to morphing triangulations, again using Theorem 2.1. We conclude in Section 9 with some open problems and future directions to consider.

## 2 Background and Definitions

### 2.1 The Flat Torus

The flat torus is the metric space obtained by identifying opposite sides of the unit square in the Euclidean plane via and . See Figure 1. Equivalently, is the quotient space , obtained by identifying every pair of points whose - and -coordinates differ by integers. The function defined by is called the covering map or projection map.

A geodesic in is the projection of any line segment in ; geodesics are the natural analogues of “straight line segments” on the flat torus. We emphasize that a geodesic is not necessarily the shortest path between its endpoints; indeed, there are infinitely many geodesics between any two points on . A closed geodesic in is any geodesic whose endpoints coincide; the two ends of any closed geodesic are locally collinear.

### 2.2 Toroidal Embeddings

Geodesic toroidal drawings are the natural generalizations of straight-line planar graphs to the flat torus. Formally, a geodesic toroidal drawing of a graph is a mapping of vertices to distinct points of and edges to non-intersecting geodesics between their endpoints. Following standard usage in topology, we refer to any such drawing as embedding, to emphasize that edges do not cross.111Formally, an embedding is a continuous injective map from the graph (as a topological space) to the torus . We note that this usage differs from standard terminology in many other graph drawing papers, where “embedding” refers to either a homeomorphism class of (not necessarily injective) drawings or a rotation system.

A homotopy between two (not necessarily injective) drawings and of the same graph is a continuous function where and . A cycle on is contractible if it is homotopic to a single point and non-contractible otherwise. A homotopy is an isotopy if each intermediate function is injective. In other words, an isotopy is a continuous family of embeddings that interpolates between and . (Edges in these intermediate embeddings are not necessarily geodesics.) Figure 1: Three combinatorially equivalent but non-isotopic geodesic toroidal triangulations with parallel edges and loops. Opposite edges of the square are identified.

Two toroidal embeddings of the same graph need not be isotopic, even if they have the same rotation system; see Figure 1. A recent algorithm of É. Colin de Verdière and de Mesmay  can decide whether two toroidal drawings of the same graph are isotopic in linear time; we describe an arguably simpler linear-time algorithm in Appendix A. However, neither of these algorithms actually construct an isotopy if one exists; rather, they check whether the two embeddings satisfy certain topological properties that characterize isotopy [50, 51, 52].

We explicitly consider embeddings of graphs with parallel edges and loops. In every geodesic toroidal embedding, every loop is non-contractible (since otherwise it would be a single point), and no two parallel edges are homotopic (since otherwise they would coincide). In this paper, we consider only geodesic embeddings; we occasionally omit the word “geodesic” when it is clear from context.

The universal cover of a geodesic toroidal embedding is the unique infinite straight-line plane graph whose projection to is ; that is, the projection of any vertex, edge, or face of is a vertex, edge, or face of , respectively. A lift of any vertex in is any vertex in the preimage . Similarly, each edge of lifts to an infinite lattice of parallel line segments in , and each face lifts to an infinite lattice of congruent polygons. Figure 2: Universal covers of the geodesic embeddings from Figure 1.

The link of a vertex in the universal cover is the simple polygon formed by the boundary of the union of the (closed) faces incident to ; the vertices of the link are the neighbors of . We emphasize that when projecting a link down to the flat torus, the vertices and edges of the link need not remain distinct; see Figure 1 for an example. For a vertex in , we informally write “link of ” to refer to the link of an arbitrary lift of , and similarly for edges of . Because the links of any two lifts are congruent, any property proven about one lift applies to all of the others.

Geometric properties of geodesics, polygons, and embeddings on the flat torus are defined by projection from the universal cover. For example, the angle between two edges (or geodesics)  and  at a common vertex is equal to the angle between lifts and  at a common lift . Similarly, the cyclic order of edges around a vertex of is the cyclic order of the corresponding edges around an arbitrary lift . In particular, if  is incident to a loop, that loop appears twice in cyclic order around , and each lift of is incident to two different lifts of that loop. Finally, convex or reflex angles in the link of a vertex in are projections of convex or reflex angle in the link of an arbitrary lift .

A toroidal embedding is a triangulation if every face of is bounded by three (not necessarily distinct) edges, or equivalently, if its universal cover is a planar triangulation. In particular, we do not insist that triangulations are simplicial complexes. Every geodesic toroidal embedding is essentially simple, meaning its universal cover is a planar embedding of a simple (albeit infinite) graph. A geodesic toroidal drawing is essentially 3-connected if its universal cover  is 3-connected [62, 61, 58, 59, 39]; every geodesic triangulation is essentially 3-connected.

### 2.3 Coordinates and Crossing Vectors

To represent an arbitrary straight-line embedding of a graph in the plane, it suffices to record the coordinates of each vertex; each edge in the embedding is the unique line segment between its endpoints. However, vertex coordinates alone are not sufficient to specify a toroidal embedding; intuitively, we must also specify how the edges of the graph wrap around the surface.

Formally, we regard each edge of the graph as a pair of opposing half-edges or darts, each directed from one endpoint, called the tail, toward the other endpoint, called the head. We write to denote the reversal of any dart ; thus, for example, and for every dart .

We can represent any geodesic embedding of any graph onto the torus by associating a coordinate vector with every vertex of and a crossing vector with every dart of . The coordinates of a vertex specify its position in the unit square; to remove any ambiguity, we assign points on the boundary of the unit square coordinates on the bottom and/or left edges. The crossing vector of a dart records how that dart crosses the boundaries of the unit square. Specifically, the first coordinate of is the number of times crosses the vertical boundary to the right (with negative numbers counting leftward crossings), and the second coordinate of is the number of times crosses the horizontal boundary upward (with negative numbers counting downward crossings). Crossing vectors are anti-symmetric: for every dart . See Figure 3. Figure 3: The geodesic embeddings from Figure 1, showing the crossing vectors of all four darts from u to v.

Crossing vectors and their generalizations have been used in several previous algorithms for surface graphs [36, 35, 20, 21, 22, 33] and simplicial complexes [17, 31, 30] to encode the homology classes of cycles. Crossing vectors are also equivalent to the translation vectors traditionally used to model periodic (or “dynamic”) graphs [46, 28, 49, 24, 64, 65, 76, 42, 43, 44] and more recently used to model periodic bar-and-joint frameworks [15, 14].

In principle, our morphing algorithm can be modified to update the coordinates of any vertex and the crossing vectors of darts incident to whenever crosses the boundary of the unit square, with only a small penalty in the running time. But in fact, this maintenance is not necessary; it suffices to modify only the vertex coordinates, keeping all crossing vectors fixed throughout the entire morph, even when vertices cross the boundary of the unit square. We describe how to interpret toroidal embeddings with these more relaxed coordinates in Appendix A.

### 2.4 Equilibrium Embeddings

We make frequent use of the following natural generalization of Tutte’s “spring embedding” theorem for 3-connected planar graphs :

###### Theorem 2.1 (Y. Colin de Verdière ; see also [29, 55, 40])

Let be any essentially 3-connected geodesic toroidal drawing, where each edge has an associated weight . Then is isotopic to a geodesic embedding in such that every face is convex and each vertex is the weighted center of mass of its neighbors; moreover, this equilibrium embedding is unique up to translation.

The equilibrium embedding can be computed by solving the following linear system for the vertex coordinates , treating the crossing vectors and weights as constants [27, 68, 40, 34]:

Here is the weight of the edge containing dart . This linear system has a two-dimensional set of solutions, which differ by translation [27, 40]; we can remove this ambiguity by fixing for some arbitrary root vertex . Some vertex coordinates in the solution to this system may lie outside the unit square; as we explain in Appendix A, it is possible to move all coordinates back into the unit square by appropriately adjusting the crossing vectors, but in fact no such adjustment is necessary.

The support of this linear system is the toroidal graph , which has balanced separators of size  . Thus, the linear system can be solved in time using the generalized nested dissection technique of Lipton et al. , where is the matrix multiplication exponent .

### 2.5 Morphs and Pseudomorphs

A morph between two isotopic geodesic toroidal drawings and is a continuous family of geodesic drawings from to ; in other words, a morph is a geodesic isotopy between and . Any morph is completely determined by the continuous motions on the vertices; geodesic edges update in the obvious way.

A morph is linear if every vertex moves along a geodesic from its initial position to its final position at a uniform speed, and a morph is parallel if all vertices move along parallel geodesics, that is, along projections of parallel line segments.222The paper of Alamdari et al.  and its predecessors [9, 7] call these “unidirectional" morphs; however, this term suggests incorrectly that vertices cannot move in opposite directions. In this paper, we construct morphs that consist of a sequence of parallel linear morphs. Every morph of this type can be specified by a sequence of isotopic geodesic toroidal embeddings and for each index , a set of parallel geodesics connecting the vertices of to corresponding vertices of .

Like many previous planar morphing algorithms, our morphing algorithm first constructs a pseudomorph, which is a continuous family of drawings in which edges remain geodesics, vertices may become coincident, but edges never cross. The most basic ingredient in our pseudomorph is an edge collapse, which moves the endpoints of one edge together until they coincide.333This procedure is often called edge contraction in planar graph morphing literature; we use the term “collapse” to avoid any confusion with the topological notion of contractible cycles. Collapsing an edge also collapses the faces on either side of that edge to geodesics. Our final morph is obtained by carefully perturbing a pseudomorph consisting of edge collapses and their reversals.

## 3 Technical Overview

In this section, we give a technical overview of our results: at a high level, first we develop an algorithm to compute a pseudomorph between geodesic toroidal triangulations, and then we describe how to use this algorithm to compute a morph between essentially -connected geodesic toroidal embeddings. Here we give only a brief overview of several necessary tools; each of these components is developed in detail in a later section of the paper.

### 3.1 List of Ingredients

We begin with some essential subroutines and structural results.

#### 3.1.1 Direct collapses

Following Cairns’ approach  and its later derivatives [1, 2, 9, 6, 7], a direct collapse consists of moving a vertex along some edge to another vertex , at uniform speed, until and coincide, keeping all other vertices fixed. To simplify our presentation, we require that the moving vertex is not incident to a loop. We informally call a vertex good if it is not incident to a loop and it can be directly collapsed to one of its neighbors without introducing any edge crossings, and bad otherwise; see Section 4 for a simple geometric characterization of good vertices.

As noted by Cairns , every vertex of degree at most not incident to a loop is good; indeed, this fact, along with the fact that every planar graph has a vertex of degree at most , forms the basis of Cairns’ approach and its derivatives for computing (pseudo)morphs between straight-line planar drawings. We prove in Lemma 6.1 that in any geodesic toroidal triangulation, a vertex of degree at most cannot be incident to a loop, so in fact all vertices of degree at most are good.

On the other hand, Euler’s formula implies that the average degree of a toroidal graph is exactly , and there are simple examples of degree- vertices that are bad. Morphing between torus graphs thus requires new techniques to handle the special case of -regular triangulations.

#### 3.1.2 6-regular triangulations

We then prove in Lemma 6.2 that if a 6-regular toroidal triangulation contains a loop, then in fact every vertex is incident to a loop; we call this special type of triangulation a zipper. Because all the loops in any non-trivial zipper are parallel, morphing between isotopic zippers and turns out be straightforward. If the zippers have only one vertex, they differ by a single translation. Otherwise, two parallel linear morphs suffice, first sliding the loops of  to coincide with the corresponding loops in , and then rotating the loops to move vertices and non-loop edges to their locations in . We describe and analyze zippers in detail in Section 6.

We analyze -regular triangulations without loops in detail in Section 4; we regard this analysis as the main technical contribution of the paper. Averaging arguments imply that in any 6-regular triangulation where every vertex is bad, in short a bad triangulation, every vertex link is one of two specific non-convex hexagons that we call cats and dogs, illustrated in Figure 8. Analysis of how cats and dogs can overlap implies that any bad triangulation must contain a non-contractible cycle of vertices (each of whose link is a cat) that consistently turns in the same direction at every vertex, and therefore has non-zero turning angle, contradicting the fact that the total turning angle of every non-contractible cycle on the flat torus is zero . We conclude that bad triangulations do not exist; every geodesic toroidal triangulation that is not a zipper contains at least one good vertex.

#### 3.1.3 Equilibria and Spring Collapses

Suppose we are given two isotopic geodesic triangulations and that are not zippers. Our analysis implies that and each contain at least one good vertex. However, it is possible that no vertex is good in both and . More subtly, even if some vertex is good in both triangulations, that vertex may be collapsible along a unique edge in but along a different unique edge in .

The second problem also occurs for straight-line planar embeddings. Cairns’ solution to this problem was to introduce an intermediate triangulation in which can be collapsed along both and . Recursively constructing pseudomorphs from to and from to yields a pseudomorph from  to with exponentially many steps. Subsequent refinements of Cairns’ approach, culminating in the work of Alamdari et al.  and later improvement by Kleist et al. , obtained a pseudomorph with only polynomial complexity by finding clever ways to avoid this intermediate triangulation.

Our algorithm does introduce one intermediate triangulation, but still avoids the exponential blowup of Cairns’ algorithm. Specifically, we use an equilibrium triangulation isotopic to and , as given by Theorem 2.1. A vertex that is good in might still be bad in , so instead of applying a direct collapse to , we introduce a novel method for collapsing edges in an equilibrium embedding in Section 5. Intuitively, we continuously increase the weight of an arbitrary edge to infinity, while maintaining the equilibrium triangulation given by Theorem 2.1. This spring collapse moves the endpoints of together, just like a direct collapse. By analyzing the solutions to the equilibrium linear system (2.4), we show that a spring collapse is a parallel pseudomorph, and in fact can be simulated by an equivalent parallel linear pseudomorph. Moreover, this parallel linear pseudomorph can be computed by solving a single instance of system (2.4).

### 3.2 Recursive Pseudomorph Between Triangulations

We are now ready to describe our recursive algorithm to compute a pseudomorph between two isotopic geodesic triangulations and . We actually explain how to compute a pseudomorph from to an isotopic equilibrium triangulation . The same algorithm gives a pseudomorph from to , and concatenating with the reversal of yields the desired pseudomorph from to .

If is a zipper, we morph directly between and the equilibrium zipper using at most two parallel linear morphs. This is the base case of our recursive algorithm.

If is not a zipper, then it contains a good vertex . By definition, can be directly collapsed along some edge to another vertex , without introducing edge crossings. This direct collapse gives us a parallel linear pseudomorph from to , a geodesic toroidal triangulation whose underlying graph has vertices. On the other hand, performing a spring collapse in by increasing the weight of the same edge  to leads to a drawing where and coincide, that is, an equilibrium triangulation of  that is isotopic to . Finally, because and are isotopic embeddings of the same graph , we can compute a pseudomorph from to recursively.

Our full pseudomorph from to thus consists of the direct collapse from to , followed by the recursive pseudomorph from to , followed by the reverse of the spring collapse from to . See Figure 4. Figure 4: Our pseudomorph consists of a direct collapse, a recursive pseudomorph, and a reversed spring collapse.

Altogether our pseudomorph consists of parallel linear pseudomorphs: at most direct collapses to reach a zipper, parallel linear pseudomorphs to reach an equilibrium zipper, and finally at most reversed spring collapses. The time to compute the overall pseudomorph is dominated by the time needed to compute the equilibrium embeddings; the overall running time is .

### 3.3 Morphing Between Embeddings

In Section 7, we show that a technique introduced by Alamdari et al.  for perturbing planar pseudomorphs into morphs can be applied with only minor modifications to our toroidal pseudomorphs, to produce morphs between geodesic toroidal triangulations. This perturbation step adds only overhead to the running time of our algorithm, and the resulting morphs consist of parallel linear morphs.

Finally, in Section 8, we describe a simple reduction from morphing arbitrary essentially -connected embeddings to the special case of morphing triangulations. In brief, given any triangulation of any essentially -connected geodesic toroidal embedding , the isotopic equilibrium embedding given by Theorem 2.1 can be triangulated in the same way, and any morph between the two triangulations induces a morph between and . This reduction preserves the number of parallel linear morphs and adds only overhead to the running time.

In summary, given any two isotopic essentially -connected geodesic toroidal embeddings, we can construct a morph between them, consisting of parallel linear morphs, in time.

## 4 Cats and Dogs

In this section, we present the core of our technical analysis: the proof that every geodesic toroidal triangulation without loops has a (directly) collapsible edge.

The visibility kernel of a simple polygon is the set of all points in that can “see” all of ; more formally, the visibility kernel is . The visibility kernel is always convex. If  is the link of a vertex in a geodesic triangulation, then must lie in the visibility kernel of . We call a simple polygon good if its visibility kernel contains a vertex of the polygon, and bad otherwise. All triangles, quadrilaterals, and pentagons are good , but some hexagons are bad; Figure 5 shows several examples.

A vertex of a geodesic toroidal triangulation is good if it is not incident to a loop, and the link of any (and thus every) lift of in  is good, and bad otherwise. A good vertex can be safely collapsed to any neighbor in the visibility kernel of its link. Finally, a geodesic toroidal triangulation  with no loops is good if it contains at least one good vertex, and bad otherwise. The main result of this section is that bad triangulations do not exist; that is, every geodesic triangulation with no loops is good.

###### Lemma 4.1

Any bad triangulation is -regular, and the link of each vertex has exactly two reflex vertices.

Every vertex in a bad triangulation must have degree at least , because every vertex with degree at most is good . On the other hand, Euler’s formula for the torus implies that the average degree is exactly . It follows that every bad triangulation is -regular.

If a simple polygon is convex or has exactly one reflex vertex, then it is good: the visibility kernel of a convex polygon is the polygon itself, and if there is exactly one reflex vertex, then the reflex vertex is in the visibility kernel. So each link in a bad triangulation has at least two reflex vertices. We argue next that the average number of reflex vertices per link is at most two, which implies that every link has exactly two reflex vertices.

Thus, each vertex in is a reflex vertex of the links of at most two other vertices. It follows that the average number of reflex vertices in a link is at most two, which completes the proof.

###### Lemma 4.2

A bad hexagon with two reflex vertices separated by two convex vertices is never the link of any vertex.

Consider a bad hexagon whose reflex vertices are separated by two convex vertices. Label the vertices through in cyclic order such that and are the reflex vertices, as shown in Figure 7. Figure 7: A hexagon with two reflex vertices that are separated by two convex vertices. The diagonal between the reflex vertices splits the hexagon into two non-convex quadrilaterals with disjoint visibility kernels.

Because is bad, neither nor lies in its visibility kernel. Vertex can see vertices , , and , so it cannot see both and . Without loss of generality, suppose cannot see . Then is a reflex vertex of the quadrilateral . Every quadrilateral has at most one reflex vertex, and that reflex vertex is in the visibility kernel, so can see . It follows that cannot see , and is a reflex vertex of the quadrilateral .

The visibility kernels of quadrilaterals and are disjoint, which implies that the visibility kernel of is empty. We conclude that is not the link of any vertex.

For the remainder of the proof, we annotate the edges of any triangulation as follows. The star of an edge in a triangulation is the union of the faces incident to that edge. An edge is flippable if its star is convex, and non-flippable otherwise. Every non-flippable edge is incident to the unique reflex vertex of its star; we direct each non-flippable edge away from this reflex vertex.

###### Lemma 4.3

In any bad triangulation, every vertex is incident to exactly two incoming directed edges, exactly two outgoing directed edges, and exactly two flippable edges.

Fix a bad triangulation . If is a reflex vertex in the link of some vertex , then the edge is directed toward . So Lemma 4.1 implies that each vertex is incident to two incoming edges. It follows that the number of directed edges in is exactly twice the number of vertices. Thus, each vertex is incident to at most two outgoing edges. Because the number of directed edges in is exactly twice the number of vertices, each vertex is incident to exactly two outgoing edges. Finally, because every vertex of G is incident to exactly four directed edges, Lemma 4.1 implies that every vertex of G is incident to two flippable edges.

Lemmas 4.2 and 4.3 imply that the links in every bad triangulation fall into two categories, which we call cats and dogs. A cat is a bad hexagon whose reflex vertices are adjacent; a dog is a bad hexagon whose reflex vertices are separated by one convex vertex. Cats are (combinatorially) symmetric; however, there are two species of dogs, which are reflections of each other. Figure 8: Feline and (right-facing) canine anatomy. Flippable edges are shown in double-thick green.

We label the vertices of each cat and dog mnemonically, as shown in Figure 8. For example, if the link of vertex is a dog, then is the unique convex vertex of the dog whose neighbors are reflex, and the vertex opposite in the link is . Since is incident to two convex vertices, it can immediately see every other vertex in the link other than ; its visibility of the nose is blocked by one of the two reflex vertices, which we will call . A dog is right-facing if immediately follows in clockwise order, and left-facing otherwise.

The following lemma implies that two boundary edges of each cat and dog are also flippable, as shown in Figure 8.

###### Lemma 4.4

In any bad triangulation, every triangle is incident to exactly one flippable edge.

Fix a bad triangulation with vertices. Euler’s formula implies that has edges and triangular faces. Lemma 4.3 implies that has exactly flippable edges, so the average number of flippable edges per triangle is exactly .

The flippable edges incident to any vertex are separated in cyclic order around by two non-flippable edges if the link of is a cat, or by one non-flippable edge if the link of is a dog. Thus, two flippable edges never appear consecutively around a common vertex. It follows that every triangle in is incident to at most one flippable edge.

###### Lemma 4.5

Every bad triangulation contains a cat.

Let be a triangulation, and let be any vertex in whose link is a dog. We argue that the link of the nose of must be a cat. (Mnemonically, dogs only sniff cats.)

Without loss of generality, assume that the link of is facing right, so the triple is oriented clockwise, as shown in Figure 9. The fact that the link of is a bad hexagon implies several orientation constraints on its vertices:

• The triple is oriented counterclockwise; otherwise, could see the entire dog.

• The triple is oriented counterclockwise; otherwise, could see the entire dog.

• Finally, the triple is oriented counterclockwise; otherwise, could see the entire dog.

Now suppose for the sake of argument that the link of is a dog. We label the other vertices of the link of as shown on the top row of Figure 10; in particular, and . Because the flippable edge is inside the link of , either or ; each of these cases admits two subcases. The four cases are illustrated schematically in the columns of Figure 10.

• Suppose and , and therefore . Let . The triple must be oriented clockwise; our earlier analysis implies that is oriented counterclockwise. It follows that triangles and overlap, which is impossible.

• Suppose and , and therefore . Let . The triple must be oriented clockwise; our earlier analysis implies that is oriented counterclockwise. It follows that triangles and overlap, which is impossible.

• Suppose and . Let . The triple is oriented clockwise; our earlier analysis implies that is oriented counterclockwise. It follows that triangles and overlap, which is impossible.

• Finally, suppose and . Let . The triple is oriented clockwise; our earlier analysis implies that is oriented counterclockwise. It follows that triangles and overlap, which is impossible.

In all four cases, we derive a contradiction. We conclude that the link of is actually a cat. Figure 10: A dog’s nose (v) cannot be the center of another dog.

Every 6-regular triangulation of the torus is isotopic to the quotient of the regular equilateral-triangle tiling of the plane by a lattice of translations [5, 63, 16]. We analyze the patterns of cats and dogs in bad triangulations by analyzing their images in this reference triangulation, and in particular, by studying the induced annotations of edges, as illustrated in Figure 11. Figure 11: Feline and (right-facing) canine reference anatomy; compare with Figure 8.

A cycle in a 6-regular toroidal triangulation is straight if it corresponds to a closed geodesic in the corresponding lattice triangulation. Every straight cycle is non-contractible.

Let be a simple polygonal (i.e., piecewise geodesic) cycle, arbitrarily directed, and let be any vertex of . Let be any lift of , and let and be lifts of the edges of incident to . The turning angle of at is the signed counterclockwise angle, strictly between and , between the vectors and . In other words, when walking along the cycle in the indicated direction, the turning angle is the angle one turns left at  (or right if the angle is negative). The total turning angle of is the sum of the turning angles of the vertices of .

###### Lemma 4.6

Every simple non-contractible cycle on the flat torus has total turning angle zero.

Lemma 4.6 follows immediately from classical results of Reinhart . In short, the total turning angle (which Reinhart calls the “winding number”) is an isotopy invariant of closed curves, and every simple non-contractible cycle on the flat torus is isotopic to a closed geodesic. Lemma 4.6 implies in particular that every straight cycle has total turning angle zero.

###### Lemma 4.7

If a bad triangulation contains one dog, it contains a straight cycle of dogs.

Let be a bad triangulation and let be any vertex of whose link is a dog. Label the vertices of ’s link as shown in Figure 12; for example, , , and .

Edges and are flippable, and therefore edges , , and are not flippable. Thus, no opposite pair of edges incident to are both flippable. It follows that the link of is a dog, whose ear vertex is .

Edges , , and are not flippable, so edges and must be flippable. Thus, the link of is also a dog, whose mouth vertex is .

Continuing by induction in both directions, we find a bidirectional sequence of vertices whose links are dogs, where the center of each dog is the mouth of the previous dog and the ear of the next dog. Because is finite, this sequence must eventually repeat, forming a straight cycle.

Finally, we are ready to prove the main theorem of this section.

###### Theorem 4.8

Let be a bad triangulation. We derive a contradiction by showing that contains a non-contractible cycle whose vertices all have cat links, whose edges are all non-flippable, and finally whose turning angle is non-zero, contradicting Lemma 4.6.

Let be any vertex of whose link is a cat; Lemma 4.5 implies that such a vertex exists. Label the vertices in the neighborhood of as shown in Figure 13. The directions of the non-flippable edges of the cat are not relevant, so we will ignore them. Thus, for example, and  are either the eyes of ’s link or its cheeks.

First, suppose that contains at least one dog, and therefore without loss of generality that is adjacent to a vertex whose link is a dog. Up to symmetry, there are two cases to consider. If the link of  is a dog whose mouth is , then the link of is also a dog (whose ear is ). Conversely, if the link of is a dog, the ear of that dog is , and thus, the link of is also a dog whose mouth is . The previous lemma now implies a straight cycle of dogs .

Because the link of is a dog, edge is flippable; it follows that the link of is a cat. Similarly, because the link of is a dog, edge is flippable; it follows that the link of is a cat. Proceeding inductively in both directions, we find a straight cycle of vertices, parallel to the cycle of dogs, all of whose links are cats. Every edge in is unflippable.

On the other hand, if contains no dogs, then we can construct a straight cycle of cat vertices starting with any unflippable edge . Again, every edge in is unflippable.

Now suppose is the left ear of . Then by induction, for every index , vertex is the left ear of and is the right cheek of . It follows that every triple is oriented clockwise, and thus the total turning angle of is negative, contradicting Lemma 4.6. The other three cases similarly lead to contradictions; in all cases, every triple has the same orientation, which implies that the total turning angle of is non-zero, contradicting Lemma 4.6.

## 5 Equilibrium Pseudomorphs

As pointed out in Section 3, when computing a recursive pseudomorph between two triangulations  and , we must contend with the fact that while each triangulation must contain a good vertex, there may be no way to safely collapse the same vertex along the same edge in both triangulations. It is relatively straightforward to adapt Cairns’ approach for planar graphs to the torus, by recursively computing pseudomorphs from both and to a suitable intermediate triangulation; unfortunately, the resulting pseudomorph from to consists of an exponential number of steps.

Instead, our algorithm introduces one intermediate triangulation isotopic to both and , namely an equilibrium triangulation guaranteed by Y. Colin de Verdière’s generalization of Tutte’s spring embedding theorem (Theorem 2.1). In this section, we describe how to collapse an arbitrary edge in an equilibrium triangulation to obtain a simpler equilibrium triangulation. This operation allows us to recursively compute a pseudomorph from either or to using only a linear number of steps, as described in Section 3.2.

Intuitively, we continuously increase the weight of to and maintain the equilibrium triangulation. We show that the resulting “spring collapse” moves all vertices of the equilibrium embedding along geodesics parallel to , as shown in Figure 14; in particular, edge collapses to a single vertex. It follows that straightforward linear interpolation from one equilibrium triangulation to the other is a parallel linear pseudomorph. Figure 14: Increasing the weight of any edge e to infinity collapses e and moves every vertex parallel to e.

For any triangulation and any assignment of positive weights to the edges of , let denote the geodesic embedding isotopic to  that is in equilibrium with respect to the weight vector , as guaranteed by Theorem 2.1. (At the top level of recursion, we can safely assume that for every edge , but as we point out in Section 5.2, we cannot maintain that assumption in deeper recursive calls.) For each vertex of , let denote the coordinates of in , obtained by solving linear system (2.4). To define the embedding  and its coordinates uniquely, fix for some arbitrary vertex .

### 5.1 Parallel Motion

The following lemma states intuitively that changing a single edge weight moves each vertex of the equilibrium embedding along a geodesic parallel to .

###### Lemma 5.1

Let and be arbitrary positive edge weights such that for some edge , and for all edges . Let be a dart of with tail and head . Then for every vertex , the vector is parallel to .

Arbitrarily index the vertices of from to . Fix a non-zero vector orthogonal to the vector . For each vertex , let and , and for each dart , let . Our choice of implies that . We need to prove that for every vertex .

The real vector is a solution to the linear system , where is the weighted Laplacian matrix

 Lij=⎧⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪⎩∑\emphtail(d)=i−λ(d)if i=j∑\emphtail(d)=i\emphhead(d)=jλ(d)if i≠j

and is a vector whose th entry is

 Hi=∑\emphtail(d)=i−λ(d)χ(d).

(In fact, is the unique solution such that .) Similarly, is the unique solution to an analogous equation with , where and are defined mutatis mutandis in terms of  instead of .

We prove that as follows. Let . The Laplacian matrices and differ in only four locations:

 L′ij−Lij=⎧⎨⎩−δif i=j=u or i=j=vδif \seti,j=\setu,v0otherwise

More concisely, we have , where denotes the th standard coordinate vector. Similarly, we have . It follows that

 L′Z =LZ−δ(ev−eu)(ev−eu)TZ =H−δ(ev−eu)(zv−zu) =H+δ(ev−eu)χ(d) =H′

which completes the proof.

We note in passing that a nearly identical lemma applies to internally 3-connected plane graphs; changing the weight of one edge moves the vertices of any Tutte embedding along lines parallel to . Surprisingly, this observation appears to be new.

### 5.2 Spring Collapse

Now fix a toroidal triangulation and edge weights . Let be an arbitrary edge of , and let be the result of collapsing one endpoint to the other endpoint . Let be the edges in the link of in , as shown in Figure 15. Edges and collapse to a single edge in , and edges and collapse to a single edge in . Now define weights for the edges of as follows:

 λ′(e):=⎧⎪⎨⎪⎩λ(a)+λ(b)if e=abλ(c)+λ(d)if e=cdλ(e)otherwise

The new equilibrium embedding has the same image as the limit of as we increase to infinity and keep all other edge weights fixed. Lemma 5.1 implies that as we continuously increase , the vertices of move continuously along geodesics parallel to .

### 5.3 Geodesic Interpolation

This continuous deformation from to is not a parallel linear pseudomorph, because the vertices do not necessarily move at fixed speeds.444We have deliberately left unspecified exactly how grows to infinity. We conjecture that with the right choice of growth function, the resulting vertex motion is actually linear. To define a parallel linear pseudomorph, we simply move each vertex at constant speed along its corresponding geodesic. That is, for every vertex and all real numbers , let

 pt(w)=(1−t)⋅p∗(w,λ)+t⋅p∗(w,λ′),

and let denote the geodesic drawing of with vertex coordinates and the same crossing vectors as . The following lemma implies that is actually an embedding for all , which implies that the continuous family of drawings is a parallel linear pseudomorph from to .

###### Lemma 5.2

Let , , and be arbitrary parallel segments in the plane. For all real , define and and . If the triples and are oriented counterclockwise, then for all , the triple is also oriented counterclockwise.

Without loss of generality, assume that segments , , and are horizontal. Thus, we can write , and similarly for and . The triple is oriented counterclockwise if and only if the following determinant is positive:

 Δ(t):=∣∣ ∣∣1pxtpy1qxtqy1rxtry∣∣ ∣∣

Routine calculation implies

 Δ(t) =∣∣ ∣ ∣∣1(1−t)px0+tpx1py1(1−t)qx0+tqx1qy1(1−t)rx0+trx1ry∣∣ ∣ ∣∣ =(1−t)∣∣ ∣∣1px0py1qx0qy1rx0ry∣∣ ∣∣+t∣∣ ∣∣1px1py1qx1qy1rx1ry∣∣ ∣∣ = (1−t)⋅Δ(0)+t⋅Δ(1)

Thus, the function has exactly one real root. It follows that if and , then for all .

## 6 Zippers

Even if the original input triangulations and are simple, collapsing edges eventually reduces them to triangulations with parallel edges and loops. Every loop in a geodesic toroidal triangulation is a closed geodesic. The base case of our recursive algorithm is a special type of geodesic toroidal triangulation that we call a zipper, in which every vertex is incident to a loop. (This class of graphs were previously considered by Gonçalves and Lévêque [39, Fig. 44].)

Consider any zipper with vertices, for some positive integer . If , then consists of a single vertex, three loop edges, and two triangular faces. Otherwise, the loops in are disjoint closed geodesics, so they must be parallel; it follows that each vertex of is incident to exactly one loop. In either case, the loops in decompose the torus into annuli, each of which is decomposed into two triangles by two boundary-to-boundary edges. Figure 1 shows three two-vertex zippers, and Figure 16 shows a zipper with five vertices.

### 6.1 Zipper Structure

The following results motivate our choice of zippers as a base case of our recursive algorithm.

###### Lemma 6.1

In every geodesic toroidal triangulation, every vertex incident to a loop has degree at least 6.

Let be a geodesic toroidal triangulation, let be a vertex of incident to a loop, let be either of the darts of that loop.

Let denote the clockwise facial walk around the face to the right of . Because the interior of  is an open disk, is contractible. Because is a triangulation, consists of exactly three darts , and , where for each index . Because every contractible geodesic loop consists of a single point, is non-contractible and thus is not homotopic to . It follows that .

Symmetrically, the counterclockwise walk around the face to the left of consists of three darts , where . Thus, at least six distinct darts head into : in counterclockwise cyclic order, , , , , , .555If has only one vertex, then and , and so is incident to only three distinct edges. Otherwise, is incident to five distinct edges. Figure 17: (a) Proof of Lemma 6.1. (b) Proof of Lemma 6.2
###### Lemma 6.2

Every 6-regular triangulation that contains a loop is a zipper.

Again, let be a 6-regular triangulation, and let be a vertex of incident to a loop . The previous proof implies that is incident to two edges on either side of . Let and be the edges incident to on one side of ; the edges , , and enclose a triangular face . Thus, and share another common endpoint . (Except in the trivial case where has only one vertex, and are distinct.) Because and are adjacent in cyclic order around , there is another triangular face with and on its boundary; the third edge of is a loop through . The lemma now follows by induction.

###### Corollary 6.3

Every triangulation that contains a loop but is not a zipper contains a vertex of degree at most 5 that is not incident to a loop.

### 6.2 Morphing Zippers

We next describe a straightforward approach to morphing between arbitrary isotopic zippers, which requires at most two parallel linear morphing steps.

Let and be arbitrary isotopic zippers with vertices. If , then and differ only by translation, so assume otherwise. Ladegaillerie [50, 51, 52] proved that two embeddings of the same graph  on the same surface are isotopic if and only if, the images of any cycle in in both embeddings are homotopic. Ladegaillerie’s theorem implies that all cycles in and all cycles in are parallel to a common vector .

In the first parallel morphing step, we translate all vertices in along geodesics orthogonal to until the image of each loop has the same image as the corresponding loop in . Then in the second parallel morphing step, we translate all vertices along their respective loops to move all vertices and edges to their proper positions in . See Figure 18 for an example. In both stages, Lemma 5.2 implies that linear interpolation between the old and new vertex coordinates yields an isotopy. Figure 18: Morphing one zipper into another. Doubled red edges are loops.

## 7 Converting Pseudomorphs to Morphs

In this section, we adapt a perturbation strategy of Alamdari et al. , which transforms their pseudomorphs between planar triangulations into morphs, to geodesic triangulations on the flat torus.

To explain our adaptation, we must first give a brief sketch of their algorithm. Let be the initial planar input triangulation. The input to their perturbation algorithm is a pseudomorph consisting of a (direct) collapse of a good vertex to a neighbor , a morph (not a pseudomorph) consisting of parallel linear steps , and finally the reverse of a collapse of to resulting in the final triangulation . The output is a proper morph from to , consisting of parallel linear steps.

Alamdari et al. proceed as follows. Let be the link of in the initial triangulation . For each index , let and respectively denote the images of and in the intermediate triangulation . For each index , a position is found within the visibility kernel of so that for all , the vector is parallel to (the direction of the parallel linear morph ). For vertices of degree and , it is simple to place as a certain convex combination of the vertices in . The strategy for vertices of degree is more complicated. First, a value is computed such that for each index , the intersection of the disk of radius centered at and the visibility kernel of intersects only the edges of the kernel incident to ; call this intersection . A specific position is then chosen within each region .

A close examination of their paper reveals that the strategy for vertices of degree generalizes to vertices of arbitrary degree (greater than ). In particular, the definition of depends solely on and the positions of the edges in incident to .

The radius is computed as follows. For each index , we need a positive distance smaller than the minimum distance from to any edge of the kernel of that is not incident to , at any time during the morphing step . It suffices to compute the minimum distance from to the lines supporting edges of not incident to . The squared distance to each of these lines at any time can be expressed as the ratio of two quadratic polynomials and . Alamdari et al. argue that a lower bound can be computed in constant time in an appropriate real RAM model . Then is the minimum of these lower bounds . Altogether computing  takes time. Finally, .

Once the radius is known, computing each sector in time is straightforward.

The point can be chosen arbitrarily within . For each index in increasing order, Alamdari et al. describe how to choose a point in time, such that the vector is parallel to the vector . This part of the algorithm makes no reference to the rest of the triangulation; it works entirely within the sectors and . Moreover, no part of this algorithm relies on being directly collapsed to , only that vertices and have the same image in the triangulations and .

We apply this perturbation technique to the toroidal pseudomorphs computed in Section 3.2 as follows. Recall that our pseudomorph consists of a direct collapse, a recursively computed pseudomorph, and a reversed spring collapse. First we (recursively) perturb the recursive pseudomorph into a proper morph consisting of parallel linear morphs. We then compute the sectors  and the radius exactly as described above. To perturb the initial direct collapse from to , we move to an arbitrary point in the intersection of and the edge along which is collapsed. We compute the intermediate positions for exactly as described above, working entirely within the local coordinates of the sectors . Finally, to perturb the reversed spring collapse, we first move from to a new point so that the image of the collapsing edge becomes parallel to the direction of the original spring collapse, after which we simply interpolate to the final triangulation, as described in Section 5.3. Because the vertices move along parallel geodesics, Lemma 5.2 implies that this final interpolation is a parallel linear morph. Altogether, we obtain a morph consisting of parallel linear morphs. We emphasize that the additional step moving to is the only significant difference from the algorithm presented by Alamdari et al.

Unrolling the recursion, we can perturb our pseudomorph between two -vertex toroidal triangulations into a proper morph consisting of parallel linear morphing steps in time. The overall time to compute this morph is still dominated by the time needed to compute equilibrium triangulations for the spring collapses.

###### Theorem 7.1

Given any two isotopic geodesic toroidal triangulations and with vertices, we can compute a morph from to consisting of parallel linear morphs in time.

## 8 Not Just Triangulations

Finally, it remains to describe how to morph between embeddings that are not triangulations. Following existing work in the planar setting, we extend the given embeddings and to triangulations, and then invoke our earlier triangulation-morphing algorithm. The main difficulty is that it may not be possible to triangulate both and using the same diagonals, because corresponding faces, while combinatorially identical, have different shapes.

Two different techniques have been proposed to overcome this hurdle in the planar setting. The first method subdivides each pair of corresponding faces into a compatible triangulation, introducing additional vertices if necessary [71, 41, 69, 70, 2]; however, this technique increases the complexity of the graph to  . The second technique uses additional morphing steps to convexify faces to that they can be compatibly triangulated without additional vertices [7, 1]. While the subdivision technique generalizes to toroidal embeddings (at least when all faces are disks), it is unclear how to generalize existing morphing techniques.

We introduce a third technique, which avoids both subdivision and additional morphing steps by exploiting Theorem 2.1. We emphasize that our method can also be applied to 3-connected straight-line plane graphs, giving a new and arguably simpler approach for the planar case as well.

###### Theorem 8.1

Given any two isotopic essentially 3-connected geodesic toroidal embeddings and with vertices, we can compute a morph from to consisting of parallel linear morphs in time.

Let be an equilibrium embedding isotopic to and as given by Theorem 2.1. It suffices to describe how to morph from to ; to morph from to one can simply first morph from to and then from to .

Arbitrarily triangulate the faces of ; this can be done in time using Chazelle’s algorithm , or in time in practice. Because each face of is convex, we can triangulate in the exact same manner. The result is two isotopic geodesic toroidal triangulations  and . Given a morph between and as promised by Theorem 7.1, we obtain a morph between