Morphing tree drawings in a small 3D grid

We study crossing-free grid morphs for planar tree drawings using 3D. A morph consists of morphing steps, where vertices move simultaneously along straight-line trajectories at constant speeds. A crossing-free morph is known between two drawings of an $n$-vertex planar graph $G$ with $\mathcal{O}(n)$ morphing steps and using the third dimension it can be reduced to $\mathcal{O}(\log n)$ for an $n$-vertex tree [Arseneva et al.\ 2019]. However, these morphs do not bound one practical parameter, the resolution. Can the number of steps be reduced substantially by using the third dimension while keeping the resolution bounded throughout the morph? We answer this question in an affirmative and present a 3D non-crossing morph between two planar grid drawings of an $n$-vertex tree in $\mathcal{O}(\sqrt{n} \log n)$ morphing steps. Each intermediate drawing lies in a $3D$ grid of polynomial volume.


Introduction
Given an n-vertex graph G, a morph between two drawings (i.e., embeddings in R d ) of G 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 is crossing-free; such morphs are called crossingfree morphs.This concept finds applications in multiple domains: animation, modeling, and computer graphics, etc. [12][13][14][15].A drawing of G is a straight-line drawing if it maps each vertex of G to a point in R d and each edge of G 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 (d = 2) and 3D drawings (d = 3); a non-crossing drawing of a graph in R 2 is called planar.
The study of crossing-free graph morphs began in 1944 from a proof that such morphs for maximal planar graphs exist between two topologically equivalent drawings [11]; a matching algorithmic result appeared in 1983 [21].Recently crossing-free morphs of straight-line drawings are considered, where the vertex trajectories are simple.Of particular interest is morph transforming one straightline drawing Γ of a graph G to another such drawing Γ through a sequence Γ = Γ 1 , Γ 2 , . . ., Γ k = Γ of straight-line drawings.Linear morph between Γ i , Γ i+1 is a linear interpolation between the corresponding drawings and is also called a morphing step, or simply a step, for brevity.In each step of a linear morph, each vertex of G moves along a straight-line segment at a constant speed.Results [2][3][4]7] led up to a seminal paper by Alamdari et al. [1] showing that for any two topologically equivalent planar drawings of a graph G, there is a linear 2D morph that transforms one drawing to the other in Θ(n) steps.This bound is asymptotically optimal in the worst case even when the graph G 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 NP ∩ co-NP [16,18], and its containment in P is wide open.If the given graph is a tree, the worst-case tight bound of Θ(n) steps holds for 3D crossing-free linear morph [5] (and the lower-bound example is again a path).If both the initial and the final drawing are planar, then O(log n) steps suffice [5].
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 [6].
Barrera-Cruz et al. [8] gave an algorithm to morph between two straightline planar Schnyder drawings of a triangulated graph in O(n 2 ) steps; all the intermediate drawings of this morph lie in a grid of size O(n) × O(n).Very recently Barrera-Cruz et al. [6] gave an algorithm that linearly morphs between two planar straight-line grid drawings Γ and Γ of an n-vertex rooted tree in O(n) steps while each intermediate drawing is also a planar straightline drawing in a bounded grid.In particular, the maximum grid length and width is respectively O(D 3 n • L) and O(D 3 n • W ), where L = max{l(Γ ), l(Γ )}, W = max{w(Γ ), w(Γ )} and D = max{H, W }, l(Γ ) and w(Γ ) are the length and the height of the drawing Γ respectively.Note that D is Ω( √ n).
Here we study morphing one straight-line grid drawing Γ of a tree to another such drawing Γ in sublinear number of steps using three dimensions for intermediate steps.Effectively we ask the same question as in [5], but now with the additional restriction that all drawings throughout the algorithm should lie in a small grid.We give two algorithms that require O(n) steps and O( √ n log n) steps, respectively.All the intermediate drawings require a 3D grid of length O(d 3 (Γ ) • log n), width O(d 3 (Γ ) • log n) and height O(n), where d(Γ ) 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 [6].Our algorithm is the first one to morph between planar drawings of a tree in o(n) steps on a grid of polynomial volume.
In this work, we morph a 2D crossing free drawing of an n-vertex tree to the 3D canonical drawing of it and then analogously morph the 3D canonical drawing to the final drawing.During the procedure, we use some standard techniques, e.g., canonical drawing [5], rotation [8].Since a simple rotation on a fixed angle can not guarantee that the integral points map to the integral points, we generalize the concept of rotation to mapping.
In Section 4, we introduce a technique of lifting paths such that the vertices on the path along with their subtrees go the respective canonical positions and the drawing remains crossing free.The algorithm in Sec. 4 splits the given tree into disjoint paths that are lifted one by one in specific order by the described technique.
In Section 5, we introduce a technique of lifting a set of edges of the given tree.It is used for the algorithm that lifts the tree by dividing its edges into disjoint sets and lifting them one after another.We then merge the described algorithms together to produce an algorithm that uses o(n) morphing steps.

