Journal of Graph Algorithms and Applications Low-distortion Embeddings of Trees

We prove that every tree T = (V, E) on n vertices with edges of unit length can be embedded in the plane with distortion O(√ n); that is, we construct a mapping f : V → R 2 such that ρ(u, v) ≤ ≤f (u) − f (v) ≤ O(√ n) · ρ(u, v) for every u, v ∈ V , where ρ(u, v) denotes the length of the path from u to v in T. The embedding is described by a simple and easily computable formula. This is asymptotically optimal in the worst case. We also construct interesting optimal embeddings for a special class of trees (fans consisting of paths of the same length glued together at a common vertex).


Introduction
Embeddings of finite metric spaces into Euclidean spaces or other normed spaces that approximately preserve the metric received considerable attention in recent years. Numerous significant results have been obtained in the 1980s, mainly in connection with the local theory of Banach spaces. Later on, surprising algorithmic applications and further theoretical results were found in theoretical computer science; see, for example, Indyk [2] or Chapter 15 in [4] for overviews.
Here we consider only embeddings into the spaces R d with the Euclidean metric. The quality of an embedding is measured by the distortion. Let (V, ρ) be a finite metric space. We say that a mapping f : V → R d has distortion at most D if there exists a real number α > 0 such that for all u, v ∈ V , This definition permits scaling of all distances in the same ratio α, in addition to the distortion of the individual distances by factors between 1 and D. Since the image in R d can always be re-scaled as needed, we can choose the factor α at our convenience.
We study embeddings with the dimension d fixed, and mainly the case d = 2, i.e. embeddings into the plane. A straightforward volume argument shows that the distortion required to embed into R d the n-point metric space with all distances equal to 1 is at least Ω(n 1/d ). In [3], it was proved that general metric spaces may require even significantly bigger distortions; namely, for every fixed d, there are n-point metric spaces that need Ω(n 1/ (d+1)/2 ) distortion for embedding into R d .
Better upper bounds can be obtained for special classes of metric spaces. A metric ρ on a finite set V is called a tree metric if there is a tree T = (V , E) (in the graph-theoretic sense) with V ⊇ V and a weight function w: E → (0, ∞) such that for all u, v ∈ V , ρ(u, v) equals the length of the path connecting the vertices u and v in T , where the length of an edge e ∈ E is w(e). It was conjectured in [3] that, for fixed d, all n-point tree metrics can be embedded into R d with distortion O(n 1/d ). If true, this is best possible, as the example of a star with n − 1 leaves and unit-length edges shows (a volume argument applies). Gupta [1] proved the somewhat weaker upper bound O(n 1/(d−1) ).
Here we make a step towards establishing the conjecture. We deal with the planar case, where the gap between the lower bound of √ n and Gupta's O(n) upper bound is the largest (in fact, the O(n) upper bound holds even for general metric spaces and embeddings into R 1 [3]). So far we can only handle the case of unit-length edges.
Theorem 1 Every n-vertex tree with unit-length edges, considered as a metric space, can be embedded into R 2 with distortion O( √ n). The embedding is described by a simple explicit formula and can be computed efficiently.
Gupta's result actually states that if the considered tree has at most leaves, then an embedding into R d with distortion O( 1/(d−1) ) is possible. We show that here the dependence on cannot be improved. Let F ,m (the fan with leaves and path length m) denote the tree consisting of paths of length m each glued together at a common vertex (root): Theorem 1 provides embeddings which are optimal in the worst case, i.e. there are trees for which the distortion cannot be asymptotically improved. But optimal or near-optimal embeddings of special trees seem to present interesting challenges, and sometimes low-distortion embeddings are aesthetically pleasing and offer a good way of drawing the particular trees. We present one interesting example concerning the fan F √ n, √ n . Here the "obvious" embedding as in the above picture, as well as the embedding from Theorem 1, yield distortions O( √ n). In Section 4, we describe a somewhat surprising better embedding, with distortion only O(n 5/12 ). This is already optimal according to Proposition 1.
Several interesting problems remain open. The obvious ones are to extend Theorem 1 to higher dimensions and/or to trees with weighted edges. Another, perhaps more difficult, question is to extend the class of the considered metric spaces. Most significantly, we do not know an example of an n-vertex planar graph (with weighted edges) whose embedding into R 2 would require distortion larger than about √ n. If it were possible to show that all planar-graph metrics can be embedded into the plane with o(n) distortion, it would be a neat metric condition separating planar graphs from non-planar ones, since suitable n-vertex subdivisions of any fixed non-planar graph require Ω(n) distortion [3].

Notation.
Let T be a tree (the edges have unit lengths) and let ρ be the shortest-path metric on V = V (T ). One vertex is chosen as a root. The height h(v) of a vertex v ∈ V is its distance to the root. Let π v denote the path from a vertex v to the root.
For every vertex we fix a linear (left-to-right) ordering of its children. This defines a partial ordering on V : we have u ≺ v iff u ∈ π v , v ∈ π u , and π v goes right of π u at the vertex where π u and π v branch. We define Furthermore we define a v (u) as the distance of v to the nearest common ancestor of u and v, and (v) = |{u ∈ V (T ) : u ≺ v}|.

