Given an -vertex graph , a morph between two drawings (i.e., embeddings in ) of
is a continuous transformation from one drawing to the other through a family of intermediate drawings. One is interested in well-behaved morphs, i.e., those that preserve essential properties of the drawing at any moment. Usually this property is that the drawing iscrossing-free; such morphs are called crossing-free morphs. This concept finds applications in multiple domains: animation, modeling, and computer graphics, etc. [13, 14, 15, 12]. A drawing of is a straight-line drawing if it maps each vertex of to a point in and each edge of to the line segment whose endpoints correspond to the endpoints of this edge. In this work, we focus on the case of drawings in the Euclidean plane () and drawings (); a non-crossing drawing of a graph in is called planar.
The study of crossing-free graph morphs began in 1944 from a non-constructive proof that such morphs for maximal planar graphs exist between two topologically equivalent drawings ; a matching algorithmic result appeared in 1983 . Recently crossing-free morphs of straight-line drawings are considered, where the vertex trajectories are simple. Of particular interest is linear morph transforming one straight-line drawing of a graph to another such drawing through a sequence of straight-line drawings. Morph is called a morphing step, or simply a step, for brevity. In each step of a linear morph each vertex of moves along a straight-line segment at a constant speed. Results [2, 4, 7, 3] led up to a seminal paper by Alamdari et al.  showing that for any two topologically equivalent planar drawings of a graph , there is a linear morph that transforms one drawing to the other in steps. This bound is asymptotically optimal in the worst case even when the graph is a path. A natural further question is how the situation changes when we involve the third dimension. For general 3D graph drawings the problem seems challenging: it is tightly connected to unknot recognition problem, that is in [16, 18], and its containment in P is widely open. If the given graph is a tree, the worst-case tight bound of steps holds for crossing-free linear morph  (and the lower-bound example is again a path). If both the initial and the final drawing are planar, then steps suffice .
Both algorithmic results [1, 5] have a drawback crucial from the practical point of view. Their intermediate steps use infinitesimal or very small distances, as compared to distances in the input drawings. This may blow up the space requirements and affect the aesthetical aspect. This raises a demand for morphing algorithms that operate on a small grid, i.e., of size polynomial in the size of the graph and parameters of the input drawings. All the intermediate drawings are then restricted to be grid drawings, where vertices map to nodes of the grid. Two crucial parameters of a straight-line grid drawing are: the area (or volume for the 3D case) of the required grid, and the resolution, that is the ratio between the maximum edge length and the minimum vertex-edge distance. If the grid area (or volume) is polynomially bounded, then so is the resolution .
Barrera-Cruz et al.  gave an algorithm to morph between two straight-line planar Schnyder drawings of a triangulated graph in steps; all the intermediate drawings of this morph lie in a grid of size . Very recently Barrera-Cruz et al.  gave an algorithm that linearly morphs between two planar straight-line grid drawings and of an -vertex rooted tree in steps while each intermediate drawing is also a planar straight-line drawing in a bounded grid. In particular, the maximum grid length and width is respectively and , where , and , and are the length and the height of the drawing respectively. Note that is .
Here we study morphing one straight-line grid drawing of a tree to another such drawing in sublinear number of steps using 3D for intermediate steps. Effectively we ask the same question as in , but now with additional restriction for all drawings throughout the algorithm to lie in a small grid. We give two algorithms that require steps and steps, respectively. All the intermediate drawings require a grid of length , width and height , where is the diameter of the drawing . At the expense of using an extra dimension we significantly decrease the number of morphing steps, and also the required (horizontal) area, as compared to the planar result . Our algorithm is the first one to morph between planar drawings of a tree in steps on a grid of polynomial volume.
2 Preliminaries and Definitions
For a tree , let be its root, and be the subtree of rooted at a vertex . Let and be respectively the set of vertices end edges of , and let denote the number of vertices in .
In a straight-line drawing of , each vertex is mapped to a point in and each edge is mapped a straight-line segment connecting its end-points. A - (respectively, a -) grid drawing of is a straight-line drawing where each vertex is mapped to a point with integer coordinates in (respectively, ).A drawing of is said to be crossing-free if images of no two edges intersect except, possibly, at common end-points. A crossing-free -grid drawing is called a planar grid drawing. For a crossing-free drawing , let denote the open disc of radius in X0Y plane centered at the image of . Unless stated otherwise, by the projection, denoted by , we mean the vertical projection to plane. Let , and respectively denote the length, width and height of , i.e., the maximum absolute difference between the -,- and -coordinates of vertices in . Let denote the diameter of , defined as the ceiling of the maximum pairwise distance between its vertices. Given a vertex and an edge of the tree , denotes the distance between and . Similarly, is the distance between and .
For , , where . Thus to estimate the space required by
. Thus to estimate the space required by, it is enough to estimate .
 For any vertex and edge not incident to in a planar grid drawing of , .
