• Keine Ergebnisse gefunden

Circle Drawings

Im Dokument Constrained Graph Drawing (Seite 36-48)

Angles and Distances

3.2 Distance Constraints

3.2.2 Circle Drawings

β,arcsin

b

kx(v)−x(z)k2

(3.6)

For the case that v has more than two children, i. e., w1, . . . , wk in coun-terclockwise direction, spreading the subtrees is slightly more complicated. We rotate the outer subtrees T(w1) and T(wk) as before, i. e., as much as possible.

We do not change the subtree T(wdk2e) in the middle of the wedge. The sub-trees between the fix middle subtree T(wdk2e) and the last subtree T(wk) are rotated by an adapted angle i, dk2e < i ≤ k. To preserve planarity, we must take care that these inner subtrees are not crossing the wedge border rooted at the grandparent u. Thus for computing k, we must also check the leaves of all inner subtrees. For a child wi we compute

i =k· i−k

2

k−k

2

. (3.7)

To rotate a subtree T(wi), we must update the position of every vertex y in T(wi): We increase the absolute angle γ of the line from v to y by i. Sym-metrically we do the same for the subtrees between T(w1) and T(wdk

2e). We spread the tree from the leaves to the children of the root. Algorithm 3 shows the complete code. Since we recompute the coordinates of a vertex whenever we rotate a subtree in which it is contained, the time complexity isO(n2).

3.2.2 Circle Drawings

Since it can be difficult to place labels in radial tree drawings (Fig. 3.9), we describe a second method to draw phylogenetic trees. Here leaves are placed equidistantly along the perimeter of a circle. Again, each leaf thus obtains a wedge of angular width |leaves(T )|, but now the radius of the circle determines the maximum height of the font. It is easy to see that with this constraint it might not be possible to draw all edges e ∈E with length proportional to δ(e). Edge length preservation therefore turns into an optimization criterion.

pseudomona

ne---(b) spreading extension (central root) Figure 3.8: Postprocessing

Type-25

8 Type-55 Type-56Typ

e-54

(a) Hordeum88 (with overlap-avoidance extension)

m2621noth.494Nothosc neapolitanchamroseum

aemoly

um3045gla281ndu1bmm0200drummrevis

3471good

3940materc5255regeli1920cristom3652suvor3947cardi

o sa6043monade 6084forres 6093aciphy2211beesi

a6070sikkim3849cyaneu3872cyaneu

5561altaicm 2373mongol5091dentig

2539polyrh m16095738st2744tuvinrubenellei

1968spiral2750senesc2747austrom3161nutan

(b) Allium200

Figure 3.9: Radial drawing examples

Algorithm 3: SPREADING

Input: Ordered rooted tree T = (V, E, δ), constant buffer sizeb, coordinates x(v) and wedge sizeωv for each v∈V

Output: Updated coordinatesx(v) for each vertexv∈V foreach v∈children(root(T))do postorder traversal(v) procedure postorder traversal(vertex v)

procedure subtree coordinates(vertexv, vertex w, angle) foreach vertexy∈T(w) do

γ ←arccos

3.2.2.1 Basic Algorithm

We use a variant of the weighted version of Tutte’s barycentric layout algo-rithm (Tutte, 1960, 1963). The general idea is to fix some vertices to the bound-ary of a convex polygon and then to place all other verticesvi ∈V in the weighted barycenter of their neighbors vj ∈V with {vi, vj} ∈E, i. e., vi is positioned at

x(vi) = X

vj∈V

(aijx(vj)) (3.8)

where aij is the relative influence ofvj on vi.

For circular drawings, the leaves of a treeT are fixed to a circle and we define weights aij by (3.9). These weights reflect the desired edge lengths, i. e., the shorter an edge{vi, vj}should be, the more influence x(vj) has on the resulting coordinate x(vi). In the original Tutte algorithm aij = deg(v1

i). Note that the weightsaij sum up to 1 for each vi so thatvi is placed inside of the convex hull of its neighbors.

Since we fix leaves to the perimeter of a circle, we can expect in general that an inner vertex of a tree is placed between its children on the one side and its parent on the other side. To counterbalance the accumulated radial influence of the children, their weight is scaled down.