Construction.
Our construction resembles Gupta's construction [1] to some extent, but we needed several new ideas to obtain a significantly better distortion.
First we describe the idea of the construction. The embedded tree is placed in a suitable acute angle. The apex of the angle is at the origin of coordinates and the angle opens upwards. The root of the tree is placed to the origin.
In the first step we put vertices of height h on the horizontal line y = 2 √ nh. Our angle is divided into subangles that correspond to subtrees rooted at the sons of the root; the sizes of these subangles are proportional to the number of vertices in the subtrees. The vertices of height 1 are placed on the first horizontal line in the middle of the corresponding subangles. We continue in the same way for every subtree, with each subangle translated so that its vertex lies at the root of the subtree.
In the second (and last) step we raise the y-coordinates of the vertices by appropriate amounts between 0 and √ n.

First step Second step
Now we describe the embedding more formally; actually we use a slightly modified embedding for which the formulas are quite simple.
First we define an auxiliary function k(v):

Distortion.
We now estimate the distortion of the embedding defined above. First we show that the maximum expansion of the tree distance of any two vertices is at most O( √ n). By the triangle inequality, the maximal expansion is always attained on an edge. Hence, it suffices to consider two vertices connected by an edge. So let u be the father of v in T ; it suffices to verify that We claim that every w contributes at most 1 to this sum. First we note that |a u (w) − a v (w)| ≤ 1. If sgn u (w) = 0, we have sgn v (w) = sgn u (w), and the contribution of w is at most |a u (w)−a v (w)| ≤ 1. The only remaining possibility is sgn u (w) = 0 and sgn v (w) = 0. But then u is the nearest common ancestor of v and w, we have a v (w) = 1, a u (w) = 0, and the contribution of w is at most 1 in this case as well. Therefore |k(u) − k(v)| ≤ n as claimed.
Next, we are going to prove that f (u) − f (v) = Ω(ρ(u, v)) for every u, v ∈ V ; this will finish the proof of Theorem 1.
First we consider the situation when h(u) = h(v); this is the main part of the proof, and the case where u and v have different levels will be an easy extension of this. So let h(u) = h(v) and a = a v (u) = a u (v), and assume that u ≺ v.
This is because all the vertices on π u not lying on π v are counted in (v) but not in (u). 2 Thus, the difference in the y-coordinate takes care of u and v whenever n. Next, we need to show that if this is not the case, then the x-coordinate takes care of u and v.
Combining this corollary with Corollary 1 yields

Proof of Lemma 2:
. First we check that t u,v ≥ 0 for all w. We always have sgn v (w) ≥ sgn u (w), and so the only cases that might cause trouble are sgn v (w) = sgn u (w) = 1 and sgn v (w) = sgn u (w) = −1. We will analyze only the case when sgn v (w) = sgn u (w) = 1, the other one is symmetric. In this case w ≺ u ≺ v, and it is easy to check that then a v (w) ≥ a u (w), which shows t u,v (w) ≥ 0 in all cases.
Next, we verify that if w contributes 1 to (v) − (u), which means w ≺ v and w ≺ u, then t u,v (w) ≥ a. We distinguish two cases for such w: either u ≺ w ≺ v, or w and u lie on a common path to the root, i.e. w ∈ π u or u ∈ π w .
In the first case, u ≺ w ≺ v, sgn u (w) = −1 and sgn v (w) = 1, and so t u,v (w) = a u (w) + a v (w). It is easy to see that if u and v are vertices with a u (v) = a v (u) = a, then max(a u (w), a v (w)) ≥ a for all w ∈ V and so t u,v (w) ≥ a in this case.
In the second case, we have sgn v (w) = 1 and sgn u (w) = 0, and so t u,v (w) = a v (w) = a, since the nearest common ancestor of u and v is the same as the nearest common ancestor of w and v. The proof of Lemma 2 is complete.
Proof: Without loss of generality, suppose that h(u) < h(v) and u ≺ v. Set a := a u (v), and let w be the vertex on the path from u to v with h(w) = h(u), ρ(u, w) = 2a.
Using the definition of the embedding f and with the observation that k(v) ≤ nh(v), it is easy to check that |x(v)| ≤ y(v) for any vertex v. Thus the whole drawing of the tree lies in the cone bounded by the two rays emanating from the root diagonally upwards and spanning the angle of 45 • with the y-axis. This also holds for every subtree. So the distance of the point f (u) to f (v) is larger than the distance to the left arm of the cone rooted at f (w), which is 1 Figure 1: Illustration to the proof of Proposition 1.