Preliminaries and Definitions
Tree drawings.For a tree T , let r(T ) be its root, and T (v) be the subtree of T rooted at a vertex v. Let V (T ) and E(T ) be respectively the set of vertices and edges of T , and let |T | denote the number of vertices in T .
In a straight-line drawing of T , each vertex u is mapped to a point in R 2 and each edge is mapped to a straight-line segment connecting its end-points.A 3D-(respectively, a 2D-) grid drawing of T is a straight-line drawing where each vertex is mapped to a point with integer coordinates in R 3 (respectively, R 2 ).A drawing of T is said to be crossing-free if images of no two edges intersect except, possibly, at common end-points.A crossing-free 2D-grid drawing is called a planar grid drawing.For a crossing-free drawing Γ , let B(Γ (v), r) denote the open disc of radius r in the XY 0 plane centered at the image Γ (v) of v. Unless stated otherwise, by the projection, denoted by pr(), we mean the vertical projection to the XY 0 plane.Let l(Γ ), w(Γ ) and h(Γ ) respectively denote the length, width and height of Γ , i.e., the maximum absolute difference between the x-,y-and z-coordinates of vertices in Γ .Let d(Γ ) denote the diameter of Γ , defined as the ceiling of the maximum pairwise (euclidean) distance between its vertices.Given a vertex v and an edge e of the tree T , dist Γ (v, e) denotes the distance between Γ (v) and Γ (e).Similarly, dist Γ (v, u) is the distance between Γ (v) and Γ (u).For a 3D-(Also, a 2D) grid drawing Γ , we define the resolution of Γ as the ratio of the distances between the farthest and closest pairs of geometric objects where points represent images of nodes and line segments represent edges in Γ .We define the vertical plane Y = 0 (respectively, X = 0) by XZ 0 (Y Z 0 ).We denote by XZ + 0 (XZ − 0 ) the vertical half-plane of XZ 0 with horizontal border-line going through the origin in X-positive (negative) direction.Similarly, XZ + v (XZ − v ) is the shifted half-plane XZ + 0 (XZ − 0 ) where the origin is translated to the vertex v and the horizontal border-line going through the vertex v. Y Z + v (Y Z − v ) denote the half-planes parallel to Y Z 0 passing through v in Y -positive (negative) direc-tion.We also define the horizontal plane passing through the origin by XY 0 .We similarly define XY + 0 and XY + v .
Lemma 1. 1. [6] For any vertex v and edge e not incident to v in a planar grid drawing of where c is an integral constant.The distance between any two distinct vertices in Γ 1 is at least c.
Proof. 1.Let us fix a vertex v ∈ V and an edge e = (u, w) ∈ E such that v = u, w.Let h be the distance between v and the line spanned by u, w. height in the triangle (v, u, w) from the vertex v, Let S be the area of triangle spanned by u, v, w.
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 Lemma 2. 1.For any vertex v and edge e not incident to v in a 3D-crossing free grid drawing of Γ of T , dist(v, e) ≥ 1 d(Γ ) . 2. For a pair of non-adjacent edges e 1 , e 2 , the distance dist(e 1 , e 2 ) ≥ 1 2 in a 3D crossing free grid drawing Γ of T .
Proof. 1.Let e is spanned by the vertices v 1 , v 2 .If v, v 1 , v 2 are co-linear, then dist(v, e) ≥ 1 since each vertex is mapped to a point with an integral coordinate in R 3 .Let us assume that the points are not co-linear.Let the coordinates of points be v = (x 0 , y 0 , z 0 ), The area of the triangles is , where . Since all the points have integral co-ordinates and they a re not co-linear, This implies that the area of the triangle spanned by . On the other hand, the area of the same triangle is 2. Let us assume that e 1 is spanned by the vertices v 1 , v 2 and e 2 is spanned by the vertices v 3 , v 4 .If these four points lie on the same plane, the problem maps to the previous one.We assume that these four points do not lie on a plane.Let the co-ordinates of points be v ) and v 4 = (x 4 , y 4 , z 4 ).Then the volume of the tetrahedron spanned by these four points is given by . On the other hand the volume of the same tetrahedron is given by the following determinant.1 6 .
This implies that the volume of the determinant spanned by these four vertices is at least 1 6 , since the points have integral co-ordinates.This also Path decomposition P of a tree T is a decomposition of its edges into a set of disjoint paths as follows.Choose a path in T and store it in P. Removal of this path may disconnect the tree; recurse on the remaining connected components.Note that during the removal of a path, we only delete its edges, not the vertices.
In the end, P contains disjoint paths whose union is T .The way of choosing paths may differ.The depth of a vertex v in T , denoted by dpt(v), is defined as the length of the path from r(T ) to v. Head of the path P , denotes as head(P ), is the vertex x ∈ P with the minimum depth in tree T .Let the internal vertices of the path be all vertices except head(P ).Any path decomposition P of T induces a linear order of the paths: path P succeeds P , i.e., P P , if and only if P is deleted before P during the construction of P. Note that the subtree of each internal vertex of a path P is a subset of the union of the paths that precede P .
In the long-path decomposition [9], the path chosen in every iteration is the longest root-to-leaf path (ties are broken arbitrarily).Let L = {L 1 , . . ., L m } be the ordered set of paths of a long-path decomposition of T .For i < j, Heavy-rooted-pathwidth decomposition [5].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 [10] with the name of rooted pathwidth when addressing the problem of computing upward tree drawings with optimal width.
The rooted pathwidth of a tree T , which we denote by rpw(T ), is defined as follows.If |T | = 1, then rpw(T ) = 1.Otherwise, let k be the maximum rooted pathwidth of any subtree rooted at a child of r(T ).Then rpw(T ) = k if exactly one subtree rooted at a child of r(T ) has rooted pathwidth equal to k, and Fig. 1: [5] The illustration (a) shows, for each vertex v of a tree T , the number rpw(T (v)).In particular, rpw(T ) = 3.The illustration (b) shows with bold lines the heavy edges of T forming the heavy paths H, H 0 , . . ., H 4 .The illustration (c) shows the path tree of T rpw(T ) = k + 1 if more than one subtree rooted at a child of r(T ) has rooted pathwidth equal to k; see Figure 1a.Clearly rpw(T ) is an integer number.
The heavy-rooted-pathwidth decomposition of a tree T is defined as follows refer to Figure 1b.For each non-leaf vertex v of T , let c * be the child of v in T such that rpw(T (c * )) is maximum (ties are broken arbitrarily).Then (v, c * ) is a heavy edge; further, each child c = c * of v is a light child of v, and the edge (v, c) is a light edge.Connected components of heavy edges form set of paths H(T ) = {H, H 0 , . . ., H k }, called heavy paths, which may have many incident light edges.The path tree of T is a tree whose vertices correspond to heavy paths in T ; see Fig. 1c.The parent of a heavy path P in the path tree is the heavy path that contains the parent of the vertex with minimum depth in P .The root of the path tree is the heavy path containing r(T ).
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 H(T ) simply as H.
We denote by H the root of the path tree of T ; let v 0 , . . ., v m−1 be the ordered sequence of the vertices of H, where v 0 = r(T ).For i = 0, . . ., m − 1, we let v 0 i , . . ., v ti i be the light children of v i in any order.Let L = u 0 , u 1 , . . ., u l−1 be the sequence of the light children of H ordered so that: (i) any light child of a vertex v j precedes any light child of a vertex v i , if i < j; and (ii) the light child v j+1 i of a vertex v i precedes the light child v j i of v i .For a vertex u i ∈ L, we denote by p(u i ) its parent; note that p(u i ) ∈ H.It is known [10] that the height of the path tree of an n-vertex tree T is at most rpw(T ) ∈ O(log n).
Fig. 2a shows the heavy-rooted-pathwidth decomposition of our running example where heavy paths are shown in different colors.
The canonical 3D drawing of a tree T , introduced in [5], is the crossing-free straight-line 3D drawing of T that maps each vertex v of T to its canonical position C(v) defined by the heavy-rooted pathwidth decomposition.
The canonical drawing of a tree T , denoted by C(T ), is defined as follows: -First, we set C(v 0 ) = (0, 0, 0) for the root v 0 of T .
-Second, for each i = 1, . . ., k − 1, we set C(v i ) = (0, 0, ). -Third, for each i = 1, . . ., k − 1 and for each j = 0, . . ., t i , we determine C(v j i ) as follows.If j = 0, then we set -Finally, in order to determine the canonical positions of the vertices in T (v j i )\ {v j i }, for each i = 0, . . ., k −2 and each j = 0, . . ., t i , we recursively construct the canonical 3D drawing of T (v j i ), and translate all the vertices by the same vector so that v j i is sent to C(v j i ).
We use the fact that C(T ) lies in the positive the XZ 0 quarter-plane, inside a bounding box of height |T | and width rpw(T ) such that the left-bottom point of the box represents the image of the root v and is mapped to the origin.Since tree T never changes throughout our algorithm, we refer rpw(T ) as rpw.For any vertex v of T , the relative canonical drawing C Tv of T (v) is the drawing of T (v) obtained by cropping it from C(T ) and translating the obtained drawing of T (v) so that v is mapped to the origin.

Tools for morphing algorithms
Stretching with a constant S 1 .Let the drawing Γ be lying in the the XY 0 plane.During the stretching morph each coordinate of each vertex in Γ is multiplied by a common positive integer constant S 1 .Thereby, it is a linear morph that "stretches" the vertices apart.
Lemma 3. The stretching morph is a crossing-free morph.

