Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graph Drawing and Information Visualization Laboratory Department of Computer Science and Engineering Bangladesh University of Engineering and Technology.

Similar presentations


Presentation on theme: "Graph Drawing and Information Visualization Laboratory Department of Computer Science and Engineering Bangladesh University of Engineering and Technology."— Presentation transcript:

1 Graph Drawing and Information Visualization Laboratory Department of Computer Science and Engineering Bangladesh University of Engineering and Technology (BUET) Dhaka-1000, Bangladesh Minimum-Layer Drawings of Trees

2 Layered Drawing of Trees February 20, 20112WALCOM 2011, New Delhi, India a b c def g h i j ab c d e f g hi j Each vertex is drawn as a point on some horizontal line and each edge is drawn as a straight line segment. A Tree T A layered drawing of T

3 February 20, 20113WALCOM 2011, New Delhi, India a b c def g h i j A minimum-layer drawing of T a b c d e f g h i j a g b c d e f hi j 3 ab c d e f g hi j 4 2 A layered drawing of T is a minimum-layer drawing of T, if the number of layers used in the drawing is the minimum. Minimum-Layer Drawing of Trees

4 February 20, 2011WALCOM 2011, New Delhi, India4 Motivation: Layout Design of Standard Cell Minimize the number of rows in the layout Visualization of Organizational charts Software class hierarchies Phylogenetic evolutions Programming language parsing

5 February 20, 20115WALCOM 2011, New Delhi, India Previous Works Felsner et al., 2003 Necessaryk-layer drawing Cornelsen et al., 2004Necessary & Sufficient2-layer and 3-layer drawing Dujmovic et al., 2004Necessary & SufficientProper minimum-layer drawing Suderman, 2005Necessary & Sufficient  3h/2  -layer drawing, h is the pathwidth Alam et al., 2010Necessary & SufficientUpward minimum-layer drawing This PaperNecessary & SufficientMinimum-layer drawing Each path from the root is a y-monotone polyline Each edge is between the vertices on adjacent layers

6 February 20, 2011WALCOM 2011, New Delhi, India6 Some Minimum-Layer Drawings a b d e c a b d e c a b c b a c

7 February 20, 2011WALCOM 2011, New Delhi, India7 Non-triviality for General Trees r r Observation: The drawing of some subtrees are packed into the drawing of some other subtrees.

8 February 20, 2011WALCOM 2011, New Delhi, India8 Let’s try to draw from scratch 1 A single vertex tree requires one layer in its minimum layer drawing. The subtree rooted at vertex 21 takes one layer. Thus we associate a label L 21 = [1] with vertex 21. 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 21 39 L 21 = [1]

9 February 20, 2011WALCOM 2011, New Delhi, India9 Let’s try to draw from scratch 1 [Suderman, 2005] Let T be a tree with three subtrees where each of these subtrees takes k layers in its layered drawing. Then any layered drawing of T requires at least k+1 layers. 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 15 21 2223 39 L 15 = [2]

10 February 20, 2011WALCOM 2011, New Delhi, India10 Let’s try to draw from scratch 1 We draw this subtree in 3-layers and 3-layers are also necessary for its layered drawing by, the previous argument of Suderman. 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 15 16 17 21 2223 2425 262728 29 13 39 L 13 = [3]

11 February 20, 2011WALCOM 2011, New Delhi, India11 Let’s try to draw from scratch 1 Since we do not want to increase layers, we put vertex 10 in between 13 and 14. 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 15 16 17 21 2223 2425 262728 29 1314 18 19 20 30 31 33 3435 3637 38 32 10 39 L 10 = [3]

12 February 20, 2011WALCOM 2011, New Delhi, India12 Let’s try to draw from scratch 1 At this step vertex 10 does not have visibility to its right or left, i.e, it cannot see any point p to its left or right which lies outside of the bounding box of drawing. 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 15 16 17 21 2223 2425 262728 29 1314 18 19 20 30 31 33 3435 3637 38 32 10 39 L 10 = [3]

13 February 20, 2011WALCOM 2011, New Delhi, India13 Let’s try to draw from scratch 1 At this step vertex 10 does not have visibility to its left or right, i.e, it cannot see any point p to its left or right which lies outside of the bounding box of the drawing. 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 15 16 17 21 2223 2425 262728 29 1314 18 19 20 30 31 33 3435 3637 38 32 10 p 39 L 10 = [3]

14 February 20, 2011WALCOM 2011, New Delhi, India14 Let’s try to draw from scratch 1 We say that this drawing has become saturated. (no more subtrees that requires at least 3 layers cannot be drawn within this drawing) Any further drawing should use the space below vertex 10. 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 15 16 17 21 2223 2425 262728 29 1314 18 19 20 30 31 33 3435 3637 38 32 10 Layers to continue drawing 39