Proof of Proposition 1
Let F ,m be defined as in Section 1; that is, F ,m denotes the tree consisting of paths of length m glued at the root r. We show that every embedding of F ,m into R d requires distortion ρ(u, v)). We choose a real number R such that there are /2 of the images of endvertices of F ,m contained inside the ball B of radius R around f (r) or on its boundary, and there are /2 of them outside the ball or on its boundary.
We consider a ball of radius m around each of the /2 images of endvertices contained in B. These balls are disjoint and contained in m-neighbourhood of B. Hence, by a volume argument, R = Ω(m 1/d ).
Let S denote the sphere of radius R around f (r) (i.e. the boundary of B). Let P 1 , . . . , P /2 denote the /2 paths for which the images of their endvertices are not contained inside B. Each f (P i ) intersects S at least once (by f (P i ) we mean f (V (P i )) together with the straight lines between any f (u), f (v) such that {u, v} ∈ E(P i )). Let m i denote the number of vertices on f (P i ) inside B before the first intersection with S. We put µ = min{m i | i = 1, . . . , /2}. From the choice of µ it follows that R ≤ Dµ.
Let P be a spherical shell of width D around B; that is, where intX stands for the interior of X. At least /2 vertices (one from each path P i , i = 1, . . . , /2) are contained in P . We consider a ball of radius µ around each of these vertices. These balls are disjoint (because the tree-distance between any two of the vertices is at least 2µ) and they are contained in µ-neighbourhood of P (see the picture). Therefore we have, for a suitable constant c > 0, Thus there are two possibilities: 1) ). Thus we know that D ≥ min{Ω( 1/d · m 1/(d+1) ), Ω( 1/(d−1) )}. It means that

A low-distortion embedding of a subdivided star
In this section we describe an asymptotically optimal embedding of F √ n, √ n into R 2 , with distortion O(n 5/12 ). The other F ,m can be embedded similarly, with distortion as in Proposition 1; we omit a proof since it is technical and contains no new ideas.
The embedding is sketched in Fig 2. The tree F √ n, √ n is embedded into the shaded trapezoids (there are n 1/4 · 2n 1/3 of them, each of height n 5/12 ) and into the shaded discs (there are n 1/4 ·n 1/4 of them). The root of F √ n, √ n is embedded to the bottom vertex of the triangle.
In the following, we describe the embedding in more detail. It will be done in two steps. In the first step, we embed vertices up to the level h = 2n 1/3 into the dashed trapezoids on the corresponding level. In the second step, we embed all the other vertices on diameters of the discs and change the positions of some vertices on levels between n 1/3 and 2n 1/3 .

Step 1.
We start with the vertices on level h = 2n 1/3 . There are n 1/2 vertices on this level. We divide them into n 1/4 groups, each of size n 1/4 . Each of these groups is packed into one of the dashed trapezoids (on the last level). This is possible, since the area of each trapezoid on this level is Θ(n 11/12 ), which is exactly the required area (we have n 1/4 vertices, and any two of them must be at distance at least Ω(n 1/3 )). It follows that no two vertices on level h = 2n 1/3 are embedded too close to each other.
When all the vertices on the level h = 2n 1/3 are embedded, we embed the vertices on lower levels. We connect every vertex x on the last level by a straight line to the root. On this line we embed all the vertices on the path from x to the root. We do this in such a way that the distance ∆ (measured on the connecting line) from a vertex to the bottom of its dashed trapezoid is the same for all the vertices on the path from x to the root (see Fig. 3). It is easy to check that the distance between the vertices on the last level guarantees that the vertices in the lower levels are also far enough from each other. Indeed, if we consider two vertices x 1 and y 1 of level h 1 (i.e., with tree distance 2h 1 ) that have distance d in the embedding, then for any x 2 on the path from x 1 to the root and any y 2 on the path from y 1 to the root, both at a level h 2 , their distance is at least dh 2 /h 1 (while their tree-distance is 2h 2 ). Hence, if every two vertices in a higher level are far enough then also every two vertices in a lower level are far enough. Thus, the construction described so far gives an embedding of F √ n,2n 1/3 with distortion O(n 5/12 ). In the next step we modify this embedding into an embedding of F √ n, √ n .
In this step we embed all vertices on the remaining levels. We also change the positions of some vertices on the levels between n 1/3 and 2n 1/3 . There is a column of discs on the left of each column of trapezoids; there are n 1/4 columns of discs with n 1/4 discs in each column. Each path of F √ n, √ n starts at the root, goes through some number of dashed trapezoids, having one vertex in each of them, reaches a suitable level, and then it turns into one of the discs, where the rest of it is embedded with vertices packed as tightly as possible. A more precise description follows.
In each column, we consider the discs one by one from the bottom to the top. For each disc, we consider the highest shaded trapezoid lying below the equator of the disc. We take the leftmost vertex embedded in that trapezoid, and we change the embedding of the successors of this vertex: The successors are embedded on the equator of the considered disc and on a straight line connecting the leftmost vertex to the equator of the considered disc. The distance between any two neighbours on the connecting line is n 5/12 and the distance between any two neighbours on the equator is 1 in the embedding.
We continue with the next higher disc (with a smaller number of paths). In the last level, there is only one path to end. The resulting embedding is indicated in Fig 2. It is straightforward to check that the resulting embedding of F √ n, √ n yields distortion O(n 5/12 ) as claimed. 2