For a vertex
) does not enclose any other vertices or any part of edges non-incident to v i .3. For every vertex v and every edge e = (v, u) in Γ 1 , there is lattice point z such that z ∈ e and z ∈ B(Γ 1 (v i ), d(Γ )).
Proof. 1.Since the disk B(Γ (v i ), 1) contains no other vertices v j , j = i, then B(Γ 1 (v i ), S 1 ) does not contain other vertices too.The B(Γ 1 (v i ), S1 2 ), i.e., the disk with the radius S1 2 , does not intersect with any B(Γ 1 (v j ), S1 2 ) (for j = i) as S 1 is the stretching factor.2. Due to Lemma 1, no non-incident edges intersects the disk of radius 1 d(Γ ) around v i in Γ .That means that in Γ 1 , where all distances are multiplied by S 1 , no non-incident edges intersect the disk of radius Mapping around a pole Let the pole through (x , y ) be vertical line in 3D through point (x , y , 0).Let α, β be vertical half-planes containing the pole l through a point with integer coordinates.Suppose ∠(α, β) / ∈ {0, π} and α, β contain infinitely many points with integer coordinates.Mapping around the pole l 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 h which passing through the point (0, 0, b) where b is an integer.Let p α , p β be points that lie on h ∩ α and h ∩ β, respectively; such that dist(l, p α ) = d α and dist(l, p β ) = d β be the minimum non-zero distances from the l to the integer points lying in h ∩ α and h ∩ β.The vector of mapping u 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. 3.Then, we can define mapping by the following matrix.
Note that the determinant of the matrix is positive.This implies that the order type of the points does not change during mapping.Since the drawing in α is crossing free, the drawing obtained in β is also crossing free.Note that if the pole passes through the point (a, b) instead of the origin, we can first translate the point (a, b) to origin.We again translate back after mapping.
The rotation is a mapping when α, β are half-planes of planes parallel to the XZ 0 , Y Z 0 respectively and thus ∠(α, β) = π 2 .A horizontal pole is a line parallel to 0X axis.We similarly define a horizontal rotation which maps XZ 0 to XY 0 plane.
. ., v l } be the set of the children of v, ordered according to their z-coordinates in C Tv .Let C = {v i1 , . . ., v i k } be an ordered subset of C such that the members of C having same order among them as in C. Let us consider the new subtree T (v) which is obtained by deleting the vertices in C \ C and their subtrees.The drawing of T (v) obtained by deleting the vertices in C \ C and their subtrees from C Tv is denoted by C Tv (T v ), i.e., the canonical drawing of T (v) restricted to T (v).Note that any vertex of T (v) has same coordinate in C Tv and C Tv (T v ).Also, for each j satisfying 1 ≤ j ≤ k, T (v ij ) lies inside a box of height |T (v ij )| and width rpw(T (v ij )) on h.We define the shrink subtree procedure on C Tv (T v ) as follows.We move each vertex v ij along with their subtrees from Fig. 5: In the drawing there is an example of shrinking morph when l = 4.

Observation 2
The height of the shrunk subtree C T v is equal to the number of vertices in T (v).
Proof.Note that the subtree rooted at v has a 3D canonical drawing in C Tv (T v ).This implies that for 1 ≤ j ≤ k the subtree rooted at v ij also has the canonical drawing with respect to Let Γ, Γ be a unidirectional morph between two planar straight-line drawings Γ and Γ of T .Let u be a vertex of T , let vw be an edge of T and, for any drawing of T , let l vw be the line through the edge vw oriented from v to w. Suppose that u is to the left of l vw both in Γ and in Γ .Then v is to the left of l vw throughout Γ, Γ .Lemma 6. Shrinking is a crossing-free morph.
Proof.Note that the x and y coordinates of each vertex in C T v and C T v are the same and z-coordinate can only decrease, shrinking is obviously a unidirectional morph in vertical XZ plane which passes through v. Also, note that through out the morphing process all vertices in T v 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 the horizontal plane.Let Γ 0 (T (v)) be the canonical drawing of a subtree T (v) on the horizontal plane α, i.e. relative canonical drawing C Tv rotated around horizontal pole through v in any direction to lie in XY + v or XY − v half-plane.We discuss the case when Γ 0 (T (v)) lies in XY + v , the other case is similar.Let Γ 1 (T (v)), Γ 2 (T (v)), Γ 3 (T (v)) be the drawings obtained from Γ 0 (T (v)) by rotating the horizontal plane α around the point Γ (v) by the angles Lemma 7. (Pinwheel) [6] Let Γ and Γ be two canonical drawings of a rooted ordered tree T , where r(T ) 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 2n-box centered at r(T ), respectively.See Fig. 6.Lemma 8.The drawing Γ i (T (v)) can be obtained from the drawing Γ i−1 (T (v)) in one morphing step, i = 0, 1, 2, 3, where by Γ 0−1 (T (v)) we mean Γ 3 (T (v)).
Proof.Proof of this fact is the same as the proof of the Lemma 7 of [6].

Morphing through lifting paths
Let T be an n-vertex tree and P be a path decomposition of T into k paths.In this section, we describe an algorithm that morphs a plane drawing Γ = Γ 0 in the XY 0 plane of tree T to the canonical 3D drawing Γ = C(T ) of T in O(k) steps.It lifts the paths of P one by one applying the procedure Lift().Note that the final positions for the vertices in C(T ) are defined through heavy-rooted-pathwidth decomposition, and do not depend on P. Also, a morph from C(T ) to Γ can be obtained by playing the morph from Γ to C(T ) backwards.At all times during the algorithm, the following invariant holds: a path P i ∈ P is lifted only after all the children of the internal vertices of P i are lifted.After the execution of Lift(P i ), path P i moves to its canonical position with respect to head(P i ).See Fig. 7-20.

Procedure
Fig. 7: Drawing Γ t .In the picture there is the drawing Γ t after lifting all paths containing purple edges.All lifted subtrees are shown in light purple.
Let P i = (v 0 , v 1 , . . ., v m ) be the first path in P that has not been processed yet and Γ t be the current drawing of T .We lift the path P i .For any vertex v let lifted subtree T (v) be the portion of subtree T (v) that has been lifted after execution of Lift(P j ) for some j < i.The following invariants hold after every iteration of Lift() procedure.
(I) the drawing of T (v) in Γ t is the canonical drawing of T (v j ) with respect to v for any v ∈ V (T ), (II) vertices of paths P k , k > i lie within the XY 0 plane.We prove that these conditions hold after lifting P i .Let the processing vertices be the internal vertices of P i along with the vertices of their lifted subtrees.Lemma 9.The subtrees of all internal vertices v j in P i are already lifted.
Proof.All the paths that precede P i in P are exactly the paths that are left after deleting P i from the forest of subtrees of T (see paragraph Path decomposition in Section 2).From this fact it follows that all internal vertices of P i have become roots of some trees after deleting the edges of P i and edges of that trees were processed in Lift(P j ) procedures for some P j , j < i.
Lemma 10.The maximum height of vertices in the drawing Γ t is strictly less than n.
Proof.As all vertices of the processed paths are part of lifted subtrees of their head vertices, and by (I) have height as in the canonical drawing, their height is strictly less than the number of vertices in a corresponding subtree, which does not exceed number of vertices in T .
Lemma 11.For any vertex v and its lifted subtree T (v).The maximum horizontal distance in the lifted subtree T (v) of v, i.e. the difference between xcoordinates between any pair of vertices in T (v) in Γ t , does not exceed rpw.
Proof.Note that the drawing of T (v) in Γ t is the canonical drawing of T (v) with respect to v.This implies that the maximum horizontal distance between any vertex in T (v) and v in Γ t is at most rpw.
Overview The procedure Lift(P i ) consists of 13 steps and results in moving vertices of the path P i along with their lifted subtrees to their canonical positions with respect to the head of P i , i.e.,vertex v 0 .Note that the preprocessing Step 0 and Lemmas.4, 10 and 11 guarantee that the already lifted subtrees lie in the disjoint cylinders of radius rpw and height n.
Step 1 is a preparatory step and is needed to ensure that the maximum height of a vertex does not exceed 2n during the Lift(.)procedure.Step 1 is a simultaneous shrinking morph for already lifted subtrees of the internal vertices, and it is a crossing free morph since it happens in the corresponding disjoint cylinders.
Step 2 is also preparatory and is needed to make sure, that no intersections happen during Steps 3. In this step, lifted subtree of vertex v j (j < m) of P i is rotated to such a direction that in the projection it does not overlap with the edge (v j , v j+1 ).
In Step 3, all the internal vertices along with their lifted subtrees are moved vertically such that height that all T (v j )(lifted subtrees of internal vertices) become horizontally separated from each other and from the non-processed part of the tree.Note that the vertices of P i are in the same vertical order as in the C(T ).
In Step 4, lifted subtree of each of the internal vertices is rotated to lie in a horizontal plane through the corresponding vertex.This step places all T (v j ) in disjoint horizontal planes.
After that we want to get C(T (v 1 )), i.e., the canonical drawing of all the subtree of v 1 , translated to the current position of v 1 .During Steps 5-9 we do not move vertex v 1 and other non-processing vertices.
Steps 5 and 6 move v 2 , . . ., v m to their canonical positions with respect to the vertex v 1 (Step 5 corrects x, y-coordinates and Step 6 corrects z-coordinate).During both of these steps every lifted subtree of v 2 , . . ., v m moves along the same vector as its root vertex.
Steps 7, 8 and 9 place lifted subtrees of the internal vertices to the canonical positions with respect to v 1 .In the canonical drawing, every subtree lies in x+ direction from its root.Step 7 simultaneously turns (if needed) every subtree of the internal vertices in y+ direction.Then in Step 8, we need to make the inverse step to Step 1 and morph T (v j ) from shrunk drawing to the canonical one.In Steps 7 and 8, all vectors of movements are horizontal and no intersections can happen due to disjointness of the corresponding horizontal planes.After Step 8 every lifted subtree of internal vertices is already in canonical position with respect to its root, but lying in XY + instead of XZ + .In Step 9, we rotate T (v j ) to the vertical plane simultaneously for every internal vertex v j .
Steps 10-13 move v 1 with its subtree T (v 1 ) and (if needed) T (v 0 ) to its canonical position with respect to v 0 .Step 10 horizontally moves T (v 1 ) towards the vertical pole through v 0 until T (v 1 ) lies within the cylinder of radius rpw + d(Γ ) and height 2n around v 0 .Due to Lemmas.4, 10 and 11, we know that these cylinders are disjoint for different unprocessed vertices that still lie in XY 0plane.Step 10 ensures that Steps 11-13 move vertices only inside this cylinder and the processed part of the tree does not intersect with the unprocessed part.
Steps 11-13 differ depending whether or not we have rotated T (v 0 ) during Step 2. In one case T (v 0 ) is in x+ direction from v 0 and in the other T (v 1 ) is in x+ direction from v 0 .Steps 11 and 13 make two rotations of the needed part of the tree to correct x, y-coordinates.Also, we need to move v 1 and its subtree to the canonical height with respect to v 0 .In Step 12, we make the z-coordinate correction of T (v 1 ).The steps are ordered in such a way that no intersections happen during their execution.
Step 13 concludes the procedure Lift(P i ), placing all processing vertices into their canonical positions with respect to v 0 , the head of the lifted path.Step 1: Shrink.
For every internal vertex v j of the path P i its lifted subtree T (v j ) morphs into the shrunk lifted subtree, see Sec. 3.All subtrees are shrunk simultaneously in one morphing step.