15 February 20, 2011WALCOM 2011, New Delhi, India15 Let’s try to draw from scratch 1 We have two saturated drawings; one is for vertex 10 and the other is for vertex 1. These two drawings forms a partition P of the tree. P has two elements (red and blue). 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 15 16 17 21 2223 2425 262728 29 1314 18 19 20 30 31 33 3435 3637 38 32 10 9 11 12 6 78 39 1 2 3 45

16 February 20, 2011WALCOM 2011, New Delhi, India16 Let’s try to draw from scratch 1 We associate a label L 1 = [3,2] with the root of the tree. Observe that the partition of the tree contains |L 1 | = 2 elements, where one element has 3-layer drawing and the other element has 2-layer drawing. 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 2425 26272829 30 31 33 3435 3637 38 32 15 16 17 21 2223 2425 262728 29 1314 18 19 20 30 31 33 3435 3637 38 32 10 9 11 12 6 78 39 1 2 3 45 L 1 = [3,2] What happens if we continue drawing further and the layers available are not sufficient? 39

17 February 20, 2011WALCOM 2011, New Delhi, India17 Let’s try to draw from scratch The label of the root of Subtree B contains 4. Therefore, B requires at least 4 layers. Draw A with one more layer so that vertex a obtains right visibility (can see r). B L b = [4, …..] B A r a b L a = [3, 2] a r b

18 m February 20, 2011WALCOM 2011, New Delhi, India18 Let’s try to draw from scratch Find the path from a to the first vertex on the topmost layer in the drawing of A. Put the vertices on the path on the layer of vertex b. Draw the components connected with the path below the path. B a r b B r b a n mn Such modifications are possible if the drawings of the components are root visible drawings (root is visible from a point above or below the bounding box of the drawing) For example, p and q are visible from n, which lies above the blue bounding box. p q

19 February 20, 2011WALCOM 2011, New Delhi, India19 Algorithm Outline Given a tree T, find a minimum-layer root-visible drawing of T taking an arbitrary vertex r as a root of T. [O(n) time] Compute all the minimum-layer root visible drawings of T taking each vertex of T as a root. The root visible drawings with the minimum number of layers is the minimum-layer drawing of T. [O(n 2 ) time] The proof follows from the fact that, In any layered drawing of a tree, at least one vertex is visible from a point above or below the bounding box of the drawing.

20 February 20, 2011WALCOM 2011, New Delhi, India20 Algorithm Outline We can choose a suitable vertex x in O(n) time such that minimum-layer root visible drawing taking x as a root of T is a minimum-layer drawing of T. Thus the running time becomes O(n) in total. How can we obtain a minimum-layer root visible drawing?

21 February 20, 2011WALCOM 2011, New Delhi, India21 Minimum-Layer Root Visible Drawing Compute a partition and a label of the tree from the partitions and labels of the subtrees in a bottom-up approach. Once the partition is computed, draw the corresponding partition. Computing of a partition is broken down into four cases depending on the labels of the subtrees.

22 February 20, 2011WALCOM 2011, New Delhi, India22 L(r) = f ( L(r 1 ), L(r 2 ), …, L(r d ) ) Case 1: B 2 < S 1 Case 2: B 2 = S 1 Case 3: B 2 > S 1 ; B 2  L(r 1 ) Case 4: B 2 > S 1 ; B 2  L(r 1 ) r r1r1 r3r3 rdrd r4r4 r2r2 L(r 1 )= (B 1,…, S 1 ) L(r 2 )= (B 2, …) L(r 3 )= (B 3, …) L(r 4 )= (B 4, …) Illustration of Cases B i is the largest integer in L(r i ) S i is the smallest integer in L(r i ) B1 ≤ B2 ≤ B3 ≤ B4

23 February 20, 2011WALCOM 2011, New Delhi, India23 Illustration of our algorithm B C E F D W X S Y R Q Z L r1 =[7, 5, 2, 0] r r1r1 r2r2 r3r3 r4r4 L r2 =[4] L r3 =[4] L r4 =[3] The figure illustrates the partitions and labels of the subtrees at some step of the algorithm. Case 4: B 2 > S 1 ; B 1  L(r 1 ) L(r 1 )= (B 1 = 7,…, S 1 =0) L(r 2 )= (B 2 = 4, …) L(r 3 )= (B 3 = 4, …) L(r 4 )= (B 4 = 3, …) 70 4  [ 7, 5, 2, 0 ]

24 24 Illustration of our algorithm Q Z RY S X W C B DF E B C E F D W X S Y R Q Z L r1 =[7, 5, 2, 0] r r1r1 r2r2 r3r3 r4r4 L r2 =[4] L r3 =[4] L r4 =[3, 2] L r1 =[7, 5, 2, 0] denotes that the subtree rooted at vertex r 1 has 3 partitions. The 0 at the end of L r1 denotes the last element with 2 layers is saturated. Saturated; r 1 does not have side visibility r1r1 r2r2 r3r3 r4r4 r