For each , let be equal to where is an integral constant. The distance between any two distinct vertices in is at least .
Let fix vertex and . Denote by the height in the triangle from the vertex , is the distance from to the line that contains the edge by its definition. Let be the area of triangle .
On the other hand from the Pick’s theorem we know, that the area of the triangle with vertices lying in the lattice points of the grid is at least .
For any pair of distinct vertices , either or is at least since all vertices has integer coordinates in . This implies that, for each pair of distinct vertices , either or is at least since each coordinate of each vertex in is multiplied by to obtain . ∎
of a tree is a decomposition of its edges into a set of disjoint paths as follows. Choose a path in and store it in . Removal of this path may disconnected the tree; recurse on the remaining connected components. In the end, contains disjoint paths whose union is . The way of choosing path may differ. The depth of a vertex in , denoted by , is defined as the length of the path from to . Head of the path , denotes as , is the vertex with the minimum depth in tree . Let internal vertices of the path be all vertices except . Any path decomposition of induces a linear order of the paths: path succeeds , i.e., , if and only if is deleted before during the construction of . Note that the subtree of each internal vertex of a path is a subset of the union of the paths that precede .
In the long-path decomposition , the path chosen in every iteration is the longest root-to-leaf path (ties are broken arbitrarily). Let be the ordered set of paths of a long-path decomposition of . For , .
Heavy-rooted-pathwidth decomposition . The Strahler number or Horton-Strahler number of a tree is a parameter which was introduced by Horton and Strahler [17, 19, 20]. The same parameter was recently rediscovered by Biedl  with the name of rooted pathwidth when addressing the problem of computing upward tree drawings with optimal width.
The rooted pathwidth of a tree , which we denote by , is defined as follows. If , then . Otherwise, let be the maximum rooted pathwidth of any subtree rooted at a child of . Then if exactly one subtree rooted at a child of has rooted pathwidth equal to , and if more than one subtree rooted at a child of has rooted pathwidth equal to ; see Figure (a)a. Clearly is an integer number.
The heavy-rooted-pathwidth decomposition of a tree is defined as follows refer to Figure (b)b. For each non-leaf vertex of , let be the child of in such that is maximum (ties are broken arbitrarily). Then is a heavy edge; further, each child of is a light child of , and the edge is a light edge. Connected components of heavy edges form set of paths , called heavy paths, which may have many incident light edges. The path tree of is a tree whose vertices correspond to heavy paths in ; see Fig. (c)c. The parent of a heavy path in the path tree is the heavy path that contains the parent of the vertex with minimum depth in . The root of the path tree is the heavy path containing .
For convenience, we will also consider the light edge immediately above a heavy path to be a part of the path. When it is clear from the context we will refer to simply as .
We denote by the root of the path tree of ; let be the ordered sequence of the vertices of , where . For , we let be the light children of in any order. Let be the sequence of the light children of ordered so that: (i) any light child of a vertex precedes any light child of a vertex , if ; and (ii) the light child of a vertex precedes the light child of . For a vertex , we denote by its parent; note that . It is known  that the height of the path tree of an -vertex tree is at most .
Fig. (a)a shows the heavy-rooted-pathwidth decomposition of our running example where heavy paths are shown in different colors.
Canonical 3D drawing of a tree , introduced in , is the crossing-free straight-line 3D drawing of that maps each vertex of to its canonical position defined from heavy-rooted pathwidth decomposition.
The canonical drawing of a tree , denoted by , is defined as follows:
First, we set for the root of .
Second, for each , we set , where is the -coordinate of .
Third, for each and for each , we determine as follows. If , then we set , where is the -coordinate of ; otherwise, we set , where is the -coordinate of .
Finally, in order to determine the canonical positions of the vertices in , for each and each , we recursively construct the canonical 3D drawing of
, and translate all the vertices by the same vector so thatis sent to .
We use the fact that lies in the positive quarter-plane, inside a bounding box of height and width such that the left-bottom point of the box represents the image of the root and is mapped to the origin. Since tree never changes throughout our algorithm, we refer as .
For any vertex of , the relative canonical drawing of is the drawing of obtained by cropping and translating the obtained drawing of so that is mapped to the origin.
Let and be two planar straight-line drawings of . Then a morph is a sequence of 3D straight-line drawings of such that , and is a linear morph, for each .
3 Tools for morphing algorithms
Stretching with a constant .
Let the drawing be lying in the plane. During stretching morph each coordinate of each vertex in is multiplied by a common positive integer constant . Thereby, it is a linear morph that ”stretches” the vertices apart.
Stretching morph is crossing-free.
For each the drawing , where the image of any vertex of is is the same drawing scaled by . Since the original drawing was crossing-free, so is the drawing . ∎
For any pair of vertices disks and do not cross in plane.
For a vertex disk does not enclose any other vertices or any part of non-incident to edges in .
For every vertex and every edge in there is lattice point such that and .
As disk contains no other vertices , then does not contain other vertices too. The — disk with half that radius — does not intersect with any for .
Due to Lemma 1 no non-incident edges intersected the disk of radius around in . That means that in , where all distances are multiplied by no non-incident edges intersect the disk of radius around . Other vertices do not lie in as .
Every edge from has been stretched by . If and , then and . The integral point and is .∎
Mapping around a pole
Let the pole through be vertical line in through point . Let be vertical half-planes containing the pole through a point with integer coordinates. Suppose and contain infinitely many points with integer coordinates. Mapping around the pole is a morphing step to obtain a drawing which lies in from which lies in . Each vertex moves along a horizontal vector between and . The direction of this vector is common for all vertices of and is defined by and . Let us fix a horizontal plane which passing through the point where is an integer. Let be points that lie on and , respectively; such that and be the minimum non-zero distances from the to the integer points lying in and . The vector of mapping is defined as . Mapping is a unidirectional morph since all vertices of move along the vectors parallel to the vector of mapping till they reach the half-plane . See Fig. (c)c.
 Let be a unidirectional morph between two planar straight-line drawings and of . Let be a vertex of , let be an edge of and, for any drawing of , let be the line through the edge oriented from to . Suppose that is to the left of both in and in . Then is to the left of throughout .