Lemma 12.
Step 1 is a crossing-free morph.
Proof.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 XY 0 plane due to Condition (I) and Lemmas 4 and 11 in the drawing Γ t .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 shrunk drawing every vertex of T (v j ) except v j has strictly positive zcoordinate which means that T (v j ) \ {v j } remains strictly above XY 0 plane and can not cross with the part of T that is still lying in the XY 0 .Internal vertices of P i do not change their positions during this morph.
This step consists of two morphs Γ t , Γ t+1 , Γ t+1 , Γ t+2 .For 0 ≤ j < i − 1, if projection pr(T (v j )) overlaps with pr((v j , v j+1 )), we rotate twice the drawing of T (v j ) around the vertical pole through Γ t (v j ).Since every lifted subtree T (v j ) lies in XZ + vj , after this step all lifted subtrees lie in XZ + vj or XZ − vj .
Step 2 is a crossing-free morph.
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 the XY 0 plane.No lifted subtree T (v j ) can intersect with any edges in the XY 0 by condition (I): Γ t (T (v j )) is the canonical drawing with respect to v j and lies strictly above XY 0 plane except for the point Γ t (v j ).Rotation morph does not change z-coordinate of points during the movement, so throughout the morph drawing of T (v j ) lies above XY 0 plane, vertex v j does not move during the rotation as it lies on the pole.
No vertices move in the XY 0 plane during Step 2 and no crossing can happen within the plane XY 0 .
Step 3: Go up: This is one morphing step Γ t+2 , Γ t+3 that moves each internal vertex v j , j ≥ 1 of path P i vertically to the height defined recursively as follows: for v 1 : ).Note that h sh (T (v j )) is an integer number equal to the height of the shrunk lifted subtree T (v j ).

Lemma 14.
Step 3 is a crossing-free morph.
Proof.Every internal vertex v j in the path P i moves with its subtree T (v j ) along the vertical vector.In the beginning of this morphing step no intersections existed in projection to the XY 0 plane between different subtrees and the path edges.Nothing changes in projection to the XY 0 plane during this step, all movements happen strictly above the XY 0 plane.That means that there can be no crossings during this step of an algorithm.
Lemma 15. 1.After Step 3, all internal vertices of P i along with vertices of their subtrees are horizontally separated from the rest of the vertices of the tree by a horizontal plane.2. The subtrees of internal vertices of P i are horizontally separated from each other.
Proof. 1. Due to Lemma 10, z-coordinates of all vertices that do not lie on the path are strictly below n, also they are integer.By height definition in Γ t+3 internal vertices of P and vertices in their lifted subtrees have z-coordinates at least n.So the plane (x, y, n − 1 2 ), x, y ∈ R is the horizontal plane of separation.2. For every pair of internal vertices v j , v k , j < k of P , let us define the plane of separation as follows.From the definition of the height Γ t+3 (v k ) z the horizontal plane (x, y, Γ t+3 (v k ) z − 1 2 ), x, y ∈ R separates lifted subtree of vertex v j from lifted subtree of vertex v k .
Step 4: Rotate subtrees to horizontal plane.In this morphing step, Γ t+3 , Γ t+4 all lifted subtrees T (v j ) of internal vertices of path P i are rotated around a horizontal pole through Γ t+3 (v j ) to lie in a horizontal plane.The direction of rotation is chosen in such a way that T (v j ) does not cross with an edge (v j , v j+1 ) throughout this morph.That is we rotate in the half-space that does not contain the edge (v j , v j+1 ).
Lemma 16.With the proper direction of rotation, Step 4 is a crossing-free morph.
Proof.If the crossing happens it must include one of the moving edges, i.e., edges of lifted subtrees.
As subtrees T (v j ) 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 T (v j ) 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 j, 1 ≤ j ≤ m the edge (v j , v j+1 ) lied in the vertical plane through T (v j ) there was no crossings in Γ t+3 and after the beginning of movement T (v j ) will no longer lie in that plane and no crossing can happen.If (v j , v j+1 ) lied strictly within one of the half-planes defined by T (v j ), then by the choice of direction of rotation we rotate through the half-space that does not contain (v j , v j+1 ) and thus can not cross with this edge either.
Step 5: Correct the path: In morph Γ t+4 , Γ t+5 , each vertex v j (j ≥ 2) of the path P i moves together with its subtree T (v j ) along the vector ((v 1x −v jx )+C(v j ) x −C(v 1 ) x , v 1y −v jy , 0), where v 1x denotes x-coordinate of vertex v 1 in drawing Γ t+4 .At the end of this step, the x and y coordinates of each v j are same as their x and y coordinates in the canonical drawing with respect to v 1 .

Lemma 17.
Step 5 is a crossing-free morph.

Proof.
Step is crossing-free because all edges of the path i and all subtrees of different vertices v j of the path P i (that lie in the horizontal planes) are hori-zontally separated from each other.All moving edges are horizontally separated from already lifted subtrees with the plane z = n by Lemma 15.
Step 6: Go down: During the morphing step Γ t+5 , Γ t+6 , every vertex v j , j ≥ 2 of the path P i moves together with its subtree T (v j ) along the same vertical vector (0, 0, (v 1z − v jz ) + C(v j ) z − C(v 1 ) z ), where v 1z means z-coordinate of vertex v 1 in drawing Γ t+5 .At the end of this step, the z coordinate of v j is the same as the z coordinate of it in the canonical drawing with respect to v 1 .