sij = fixing the leaves equidistantly around the circle, we need to solve

By the following lemma, this can be done in linear time by traversing the tree first in postorder to resolve the influence of leaves and then in preorder passing down positions of parents.

Lemma 3. For vi ∈V and vp = parent(vi), define coefficients Then (3.10) has a unique solution with

x(vi) =

(di if vi = root(T),

cix(vp) +di otherwise (3.12) for all inner vertices vi ∈V \leaves(T).

Proof. We use induction over the vertices. For the base case let vi be an inner vertex having only leaves as children. Then for the case vi 6= root(T), let vp be the parent of vi and thus

The case vi = root(T) is a special case of (3.13), which uses only the second addend. For the inductive step, now let vi 6= root(T) be an inner vertex and vp

the parent of vi. Then

The proof forvi = root(T) is a special case of (3.14), which uses only the second addend.

Theorem 5. For a rooted ordered phylogenetic tree T = (V, E, δ), there is a unique planar circle drawing up to rotation, translation, and scaling that satisfies the following properties:

1. Leaves are placed equidistantly on the perimeter of a circle.

2. Disjoint subtrees are confined to disjoint wedges.

3. Inner vertices are placed in the weighted barycenter of their neighbors with weights defined by (3.9).

Moreover, it can be determined in linear time.

Proof. Uniqueness is proven in Lemma 3 and linear run time is obvious from Algorithm 4.

For planarity we may assume that inner vertices have a degree of at least three since a degree-two vertex can be replaced by an edge and degree-one vertices are fixed. Adding dummy edges between neighboring leaves on the circle then yields a triconnected graph with all leaves incident to the same face. Since our weights yield strictly convex combinations for the positions of inner vertices, planarity follows from a generalization of Tutte’s original theorem in (Gortler and Thorston, 2006). Note that our influence weights are not symmetric.

Algorithm 4: CIRCLE-LAYOUT Input: Ordered rooted tree T = (V, E, δ)

Data: Vertex arrays c(coefficient), d(offset), and edge arrays(weighting) Output: Coordinates x(v) in/on the unit circle for each vertexv∈V begin

i←0 k←0

foreach v∈V do

if deg(v) = 1 thenk←k+ 1

postorder traversal(root(T)) preorder traversal(root(T))

procedure postorder traversal(vertex v) foreach w∈children(v) do

postorder traversal(w) // ordered by h(w) +δ(v, w)

if is leaf(v) or (v= root(T) anddeg (root(T)) = 1) then cv ←0

dv← cos 2πik

,sin 2πik

// fix vertex on circle i←i+ 1

else S ←0

foreach adjacent edgee← {v, w} do if v= root(T) or w= parent(v) then

seδ(e)1 else

seδ(e)·(deg(v)−1)1

S ←S+se t←t0 ←0

foreach outgoing edge e←(v, w) do t←t+sSe ·cw

t0 ←t0+sSe ·dw if v6= root(T) then

e←(parent(v), v) cvS·(1−t)se dv1−tt0

procedure preorder traversal(vertexv) if v= root(T) then

x(v)←dv

else

u←parent(v) x(v)←cv·x(u) +dv

foreach w∈children(v) do preorder traversal(w)

w e

® ¯

(a) angles

z

v

® P

¯

(b) T(v) crosses wedge borders Figure 3.10: Each subtree is drawn in a wedge

It remains to show that the resulting layouts satisfy the subtree-wedge con-dition. Since every inner vertex is placed within the convex hull of its neighbors, they all, especially the rootr, lie within the circle. Thus for deg(r)≥2, all leaves lie in the wedge of r with size 2π. In the special case of deg(r) = 1 (deg(r) = 0 is trivial), we traverse downwards until a vertex with at least two outgoing edges or a leaf is found, take this vertex as the new root, and treatr as a leaf. For any inner vertex w ∈ V\{r} and the corresponding angle α between the incoming edge e and the first outgoing edge is α ≤ π, because w is placed within the convex hull of its neighbors. See Fig. 3.10(a) for an example.

Let z be the leaf in T(v) found by subsequently following the first outgoing edge. Let P be the unique simple path from v to z, which is denoted as the left contour of T(v). The left border of the wedge of v is a straight line from v to z. See Fig. 3.10(b) for an example. Now assume P crosses this border. Then there must be at least one angle α > π on P, which is a contradiction to the above. Otherwise, there is a crossing of P with itself or with the right contour ofT(v), which contradicts planarity. Symmetrically the same holds for the right contour ofT(v) and anglesβ between the last outgoing edges and corresponding incoming edges.

The most general version of Tutte’s algorithm for arbitrary graphs fixes at least one vertex of each component and simply places each vertex in the barycen-ter of its neighbors, which yields a unique solution. The run time corresponds to solving n symmetric equations, which can be done in O(n3) time. For planar graphsO(nlogn) time can be achieved (Lipton, Rose, and Tarjan, 1979), but it is not known whether this is also a lower bound. We showed that for trees with

v

Figure 3.11: Children ordered according to subtree height

all leaves in convex position, the run time is in O(n). Giving up planarity this result can be generalized to trees having arbitrary fixed vertices (at least one).

Consider a fixed inner vertex v and let each other vertex w in the subtreeT(v) be free. Then T(v) collapses to the position of v. On the other hand, if v has a fixed ancestoru, then all positions of the vertices in T(v) are computed and for the rest a restart on T\T(v)∪ {v} computes all remaining positions. It follows by induction that our algorithm computes the unique solution in O(n) time.

Note, the desirable property of disjoint subtree wedges together with the circular leaves constraint further restricts the class of edge lengths that can be represented exactly. Nevertheless, our experiments indicate that typical phylo-genetic tree metrics are represented fairly accurately.

3.2.2.2 Extensions

Our weights depend on the choice of the root vertex since re-rooting the tree changes weights along the path between the previous and the new root. The rationale behind reducing the influence weights of children suggests that the tree should be rooted at its center (minimum eccentricity element). Using weights independent of the parent-child relation, the layout can be made independent of the root just like the radial layouts discussed in the previous section.

It is easy to see that by fixing the order of leaves we are also fixing the child order of all inner vertices. If no particular order is given, we can permutate the children of inner vertices to improve edge length preservation. Ordering the children of each vertex v according to ascending height h(w) of the subtrees T(w) plusδ(v, w) ensures that shallow and deep subtrees are never placed in an alternating order. See Fig. 3.11. Though sorting the children leads toO(nlogn) preprocessing time in general, most phylogenetic trees have bounded degree, meaning that sorting can be performed in linear time.

Since correct edge lengths cannot be guaranteed in circle drawings, we use the following coloring scheme to depict the error: Let

pseudomona

ne---(b) re-rooted at the center Figure 3.12: Circular drawing examples

σ = P

e=(u,v)∈E kx(v)−x(u)k2

P

e∈Eδ(e) (3.15)

be the mean resolution of the drawing, i. e., the scaling factor between drawn units and length units ofδ. Then we obtain the (multiplicative) error of an edge e= (u, v) by

With this, that blue and red signify edges that are too short and too long, respectively. 100% red means that the edge is at least twice as long as desired whereas 100% blue means that the edge should be at least twice as long. Weaker saturation reflects intermediate values. Black edges have the correct lengths.

Type-25

Type-40Type-81Type-44 Type-45Type-0

3

1650nigrum3940materc5255regeli5578ochrol2333gunibi

6024linear 3898scabri3998trachi6048sulphu6022dro

bo

1741daghes1547ericet2827pseudo1603suaveo3883ochrol

6046komaro 1963thunbe 2015chinen m3407chine 2396amblyo3135hym2905platys2570caroli3140filifoeno 2418kaschi 2198ampelo3969ira

nic 2772m3201oligan2592kareaximoli 5432schoen

Figure 3.13: Circular layout for examples from Figure 3.9

Acknowledgement

We wish to thank Lars Volkhardt for implementing our algorithms in Java using yFiles version 2.3 (Wiese, Eiglsperger, and Kaufmann, 2002), and Falk Schreiber from the Institute of Plant Genetics and Crop Plant Research in Gatersleben for providing real-world data.

Im Dokument Constrained Graph Drawing (Seite 36-48)