For each the drawing lies in one half-plane. Moreover, for each this half-plane has the vertical borderline , which is a borderline of half-planes and .
Recall that mapping is a unidirectional morph that transforms drawings between two half-planes that share a common pole. Note that the length of the vector of movement of any vertex in is proportional to its distance to the pole. Let denote the point on the pole with the same coordinate as , once again for each we denote by the drawing, where the image of any vertex of is . For any two vertices from with the same height that are being mapped to the half-plane , from proportionality of distances, we can cay that at any moment for the intermediate drawing we have . If the angle between the edge and the plane is the same for all points at some height, then it is the same for all vertices in , because points with the same -coordinates had the same vector of movement.
Mapping is a crossing-free morph.
From Lemma 4 we know that at any moment the whole lies within one half-plane and as the mapping is a unidirectional morph, one can get that drawing is a result of projection from half-plane to intermediate half-plane . We restricted angle between and not to be equal to and . With this resctiction drawing is the rotated drawing stretched in horizontal direction by some constant. Then is crossing-free as was crossing-free.
The rotation is a mapping when are half-planes of planes parallel to respectively and thus . Vector of mapping for rotation is lying in the set, see Fig. 10:
We denote by a half-plane parallel to with vertical border-line going through vertex in X-positive direction from that pole. are defined analogously.
A horizontal pole is a line parallel to axis. Horizontal pole through the point, mapping around horizontal pole and horizontal rotation are defined analogously. Corresponding set of possible directions of movement for horizontal rotation are:
Shrinking lifted subtrees.
Let be a vertex of such that the image of subtree in is , i.e., it lies in . Let be the ordered set of the children of which are ordered according to their -coordinates in . For a tuple , where , let us consider the ordered set such that the members of are ordered according to their -coordinates in . Let us consider the new subtree which is obtained by deleting the vertices in and their subtrees. Consider the canonical drawing of with respect to . For each satisfying , lies inside a box of height and width on the plane such that the down-left corner of the box coincides with since they are in a canonical position with respect to their roots. We define the shrink subtree procedure on as follows. We move each vertex from to . Vertices of the subtree rooted at also move along the same vector. Let us denote the shrinked subtree by . The height of the shrinked subtree is equal to the number of vertices in .
The height of the shrinked subtree is equal to the number of vertices in .
Note that the subtree rooted at has a canonical drawing in . This implies that for the subtree rooted at also has a canonical drawing with respect to in . Each lies inside a box of height . Also, note that the z-coordinate of is equal to . This implies that in , lies inside a box of height and the down-left corner of the box coincide with Also note that .
Shrinking is a crossing-free morph.
Note that the and coordinates of each vertex in and are the same and -coordinate can only decrease, shrinking is obviously a unidirectional morph in vertical plane which passes through . Also, note that through out the morphing process all vertices in maintain the relative orders among themselves since they move along parallel vectors. Also note that shrinking satisfies the conditions of Proposition 1. This implies that shrinking is a crossing free morph. ∎
Turning in horizontal plane.
Let be the canonical drawing of a subtree on the horizontal plane , i.e. relative canonical drawing rotated around horizontal pole through in any direction to lie in or half-plane. We discuss the case when lies in , the other case is similar. Let be the drawings obtained from by rotating the horizontal plane around the point by the angles respectively. Using a lemma from [6, Lemma pinwheel], we show the following.
(Pinwheel)  Let and be two canonical drawings of a rooted ordered tree , where is at the same point in and . If and are (i) upward and leftward, or (ii) leftward and downward, or (iii) downward and rightward, or (iv) rightward and upward, respectively, then the morph is planar and lies in the interior of the right, top, left, or bottom half of the -box centered at , respectively. See Fig. 11.
The drawing can be obtained from the drawing in one morphing step, , where by we mean .
4 Morphing through lifting paths
Let be an -vertex tree with vertices and be a path decomposition of into paths. In this section, we describe an algorithm that morphs a plane drawing in plane of tree to the canonical 3D drawing of in steps. It lifts the paths of one by one applying procedure Lift. Note that the final positions for the vertices in are defined through heavy-rooted-pathwidth decomposition, and do not depend on . Also, a morph from to can be obtained by playing the morph from to backwards. At all times during the algorithm, the following invariant holds: a path is lifted only after all the children of the internal vertices of are lifted. After the execution of Lift, path moves to its canonical position with respect to . See Fig. 12-17.
Step 0: Preprocessing. This step is a single stretching morph with , see Section 3, stretching is a crossing-free morph.
4.1 Procedure Lift
Let be the first path in that has not been processed yet and be the current drawing of . We lift the path . For any vertex let lifted subtree be the portion of subtree that has been lifted after execution of Lift for some . The following invariants hold after every iteration of Lift procedure.
the drawing of in is the canonical drawing of with respect to for any ,
vertices of paths lie within X0Y plane.
We prove that these conditions hold after lifting . Let the processing vertices be the internal vertices of along with the vertices of their lifted subtrees.
The subtrees of all internal vertices in are already lifted.
All the paths that precede in are exactly the paths that are left after deleting from the forest of subtrees of (see paragraph Path decomposition in Section 2). From this fact it follows that all internal vertices of have become roots of some trees after deleting the edges of and edges of that trees were processed in Lift procedures for some . ∎
The maximum height of vertices in the drawing is strictly less than .
As all vertices of the processed paths are part of lifted subtrees of their head vertices, and by (I) have height as in canonical drawing, their height is strictly less than the number of vertices in a corresponding subtree, which does not exceed number of vertices in . ∎
For any vertex and its lifted subtree . The maximum horizontal distance in the lifted subtree of , i.e. the difference between -coordinates between any pair of vertices in in , does not exceed .
Note that the drawing of in is the canonical drawing of with respect to . This implies that the maximum horizontal distance between any vertex in and in is at most . ∎
Step 1: Shrink. For every internal vertex of the path its lifted subtree morphs into shrinked lifted subtree, see Sec. 3. All subtrees are shrinked simultaneously in one morphing step.
Step 1 is crossing-free.
For each lifted subtree this is a shrinking step and by Lemma 6 it is crossing-free.
All lifted subtrees were not overlapping in projection to X0Y plane due to Condition (I) and Lemmas 3 and 11 in the drawing . As all vectors of movement are vertical, projections of lifted subtrees can not overlap during this morphing step and can not cross with each other.
In shrinked drawing every vertex of except has strictly positive -coordinate which means that remains strictly above X0Y plane and can not cross with the part of that is still lying in X0Y. Internal vertices of do not change their positions during this morph. ∎
Step 2: Move others. This step consists of two morphs .
For , if projection overlaps with , we rotate twice the drawing of around the vertical pole through . Since every lifted subtree lies in , after this step all lifted subtrees lie in or .
Step 2 is crossing-free.
No edges within rotating lifted subtree can intersect as rotating is a mapping and mapping is a crossing-free morph (Lemma 5). Due to condition (II), all edges that do not lie in lifted subtrees are lying in X0Y plane. No lifted subtree can intersect with any edges in X0Y by condition (I): is the canonical drawing with respect to and lies strictly above X0Y plane except for the point . Rotation morph does not change -coordinate of points during the movement, so throughout the morph drawing of lies above X0Y plane, vertex does not move during the rotation as it lies on the pole.
No vertices move in X0Y plane during Step 2 and no crossing can happen within the plane X0Y. ∎
Step 3: Go up: This is one morphing step that moves each internal vertex of path vertically to the height defined recursively as follows: for : ; for : . Note that is an integer number equal to the height of shrinked lifted subtree .
Step 3 is crossing-free
Every internal vertex in the path moves with its subtree along the vertical vector. In the beginning of this morphing step no intersections existed in projection to plane between different subtrees and the path edges. Nothing changes in projection to plane during this step, all movements happen strictly above plane. That means that there can be no crossings during this step of an algorithm. ∎
After Step 3, all internal vertices of along with vertices of their subtrees are horizontally separated from the rest of the vertices of the tree by a horizontal plane.
The subtrees of internal vertices of are horizontally separated from each other.
Due to Lemma 10, -coordinates of all vertices that do not lie on the path are strictly below , also they are integer. By height definition in internal vertices of and vertices in their lifted subtrees have -coordinates at least .
So the plane is the horizontal plane of separation.
For every pair of internal vertices of , let us define the plane of separation as follows. From the definition of the height the horizontal plane separates lifted subtree of vertex from lifted subtree of vertex . ∎
Step 4: Rotate subtrees to horizontal plane. In this morphing step all lifted subtrees of internal vertices of path are rotated around a horizontal pole through to lie in a horizontal plane. The direction of rotation is chosen in such a way that does not cross with an edge throughout this morph. That is we rotate in the half-space that does not contain edge .
With the proper direction of rotation, Step 4 is crossing-free.
If the crossing happens it must include one of the moving edges, i.e., edges of lifted subtrees.
As subtrees are horizontally separated from each other after Step 3 by Lemma 15, edges of different lifted subtrees can not cross. Also by Lemma 15, subtrees can not cross with non-processing vertices or edges between them as they also are horizontally separated in the beginning and in the end of this step.
If for some the edge lied in the vertical plane through there was no crossings in and after the beginning of movement will no longer lie in that plane and no crossing can happen. If lied strictly within one of the half-planes defined by , then by the choice of direction of rotation we rotate through the half-space that does not contain and thus can not cross with this edge either. ∎
Step 5: Correct the path: In morph , each vertex () of the path moves together with its subtree along the vector , where denotes -coordinate of vertex in drawing . At the end of this step, the and coordinates of each are same as their and coordinates in the canonical drawing with respect to .
Step 5 is crossing-free
Step is crossing-free because all edges of the path and all subtrees of different vertices of the path (that lie in horizontal planes) are horizontally separated from each other. All moving edges are horizontally separated from already lifted subtrees with the plane by Lemma 15. ∎
Step 6: Go down: During the morphing step , every vertex of the path moves together with its subtree along the same vertical vector , where means -coordinate of vertex in drawing . At the end of this step, the coordinate of is the same as the coordinate of it in canonical drawing with respect to .
Step 6 is crossing-free
All moving edges are horizontally separated from already lifted subtrees with the plane . During the morph the vertical order of internal vertices of the path does not change as is a portion of a root-to-leaf path. From that it follows that horizontal separation of remains for different . ∎
Step 7: Turn subtrees in horizontal planes: It consists of two morphing steps , and turns every lifted subtree of internal vertices of to lie in positive -direction with respect to vertex . For every subtree that lies in negative -direction in the drawing , we use the morphing step from Lemma 8 to obtain a planar point reflection of across the point in horizontal plane containing .
Step 7 is crossing-free
The fact that point reflection of a tree across the point of its root can be performed as two steps and those steps are crossing-free follows from Lemma 8.
Vertices of different lifted subtrees are horizontally separated and separated from non-processing vertices and edges, which means no crossings can happen between them. ∎
Step 8: Stretch in -direction: This morphing step transforms lifted subtrees of internal vertices of in horizontal planes from shrinked to canonical size.
Step 8 is crossing-free.
Stretching here is a shrinking morph played backwards and is a crossing-free morph for every by Lemma 6.
As all are horizontally separated from each other and from unprocessed part of the tree and morph is horizontal no crossings can happen between different or and unprocessed part of the graph. ∎
Step 9: Rotate to canonical positions: In morph all lifted subtrees of the internal vertices of the path rotate around horizontal axes to lie in vertical plane in positive direction such that the subtree is in canonical position with respect to vertex .
Step 9 is crossing-free.
Let be the vertical plane parallel to X0Z and containing .
Vertices in subtrees lie from one side of in parallel planes at any moment of this morphing step. The half-planes that contain different are parallel because we can look at the rotation of the half-plane containing as at the rotation of the half-plane containing translated by the vector . Then at every moment angle which means that these half-planes are parallel to each other. So the vertices of do not cross.