Lemma 18.
Step 6 is a crossing-free morph.
Proof.All moving edges are horizontally separated from already lifted subtrees with the plane z = n.During the morph the vertical order of internal vertices of the path does not change as P i is a portion of a root-to-leaf path.From that it follows that horizontal separation of T (v j ) remains for different j.
Step 7: Turn subtrees in the horizontal planes: It consists of two morphing steps Γ t+6 , Γ t+7 , Γ t+7 , Γ t+8 , and turns every lifted subtree T (v j ) of internal vertices of P i to lie in positive x-direction with respect to vertex v j .For every subtree that lies in negative x-direction in the drawing Γ t+6 , we use the morphing step from Lemma 8 to obtain a planar point reflection of T (v j ) across the point v j in the horizontal plane containing T (v j ).

Lemma 19.
Step 7 is a crossing-free morph.
Proof.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 y-direction: This morphing step Γ t+8 , Γ t+9 transforms lifted subtrees of internal vertices of P i in the horizontal planes from shrunk to the canonical size.

Lemma 20.
Step 8 is a crossing-free morph.
Proof.Stretching here is a shrinking morph played backwards and is a crossingfree morph for every T (v j ) by Lemma 6.
As all T (v j ) are horizontally separated from each other and from unprocessed part of the tree and morph is horizontal no crossings can happen between different T (v j ) or T (v j ) and unprocessed part of the graph.
Step 9: Rotate to the canonical positions: In morph Γ t+9 , Γ t+10 all lifted subtrees T (v j ) of the internal vertices of the path rotate around horizontal axes (x, v jy , v jz ), x ∈ R to lie in vertical plane in positive direction such that the subtree T (v 1 ) is in the canonical position with respect to vertex v 1 .

Lemma 21.
Step 9 is a crossing-free morph.
Proof.Let H be the vertical plane parallel to XZ 0 and containing v 1 , . . ., v m .
Vertices in subtrees T (v j ) lie from one side of H in parallel planes at any moment of this morphing step.The half-planes that contain different T (v j ) are parallel because we can look at the rotation of the half-plane α containing T (v j ) as at the rotation of the half-plane β containing T (v k ), j, k ∈ {1, . . ., m} translated by the vector Γ t+9 (v j ) z − Γ t+9 (v k ) z .Then at every moment angle ∠(α, XZ) = ∠(β, XZ) which means that these half-planes are parallel to each other.So the vertices of T (v j ) do not cross.
T (v j ) remains in the same half-space from H during all morph for every j = 1, . . ., m.This means that subtrees that lie from different sides of H do not cross too.
At the end of this step subtree of vertex v 1 of the drawing Γ t+10 is at its canonical positions with respect to to vertex v 1 and therefore does not have any crossing within itself.

Lemma 22.
Step 10 is a crossing-free morph.

Proof.
Step is crossing-free because all the vertices of the path P are horizontally separated from other subtrees of other vertices in the plane XY 0 (all already lifted subtrees have height at most n − 1 and all processing vertices have z-coordinates at least n) and the only not-separated edge (v 0 , v 1 ) moves along such a vector, that its projection does not change angle in the XY 0 plane.
All the steps from 11 to 13 are split in two different cases depending on whether we turned T (v 0 ) during Step 2 or not.Case 1 describes all three steps when T (v 0 ) was not rotated since pr(v 0 , v 1 ) and T (v 0 ) did not overlap after Step 1.This implies that in Γ t+11 already lifted subtree of v 0 lies in XZ + v0 (Fig. 19).Case 2 describes all three steps if overlap happened and T (v 0 ) was rotated twice to lie in XZ − v0 (Fig. 20).
Step 11: First part of xy-correction: Case 1: If in Step 2 T (v 0 ) was not rotated, during Γ t+11 , Γ t+12 all internal vertices of P with their subtrees T (v j ) move along the same horizontal vector until the edge (v 0 , v 1 ) lie on the half-plane parallel to Y Z 0 and The direction is chosen so that the angle between pr((v 0 , v 1 )) in Γ t+11 and pr((v 0 , v 1 )) in Γ t+12 is minimal.Case 2: If during Step 2 T (v 0 ) was rotated, which means that the edge (v 0 , v 1 ) was parallel to 0X, then pr((v 0 , v 1 )) is still parallel to 0X, because we have not changed its direction.By definition of Step 2 we know that T (v 0 ) in Γ t+11 lies in XZ − v0 .We are rotating T (v 0 ) around the pole through v 0 to lie in Y Z + v0 .
Step 11 is a crossing-free morph.
Proof.Case 1: All vectors of movement in T (v 1 ) are the same, which means no crossing can happen in T (v 1 ).Also T (v 1 ) is horizontally separated from the unprocessed part of T , which is motionless.
Case 2: Rotation is a crossing-free morph and in projection happens within B(Γ t+11 (v 0 ), rpw+d(Γ )).For the same reasons as in Case 1 no crossings happen.
Γ t+12 , Γ t+13 morphing step is a vertical morph.In Γ t+12 , the z-coordinates of internal vertices of P are n more than their canonical z-coordinates with respect to v 0 .We decrease the z-coordinates of internal vertices along with all their subtrees by n.

Lemma 24.
Step 12 is a crossing-free morph.