25 25 Illustration of our algorithm Q Z RY S X W C B DF E B C E F D W X S Y R Q Z L r1 =[7, 5, 2, 0] r r1r1 r2r2 r3r3 r4r4 L r2 =[4] L r3 =[4] L r4 =[3, 2] L r2 =[4] denotes that the subtree rooted at vertex r 2 has 1 partition drawn on 4 layers. No 0 at the end of L r2. Therefore, r 2 has side visibility. Not-saturated; r 2 has side visibility r1r1 r2r2 r3r3 r4r4 r

26 26 Illustration of our algorithm Q Z RY S X W C B DF E B C E F D W X S Y R Q Z L r1 =[7, 5, 2, 0] r r1r1 r2r2 r3r3 r4r4 L r2 =[4] L r3 =[4] L r4 =[3, 2] L r3 =[4] denotes that the subtree rooted at vertex r 3 has 1 partition drawn on 4 layers. No 0 at the end of L r3. Therefore, r 3 has side visibility. r1r1 r2r2 r3r3 r4r4 r Not-saturated; r 3 has side visibility

27 Illustration of our algorithm Q Z RY S X W C B DF E B C E F D W X S Y R Q Z L r1 =[7, 5, 2, 0] r r1r1 r2r2 r3r3 r4r4 L r2 =[4] L r3 =[4] L r4 =[3, 2] L r4 =[3,2] denotes that the subtree rooted at vertex r 4 has 2 partitions. No 0 at the end of L r4. Therefore, r 4 has side visibility. r1r1 r2r2 r3r3 r4r4 r Not-saturated; r 4 has side visibility

28 Illustration of our algorithm Q Z RY S X W C B DF E B C E F D W X S Y R Q Z L r1 =[7, 5, 2, 0] r r1r1 r2r2 r3r3 r4r4 L r2 =[4] L r3 =[4] L r4 =[3, 2] The drawings of the subtrees are minimum-layer root visible drawings by induction. r1r1 r2r2 r3r3 r4r4 r

29 February 20, 2011WALCOM 2011, New Delhi, India29 Minimum-Layer Root Visible Drawing Q Z RY S X W r1r1 Q Z RY S X W C B DF E r1r1 r2r2 r3r3 r4r4 r B C Insert smaller subtrees into the largest subtree. r2r2 r r3r3 D F E r4r4

30 February 20, 2011WALCOM 2011, New Delhi, India30 Illustration of our algorithm Q Z RY S X W r1r1 Q Z RY S X W C B DF E r1r1 r2r2 r3r3 r4r4 r B C Form a new element with all the modified part of the drawing. r2r2 r3r3 D F E r4r4 r L r1 =[7, 5, 2, 0] L r2 =[4] L r3 =[4] L r4 =[3, 2] L r =[7, 5, 4, 0]

31 February 20, 2011WALCOM 2011, New Delhi, India31 Illustration of our algorithm Q Z RY S X W r1r1 Q Z RY S X W C B DF E r1r1 r2r2 r3r3 r4r4 r B C L r =[7, 5, 4, 0] denotes that partition of the tree with root r has 3 elements. The 0 at the end of L r denotes the last element with 4 layers is saturated. r2r2 r3r3 D F E r4r4 r L r1 =[7, 5, 2, 0] L r2 =[4] L r3 =[4] L r4 =[3, 2] L r =[7, 5, 4, 0] The final list is obtained by modifying the list L r1 of the largest subtree. All the cases in our algorithm are described by some operations on the lists. We prove that the number of operations after all the steps are O(n) in total.

32 February 20, 2011WALCOM 2011, New Delhi, India32 Proof for Optimality Assume that for a tree T our algorithm constructs a layered drawing with k-layers We prove that k layers are necessary for any layered drawing of T, even if we allow edges to be drawn with poly-line segments. The drawing is a minimum-layer drawing

33 February 20, 2011WALCOM 2011, New Delhi, India33 Proof for Optimality Assume that, each of the drawings of the subtrees takes at most k layers. If our algorithm draws the tree on k+1 layers, we prove that one of the following conditions (a) or (b) is true. (a)There are at least three different subtrees in the tree where each of these subtrees requires at least k layers in any layered drawing. In this condition, k+1 layers are necessary [Suderman, 2005] r1r1 r3r3 rdrd r4r4 r2r2 r L r2 =[k,…] L r4 = [k,…] L rd = [k,…]