Proof. Case 1:
Step is crossing-free because T (v 0 ) and T (v 1 ) lie in distinct parallel planes and do not intersect in projection in Γ t+12 .Vertical morph does not change the projection of the drawing so separation remains.Edge (v 0 , v 1 ) and T (v 0 ) after Step 11 lie in different planes too.
Case 2: During Step 12 (v 0 , v 1 ) and T (v 1 ) are in XZ + v0 .T (v 0 ) during the same step is in XZ − v0 .They can not make any crossings because they do not intersect in projection during all this morph.
Case 1 All processing vertices move along the same horizontal vector so that after this movement vertex v 1 lies in the canonical position with respect to v 0 .As T (v 1 ) is already in the canonical position with respect to v 1 , after Step 13 it is in the canonical position with respect to v 0 .
Case 2 T (v 1 ) and (v 0 , v 1 ) are in the canonical positions with respect to v 0 after Step 12: in Step 10 we got x, y-coordinates equal to (v 0x + (C(v 1 ) x − C(v 0 ) x ), v 0y + (C(v 1 ) y − C(v 0 ) y ) because (v 0 , v 1 ) was parallel to 0X axis, after Step 12 we have corrected z-coordinates.In this case, we rotate T (v 0 ) to XZ + v0 , i.e. to its canonical position with respect to v 0 .In both cases processing vertices and T (v 0 ) lie in the canonical position with respect to v 0 in Γ t+14 , they all now form new lifted subtree of vertex v 0 .
Step 13 is a crossing-free morph.
Proof.Case 1: During the morph projections of (v 0 , v 1 ), T (v 1 ), T (v 0 ) do not cross.In the end of the step T (v 1 ) and (v 0 , v 1 ) lie in the canonical positions with respect to v 0 , T (v 0 ) was already in the canonical position with respect to v 0 by condition (I), so at the end of the morph they can not cross too.
Case 2: Rotation is a crossing-free morph and in the end of this step we get T (v 0 ), T (v 1 ) and (v 0 , v 1 ) to be in the canonical positions with respect to v 0 and C Tv 0 does not contain any crossings.
In the end of these morphing steps, we observe that all the internal vertices of P i along with their subtrees are placed in the canonical position with respect to v 0 .We keep on lifting up paths until we obtain the canonical drawing of T .

Correctness of the algorithm
Lemma 26.Conditions (I) and (II) hold after performing Lift(P i ) for each Fig. 19: Step 11-13.Case 1 Fig. 20: Step 11-13.Case 2 Proof.(I) the drawing of T (v) in Γ t is the canonical drawing of T (v) with respect to v for any v ∈ V (T ) Base of the induction: i = 1: Note that after performing the stretching step the whole T lies on the XY 0 plane.Since none of the paths are lifted, condition (I) trivially holds.The induction step: By induction hypothesis every T (v) for internal vertex v lies in position needed before Lift(P i ) procedure.After Step 5 all internal vertices have the canonical x, y-coordinates with respect to vertex v 1 and after Step 6 -the canonical z-coordinates with respect to v 1 also.Steps 7 and 8 guarantee that T (v j ), j = 1, . . ., m are in the canonical position with respect to to their roots rotated to horizontal plane in positive x-direction.Steps 1 and 8 are mutually inverse planar morphs for every T (v j ), 1 ≤ j ≤ m which means that the canonical coordinates with respect to the roots will remain the same after Step 8 but in the horizontal direction.
Step 9 lifts subtrees of internal vertices into vertical canonical position and T (v 1 ) is in the canonical position with respect to vertex v 1 .Steps 10-13 move T (v 1 ) along with v 1 , so after Lift(P ) procedure T (v 1 ) is in the canonical position with respect to v 1 .
Steps 10, 11, 13 place v 1 in the canonical xy-position with respect to v 0 and Step 12 makes it y-canonical.So after Step 13 old T (v 0 ) along with new edge (v 0 , v 1 ) and subtree T (v 1 ) is in the canonical position with respect to v 0 .As for the other vertices in the XY 0 , their lifted subtrees had not moved during Lift(P ) procedure and are in the canonical positions with respect to their roots by induction hypothesis.(II) vertices of paths P k , k > i are lying within the XY 0 plane Base of the induction: i = 1: The condition (II) holds since the entire tree T lies in the XY 0 plane.The induction step: By induction hypothesis before Lift(P ) procedure all vertices of nonprocessed paths lie in the XY 0 plane.Internal vertices of the path P can not lie in the other non-processed paths than P by definition of path decomposition.That means that after Lift(P ) in which we move only processed paths, i.e. lifted subtrees, or internal vertices of the P , all vertices that lie on non-processed paths will still lie in the XY 0 plane.
Lemma 27.All morphing steps in the algorithm are integer.
Proof.Let us prove this by induction on number of lifted paths.The base case is trivial.After the stretching morph all coordinates of all vertices are integer because the constant of stretching is integer and in the given drawing Γ all vertices had integer coordinates.
By induction hypothesis in the beginning of Lift(P ) procedure all vertices lie on lattice points of the grid.During Lift(P ) procedure non-processed vertices and vertex v 0 do not change coordinates at all.Rotation and shrinking morphs move points with integer coordinates to points with integer coordinates.Turning of the subtrees in the horizontal planes in Step 7 is integer by definition (see [6]).In all other steps the lifted subtrees of internal vertices are moved along with their roots by the integer vector.
As all coordinates at the beginning of Lift(P ) were integer and all vectors of movement of all vertices in every step were integer, after Lift(P ) procedure all vertices still have integer coordinates.
Complexity of the algorithm Let us estimate the size of the required grid: Our graph T = (V, E), |V | = n will have drawing Γ = Γ 0 that takes space l(Γ ) × w(Γ ) 1.
First step of the algorithm multiplies needed space by S 1 = 2 • (rpw + d(Γ )).In the beginning of our algorithm, lifted subtrees of all vertices lie in planes parallel to XZ 0 plane passing through the corresponding vertices.They take no more than O(rpw) space in x, y direction and no more than n − 1 in z direction.During the execution of the algorithm (during Step 4-Step 8), we rotate lifted subtrees of the internal vertices of the path to lie in horizontal planes passing through the corresponding vertices, at this point the subtrees take no more than n − 1 space in y-direction (and same O(rpw) in x-direction).During "Pinwheel" rotation in Step 7, those subtrees take no more than n − 1 space in x-direction (and same O(rpw) in y-direction).As in z-direction every lifted subtree drawing takes no more than n height, during Lift() procedure, we may get vertices at height at most n + n.
So the space is: Note that the estimation of rpw(T ) = O(log n) [5] and it is asymptotically less than d(Γ ) ≥ √ n.Also note that d 2 (Γ ) ≥ n.This implies that we can accommodate horizontal subtrees in the grid of aforementioned size.The lemmas proved in this section along with the space and time complexity bounds prove the following Theorem.Theorem 1.For every two planar straight-line grid drawings Γ, Γ of tree T with n vertices there exists a crossing-free 3D-morph M = Γ = Γ 0 , . . ., Γ l = Γ that takes O(k) steps where k is number of paths in some path decomposition of tree T .In this morph, every intermediate drawing where d is maximum of the diameters of the given drawings.
Corollary 1.For every two planar straight-line grid drawings Γ, Γ of tree T with n vertices there exists a crossing-free 3D-morph M = Γ = Γ 0 , . . ., Γ l = Γ that takes O(n) steps and O(d 2 ×d 2 ×n) space to perform, where d is maximum of the diameters of the given drawings.In this morph, every intermediate drawing Proof.Bound O(n) to the number of paths in P is obvious.

Morphing through lifting edges
In this section, we describe another algorithm that morphs a planar drawing Γ of tree T to the canonical drawing C(T ) of T .This time one iteration of our algorithm lifts simultaneously a set of edges with at most one edge of each path of a selected path decomposition.Let Γ = Γ 0 be a planar drawing of T .
Step 0: Preprocessing.This step Γ, Γ 1 is a stretching morph with , stretching is a crossing-free morph.

Lif t(edges) procedure
For edge e of T , let starting vertex of the edge st(e) (respectively, ending vertex of the edge end(e)) be the vertex of e with smallest (respectively, largest) depth.Let K = {K 1 , . . ., K m } be the partition of edges of T into disjoint sets such that e ∈ K i if and only if dpt(st(e)) = m − i, where m denotes the depth of T .We lift up sets K i from K from i = 1 to i = m by running the following procedure Lif t(K i ) (Steps 1-5).Let Γ t be the drawing of T before lifting set K i .
Let lifted subtree T (v j ) be the portion of subtree T (v j ) lifted by the execution of Lif t(K j ) where j < i. Conditions that we maintain throughout the algorithm are the following: (I) The drawing of T (v) in Γ t is the canonical drawing of T (v) with respect to v. (II) The vertices that lie on edges in a set that is not yet processed are lying in the XY 0 plane.
Let the processing vertices be the ending vertices end(e) of every edge e from K i along with the vertices of their subtrees T (end(e)).
Lemma 28.For every edge e = (v, u) with st(e) = v in Γ 1 there is a lattice point z e ∈ e such that: . . .For edges e 1 , e 2 ∈ K i with a common start vertex v we get points z 1 , z 2 from Lemma 4 in Γ 1 .We have dist(z 1 , z 2 ) ≥ 1 because z 1 , z 2 are lattice points of the grid.Then by definition of z e1 , z e2 we have dist Γ1 (z e1 , z e2 ) ≥ 2 • rpw and for different edges e in K i disks B(Γ 1 (z e ), rpw) do not intersect.3.For e 1 = (v, u 1 ), e 2 = (v, u 2 ) by Lemma 1 dist(z 1 , e 2 ) ≥ 1 2•d(Γ ) , because z 1 , (v, z 2 ) can be interpreted as drawing within B(Γ 1 (v), d(Γ )) with the diameter at most 2 • d(Γ ).Then dist(z e1 , e 2 ) ≥ (4 ) is realized at one of the endpoints of the segments, for z ej , j = 1, 2 it is at least 2 • rpw as we know from above.For vertices u j , j = 1, 2 by Lemma 4 disk B(Γ t (u j ), 2 • rpw) does not intersect with any edges non-incident to u j or contain any other vertices than u j .That means that all segment (z e1 , u 1 ) is at distance at least 2 • rpw from segment (z e2 , u 2 ) and F e1 , F e2 do not intersect.
For edges e 1 , e 2 with different start vertices we have that e 1 , e 2 do not have common endpoints by the definition of K i .Then e 1 = (v 1 , v 2 ), e 2 = (v 3 , v 4 ) and for the same reasons as above the corresponding regions are disjoint.Overview The procedure Lif t(K i ) consists of 5 steps and results in moving the end vertices of the edges of the set K i along with their subtrees rooted at them to their canonical positions with respect to the corresponding starting vertices of the edges of K i .Note that by preprocessing Step 0, Lemma 4 and by the similar arguments as in Lemmas 10 and 11, we ensure that already lifted subtrees lie in disjoint cylinders of radius rpw and height n.
During Step 1 and 2 vertices of each processing subtree T (end(e))), e ∈ K i , move along the same vector as the root end(e).In Step 1 we move simultaneously ending vertices of the edges horizontally towards the starting vertices of the corresponding edges in K i until they reach certain points specified in Lemma 28.Firstly, this step ensures that all later steps are performed in different disjoint cylinders for different starting vertices of the edges in K i .Secondly, it also ensures that for the ending vertices with a common starting vertex, Step 3 is a crossing free morph.
Step 2 moves all ending vertices to their canonical height with respect to the corresponding starting vertices in K i .This step corrects z-coordinates of all the processing vertices with respect to the corresponding starting vertices.
The following Steps 3-5 move the processing vertices only horizontally and correct their x, y-coordinates.Step 3 simultaneously maps every lifted subtree T (end(e)) to the vertical plane containing the corresponding edge e ∈ K i .Idea of this step is to put different subtrees T (end(e)) with a common vertex st(e) to separate vertical half-planes around the pole through st(e) and to avoid intersections during Step 5.
Step 4 moves the ending vertices of edges in K i towards the pole trough the corresponding starting vertices until the last integer point.After this step the drawing in every half-plane that contains edge e and subtree T (end(e)) differs from the canonical drawing of this part of the tree with respect to the st(e) by the rotation and by some stretching factor.
Step 5 collapses all planes around each of the starting vertices in K i in one.In every iteration it divides neighbouring planes in pairs and maps one to another.
Step 5 may take up to log(∆(T )) morphing steps, where ∆(T ) is the maximum degree of the vertices in T .
Step 5 concludes the procedure as after the collapse of all half-planes around each vertex st(e) and mapping it to the x+ direction from st(e) we get the canonical drawing of T (st(e)) with respect to st(e).
Step 1: Shrink.In the step Γ t , Γ t+1 , for every edge e ∈ K i we move vertex end(e) along with its lifted subtree towards st(e) until end(e) reaches point z e .

Lemma 29.
Step 1 is a crossing-free morph.
Proof.Vertices that lie in the XY 0 plane do not move or move along their incident edges, so no intersections can happen in the XY 0 .
For the moving subtrees we know from Lemma 28 that they do not intersect because each lifted subtree in projection lies in the corresponding region F e throughout the whole morph and these regions do not intersect for different e ∈ K i .
From Conditions (I) and (II) it follows that no intersections happen during this morphing step.

Lemma 30.
Step 2 is a crossing-free morph.
Proof.For every vertex v let End(v) be a set of edges, for which v is a start vertex.All edges of End(v) are contained in one set K i because their depth is defined by dpt(v).That means that if we are lifting some edges with start vertex v, then v does not have any lifted subtree in the beginning of Lif t(K i ) procedure.In projection to XY 0 plane in Γ t+1 lifted subtrees of the same or different vertices do not intersect.
During this morphing step we do not change projection and move every lifted subtree by the same vertical vector, so no intersections can happen between the subtrees and between the edges of the same subtree.Vertices of unprocessed sets are lying still in the XY 0 plane and can not make any intersections too.
Morphing step Γ t+2 , Γ t+3 is a mapping morph, see Section 3.For every lifted subtree T (v j ), where v j = end(e), e ∈ K i , we define the half-planes of the mapping morph as follows: half-plane α is XZ + vj , half-plane β is part of the vertical plane containing the edge e in such direction that e / ∈ β, the common vertical pole of α and β is a pole through v j .All mapping steps are done simultaneously for all subtrees of end vertices of the edges of K i .

Lemma 31.
Step 3 is a crossing-free morph.
Proof.By Lemma.5 mapping is a crossing-free morph and no intersections happen in every T (v j ).
Movement of every T (v j ) for v j = end(e) happens in projection to XY 0 plane in the region F e defined for e and st(e): distance from vertices of T (v j ) to e decreases and e has at least rpw + 1 integer points on it so in Γ t+1 and Γ t+2 projections of vertices of T (v j ) lie in F e .
Different lifted subtrees do not intersect as they do not intersect in projection to XY 0 during this step.Other vertices do not move and also make no intersections.Step 4: Shrink more.The morphing step Γ t+3 , Γ t+4 is a horizontal morph.For each v j = end(e), e ∈ K i we define a horizontal vector of movement as following.If e is a vertical edge in the canonical drawing then this vector is (Γ t+3 (st(e)) x − Γ t+3 (end(e)) x , Γ t+3 (st(e)) y − Γ t+3 (end(e)) y , 0), in this case subtree T (end(e)) is moving towards vertical pole through st(e) until the image of the edge e becomes vertical.
If e is not a vertical edge in the canonical drawing, then C(end(e)) x − C(st(e)) x = 1 and we move the whole subtree T (end(e)) in the same direction towards the pole through Γ t+3 (st(e)) until end(e) reaches the last point with integer coordinates before (Γ t+3 (st(e)) x , Γ t+3 (st(e)) y , Γ t+3 (end(e)) z ).Note that end(e) maps to the same point if we map the canonical drawing of end(e) with respect to the st(e) from XZ + st(e) to the vertical plane containing end(e).
Step 4 is a crossing-free morph.
Proof.Every lifted subtree moves inside its half-plane.That means that different subtrees T (end(e j )) with the same st(e j ) do not intersect in projection to XY 0 plane and though do not intersect with each other.Subtrees with different st(e j ) in projection lie in non-crossing disks ) by Lemma 28 and also can not intersect during this morph.
Step 5: Collapse planes.During the following steps Γ t+4 , Γ t+5 , . . ., Γ t+5+log k , Γ t+5+log k+1 we iteratively divide half-planes that contain T (end(e)), e ∈ K i around each vertex st(e), e ∈ K i in pairs, pairs are formed of neighboring half-planes in clockwise order around the pole through st(e).If in some iteration there are an odd number of planes around some pole, the plane without pair does not move in this iteration.In every iteration we map the drawing of one plane in the pair to another simultaneously in all pairs.As around each vertex we can have at most k = ∆(T ) number of half-planes, we need at most O(log k) number of mapping steps to collapse all planes in one and to rotate the resulting image to XZ + st(e) Lemma 33.
Step 5 is a crossing-free morph.
Proof.Since mapping is a crossing-free morph, no intersection can happen in a particular subtree.We now argue that no intersection can happen between two different subtrees.
After step 4, each T (end(e)), e ∈ K i is in the canonical position with respect to st(e) but mapped from XZ + st(e) to the vertical half-plane containing e.During the mapping morph, we keep the invariant that the closest integral point to the pole in one plane maps to the closest integral point in the other plane.Then, other integer points are mapped proportionally.
This implies that after mapping the plane α containing one subtree to the plane β containing another subtree, in the plane β, we have two subtrees drawn in such a way that as if it is obtained by mapping the canonical drawings of the both the subtrees with respect to st(e) from the XZ + st(e) to β.So during each morphing step and at the end of every morphing step no intersections can happen.
Every mapping step for every st(e) is happening in projection to XY 0 in its ) so mappings for different st(e) can not intersect too.
All other non-processed vertices and st(e) do not change their positions during the morph, hence can not make any intersections.
We perform Lif t() for each K i ∈ K till we obtain the canonical drawing of T .
Lemma 34.Conditions (I) and (II) hold after performing Lif t(K i ) for each 1 ≤ i ≤ m.
Proof.(I) the drawing of T (v) in Γ t is the canonical drawing of T (v) with respect to v for any v ∈ V (T ) Base of the induction: i = 1: Note that after performing the stretching step the whole T lies on the XY 0 plane.Since none of the paths are lifted, condition (I) trivially holds.The induction step: By induction hypothesis every T (v) for end vertex of any edge in K i lies in position needed before Lif t(K i ) procedure.After Step 2 all end vertices of the edges of K i have the canonical z-coordinates with respect to the start vertices of their edges.Then Step 4 for any edge e in K i makes distances from the vertex end(e) and vertices of its subtree to the pole through st(e) proportional to their canonical y-coordinate.After Step 5 all end(e), e ∈ K i vertices and their lifted subtrees lie in the corresponding XZ + st(e) and have the canonical x, y, z-coordinates with respect to the start vertices of their edges.Note that start vertices of edges in K i did not have lifted subtree in the beginning of the procedure Lif t(K i ) and after this procedure their lifted subtree consists of the end vertices of the edges in K i and their lifted subtrees.As for the other vertices in the XY 0 , their lifted subtrees had not moved during Lif t(K i ) procedure and are in the canonical positions with respect to their roots by induction hypothesis.
(II) vertices that lie on edges in a set that is not yet processed are lying within the XY 0 plane Base of the induction: i = 1: The condition (II) holds since the entire tree T lies in the XY 0 plane.The induction step: By induction hypothesis before Lif t(K i ) procedure all vertices that lie on edges in a set that is not yet processed lie in the XY 0 plane.End vertices of the edges in K i can not lie in K j , j > i by definition of the partition K.That means that after Lif t(K i ) in which we move only end vertices of the edges in K i and their lifted subtrees, all vertices that lie on edges of sets K j , j > i will still lie in the XY 0 plane.
Lemma 35.All morphing steps in the algorithm are integer.
Proof.Let us prove this by induction on number of lifted sets K i .The base case is trivial.After the stretching morph all coordinates of all vertices are integer because the constant of stretching is integer and in the given drawing Γ all vertices had integer coordinates.
By induction hypothesis in the beginning of Lif t(K i ) procedure all vertices lie on lattice points of the grid.During Lif t(K i ) procedure vertices that are not ends of the edges of K i do not change coordinates at all.Mapping morphs move points with integer coordinates to points with integer coordinates.In all other steps the lifted subtrees of end vertices of the edges are moved along with their roots by the integer vector.
As all coordinates at the beginning of Lif t(K i ) were integer and all vectors of movement of all vertices in every step were integer, after Lif t(K i ) procedure all vertices still have integer coordinates.
Complexity of the algorithm The estimation on the size of the required grid is similar to the previous algorithm: In the beginning of the algorithm the given drawing Γ = Γ 0 of graph T = (V, E), |V | = n takes space l(Γ ) × w(Γ ) × 1.First step of the algorithm multiplies needed space by S 1 = 2•rpw •d(Γ )•(4•d(Γ )+1).During our algorithm the height of lifted subtrees does not exceed their height in relative canonical drawing with respect to their roots, i.e. does not exceed n.Lifted subtrees take no more than rpw • d(Γ ) • (4 • d(Γ ) + 1) space in x; y-directions from their root during each iteration of Lif t() procedure.Since in Step 1 we are moving a lifted subtree rooted at end(e) toward st(e) along the edge e, the maximum of the x; y-coordinates of vertices in the lifted subtree can not exceed maximum of the x; y-coordinates of the vertices end(e), st(e).During Steps 3-5 of Lif t() procedure lifted subtrees lie in disks B(Γ 1 (v), rpw • d(Γ ) • (4 • d(Γ ) + 1)) for some v that is the start of edge in K i .
So the space algorithm takes during all step is at most: There are l number of sets K i , where l is the depth of T .For every procedure Lif t(K i ) we need at most 6 + log k number of morphing steps, where k = ∆(T ), i.e., maximum degree of a vertex in T .This implies that the total number of steps in the algorithm is O(dpt(T ) • log ∆(T )).
The lemmas proved in this section along with the space and time complexity bounds prove the following Theorem.