34 v February 20, 2011WALCOM 2011, New Delhi, India34 Proof for Optimality Assume that, each of the drawings of the subtrees takes at most k layers. If out algorithm draws the tree on k+1 layers, we prove that one of the following conditions (a) or (b) is true. (b) There is a path in the tree where the deletion of the three vertices u, v, w on the path yields six subtrees such that - two of them requires at least k layers (obtained from the deletion of v), - and the other four subtrees requires at least k-1 layers (obtained from the deletion of u and w). In this condition, k+1 layers are necessary (proof is based on the above figure). u w u v w

35 February 20, 2011WALCOM 2011, New Delhi, India35 Conclusion In this paper we have given an algorithm to compute minimum-layer drawings of trees. ------------------------------------------------------------- Future works may include  Minimum-layer drawings of ordered trees.  Minimum-layer drawings of other classes of planar graphs richer than trees.

36 February 20, 2011WALCOM 2011, New Delhi, India36 Thank you

37 February 20, 2011WALCOM 2011, New Delhi, India37 How to Choose a Suitable Root? RT S r Case 1 : B 1 = B 2 = B 3 By the proof of necessity, each of R,S,T requires at least B 1 layers. Thus the final drawing takes B 1 +1 layers. We can safely choose r as the desired root vertex and this drawing is itself the desired drawing. Otherwise, say choosing w as a root gives a drawing with less than B 1 +1 layers. But it is not possible since in any drawing R,S,T requires at least B 1 layers. A minimum-layer root visible drawing obtained by taking a vertex r arbitrarily as a root r1r1 r2r2 r3r3 r4r4

38 February 20, 2011WALCOM 2011, New Delhi, India38 How to Choose a Suitable Root? R S r Case 2 : B 1 = B 2 > B 3 If r 1 does not have side visibility then, by the proof of necessity B 1 +1 layers are necessary. We can safely choose r as the desired root and this drawing is itself the desired drawing. The reason is R and S will ensure B 1 +1 layers for any other choice. If r 1 has side visibility then, by the proof of necessity B 1 layers are necessary. We can safely choose r as the desired root and this drawing is itself the desired drawing. The reason is R or S will ensure B 1 layers for any other choice. r1r1 r2r2 r3r3 r4r4 R r r1r1 r2r2 S r3r3 r4r4

39 February 20, 2011WALCOM 2011, New Delhi, India39 How to Choose a Suitable Root? Case 3 : B 1 > B 2 If r 1 has side visibility then, by the proof of necessity B 1 layers are necessary. We can safely choose r as the desired root and this drawing is itself the desired drawing. The reason is R will ensure B 1 layers for any other choice. If r 1 does not have side visibility then the case is non trivial. R r r1r1 r2r2 S r3r3 r4r4

40 February 20, 2011WALCOM 2011, New Delhi, India40 Illustration of Case 3 Q Z RY S X W r1r1 Q Z RY S X W C B DF E r1r1 r2r2 r3r3 r4r4 r B C Case 3 : B 1 > B 2 and r 1 does not have side visibility. In this case we choose r w as the desired root vertex. r2r2 r3r3 D F E r4r4 r The case when r 1 does not have side visibility. rwrw

41 February 20, 2011WALCOM 2011, New Delhi, India41 Illustration of Case 3 Q Z RY S X W r1r1 B C Observe that T 1 contains two subtree Q and Z that requires B 1 layers. Thus, the number of layers in the final drawing depends on the number of layers necessary for T 2 r2r2 r3r3 D F E r4r4 r Q Z RY S X W r1r1 B C r2r2 r3r3 D F E r4r4 r Subtree rooted at r w is shown in blue (denote it by T 1 ). The other part of the tree is shown in green (denote it by T 2 ). rwrw

42 February 20, 2011WALCOM 2011, New Delhi, India42 Illustration of Case 3 Q Z RY S X W r1r1 B C If minimum layer drawing of T 2 takes B 1 layers, then the overall drawing takes at least B 1 +1 layers (by necessity). We can construct such a drawing on B 1 +1 layers by taking r w as the desired root. r2r2 r3r3 D F E r4r4 r Q Z RY S X W r1r1 B C r2r2 r3r3 D F E r4r4 r If minimum layer drawing of T 2 takes at most B 1 -1 layers, then the overall drawing takes at least B 1 layers (by necessity). We can construct such a drawing on B 1 layers by taking r w as the desired root. rwrw

43 February 20, 2011WALCOM 2011, New Delhi, India43 How to Choose a Suitable Root? In summary, the best possible drawing is always achieved by taking either r or r w as the root vertex. Thus we only need to compute minimum layer drawings twice. 1.Taking any arbitrary vertex r as the root. 2.Taking r w as the root, where r w is a descendent of r as defined in the minimum layer root visible drawing taking r as the root.


Download ppt "Graph Drawing and Information Visualization Laboratory Department of Computer Science and Engineering Bangladesh University of Engineering and Technology."

Similar presentations


Ads by Google