Trade-off
Recall that L(T ) is the set of paths induced by the long-path decomposition, see Section 2. Let Long(T ) be a set of paths from L(T ), consisting of the paths which length is at least √ n, i.e.Long(T ) = {L i ∈ L(T ) : |L i | ≥ √ n}, let the order in Long(T ) be induced from the order in L(T ).We denote by Short(T ) a set of trees that are left after deleting from T edges of Long(T ).
Lemma 36. 1. |Long(T )| ≤ √ n 2. For every tree T i in Short(T ) depth of T i is at most √ n .
Proof. 1.Every edge in the tree lies in exactly one path of long-path decomposition.In a tree T with n nodes there are n − 1 edge.
If there exists a tree T i which depth is at least √ n, then long edges from its root create a path that lies in long-path decomposition and has length at least √ n.That means that this path from the root of T i should lie in Long(T ) and does not exist in T i .We have come to a contradiction.Theorem 3.For every two planar straight-line grid drawings Γ, Γ of tree T with n vertices there exists a crossing-free 3D-morph M = Γ = Γ 0 , . . ., Γ l = Γ that takes O( √ n • log ∆(T )) steps and O(d 3 • log n × d 3 • log n × n) space to perform, where d is maximum of the diameters of the given drawings, ∆(T ) is the maximum degree of vertices in T .In this morph, every intermediate drawing Γ i , 1 ≤ i ≤ l is a straight-line 3D grid drawing.
Note that it is possible to morph between Γ, Γ using O( √ n) steps if the maximum degree of T is a constant.

Conclusion
In this paper, we presented an algorithm that morphs between two planar grid drawings of a n-vertex tree T in O( √ n log n) steps such that all intermediate drawings are crossing free 3D-grid drawings and lie inside a polynomially bounded 3D-grid.Arseneva et al. [5] proved that O(log n) steps are enough to morph between two planar grid drawings of a n-vertex tree T where intermediate drawings are allowed to lie in R 3 but they did not guarantee that intermediate drawings have polynomially bounded resolution.Several problems are left open in this area of research.We mention few of them here.It is interesting to prove a lower-bound on the number of morphing steps if intermediate drawings are allowed to lie in R 3 .It is also interesting to prove a lower bound on this problem along with the additional constraint of polynomially bounded resolution.Is it possible to morph between two planar grid drawings in o(n) number of steps for a richer class of graphs (e.g.outer-planar graphs) than trees if we are allowed to use the third dimension?Is there a trade-off between the number of steps required and the volume of the grid needed for the morph?

Fig. 2 :
Fig. 2: An example of the canonical drawing of a tree.Illustrations (a) and (b) show heavy and long paths respectively with different colors.

Fig. 3 :Lemma 5 .
Fig.3:The illustration shows the mapping morph, half-planes α, β sharing a common pole through point (x , y ) and their vector of mapping.

Fig. 4 :
Fig. 4: Possible vectors of rotation between 4 half-planes sharing a common pole through vertex v

π 2 ,Fig. 6 :
Fig. 6: Possible orientations of the canonical drawing of a tree T .

Fig. 22 :
Fig.22: Drawing Γ t The drawing Γ t in the beginning of the procedure Lif t(K i ), lifted subtrees are violet.K i consists of green edges.

Theorem 2 .
For every two planar straight-line grid drawings Γ, Γ of a n-vertex tree T , there exists a crossing-free 3D-morphM = Γ = Γ 0 , . . ., Γ k = Γ that takes O(dpt(T ) • log ∆(T )) steps and O(d 3 • log n × d 3 • log n × n) space such that every intermediate drawing Γ i , 0 ≤ i ≤ k is a straight-line 3D grid drawing,where d is maximum of the diameters of the given drawings, ∆(T ) is the maximum degree of vertices in T .Corollary 2. For every two planar straight-line grid drawings Γ, Γ of a nvertex tree T , there exists a crossing-free 3D-morphM = Γ = Γ 0 , . . ., Γ k = Γ that takes O(dpt(T ) • log n) steps and O(d 3 • log n × d 3 • log n × n) space such that every intermediate drawing Γ i , 0 ≤ i ≤ k is a straight-line 3D grid drawing,where d is maximum of the diameters of the given drawings.