Presentation is loading. Please wait.

Presentation is loading. Please wait.

5-Minute Review How does the Inorder tree layout algorithm work? Which tree drawing requirements does it (not) fulfill? What is its main drawback? How.

Similar presentations


Presentation on theme: "5-Minute Review How does the Inorder tree layout algorithm work? Which tree drawing requirements does it (not) fulfill? What is its main drawback? How."— Presentation transcript:

1 5-Minute Review How does the Inorder tree layout algorithm work? Which tree drawing requirements does it (not) fulfill? What is its main drawback? How does the algorithm by Whetherell and Shannon (WS) work? How efficient is it, why? Drawbacks? Are isomorphy preservation and minimum width always compatible with each other? Compared to WS, what is the advantage of the algorithm by Reingold and Tilford (RT)? What is its complexity? What is a simple radial layout algorithm? What is a possible hitch with it, how can that be avoided? Inorder tree layout: y-coordinate according to layer (= distance to root), x-coordinate given by inorder traversal order (left subtree - root - right subtree). Is planar, grid drawing, straight-line, layered (and hence strictly upward), order preserving, separates subtrees. Not: centering of parents over children, isomorphy preservation. Drawback: often unnecessarily wide, does not preserve isomorphy. WS: 1) postorder traversal computes next available position at each level and provisional place for each node as average of child position. Shift subtrees if provisional place is too far left. Has linear efficiency, by keeping track of subtree shifts in modifiers, which are accumulated in preorder pass. Drawback: again often unnecessarily wide, does not preserve isomorphy. Isomorphy preservation and minimum width may conflict with each other. Might have to „bend“ drawings in different ways to achieve min width, see example from RT RT: preserves isomorphy. Draws subtrees recursively, computes distance of neighboring subtrees when they are completely drawn. Complexity is again linear, made possible by efficient book keeping of contours Simple radial layout: divide circle among subtrees in sectors whose size is proportional to number of nodes in subtree. Possible hitch: edge crossings. Can avoid this by limiting sectors according to annulus wedge.

2 Series-Parallel Digraphs
Inf-GraphDraw: Automatic Graph Drawing Lecture 9 Series-Parallel Digraphs Reinhard von Hanxleden This lecture is based in part on material kindly provided by Eran Geva and Matya Katz

3 Series-Parallel (SP) Digraphs
Directed graph with a source and sink nodes Source and sink are called poles Defined recursively Assume simple graph, thus no multiple edges SP digraphs are planar Base case: An edge with source and sink vertices sink source [Di Battista et al. book ‘99, Sec. 3.2] Bertolazzi, Cohen, Di Battista, Tamassia, Tollis, How to Draw a Series-Parallel Digraph, SWAT ’92, LNCS vol. 621

4 Series composition of digraphs
Identify sink of one and source of other as one vertex t2 t1 t’2 G2 + = G1 G2 t1 s1 s2 G1 s1

5 Parallel composition of digraphs
Identify as one vertex both their sources Identify as one vertex both their sinks t1 t2 t1 + = G1 G2 G1 G2 s1 s2 s1

6 Decomposition trees Associate SP digraph with parse tree T Binary tree
Consists of S-nodes, P-nodes and Q-nodes Defined recursively

7 Decomposition trees G is a single edge: T is a single Q-node t Q s

8 Decomposition trees G is a series composition of G1 and G2 where T1 and T2 are their parse trees: T has S-node root with children T1 and T2 t2 G2 S t1 T1 T2 G1 s1

9 Decomposition trees G is a parallel composition of G1 and G2 where T1 and T2 are their parse trees: T has P-node root with children T1 and T2 t1 P G1 G2 T1 T2 s1

10 Decomposition trees If a node has the same type as his parent, make it the right child Then T is unique for G If G has n nodes, then T has O(n) nodes T can be created in O(n) time, so will be assumed to be part of the input

11 Area Requirements Q: How much area may an upward, straight-line, embedding-preserving drawing of an SP digraph require? A: A lot ... Consider Gn: P (sn+1, tn+1) S tn+1 (sn+1, sn) P t0 tn (sn, tn+1) S G0: Gn+1: Gn (tn, tn+1) Gn s0 sn sn+1 Decomposition Tree for Gn+1

12 Area Requirements Theorem [Bertolazzi et al. ‘92]:
An upward, embedding-preserving, straight-line drawing of Gn requires area Ω(4n), under any resolution rule. Resolution rule: e.g., minimum separation between two nodes integer coordinates Proof: We show that Area(Gn+1) ≥ 4 * Area(Gn).

13 Drawing of Gn is bounded by triangle Δn given by sn, sn-1, tn
tn+1 must be in here tn τ Δn λ sn-1 σ sn sn+1 sn+1 must be in here ρ

14 Drawing of Gn+1 contains Δn+1
tn+1 tn τ Δn λ sn-1 Δn+1 σ sn sn+1 ρ

15 Now calculate lower bound on Area(Δn+1) from Area(Δn)
tn Δ’’ τ Δn p λ Δ’ sn-1 Π σ ρ sn For parallelogram Π: Area(Π) ≥ 2 * Area(Δn) Also: Area(Δ’) + Area(Δ’’) ≥ Area(Π) Thus Area(Δn+1) = Area(Π) + Area(Δ’) + Area(Δ’’) ≥ 2 * Area(Π) ≥ 4 * Area(Δn) q.e.d.

16 Right-pushed embedding
(u, v) is transitive in G if there is another path from u to v As pre-processing to Δ-SP-Draw, modify embedding into right-pushed embedding: transitive edge (u, v) is on the right of all components with u and v poles This permits O(n2) drawing area

17 Δ-SP-Draw Produces upward embedding of SP-digraph
Drawing inside a bounding triangle Δ(Γ) which is isosceles (gleichschenklig) and right-handed Series – place one above the other Parallel – place one to the right of the other

18 Δ-SP-Draw – Base If G is a single edge:
Draw it as a vertical edge with length 2 Bounding triangle Δ(Γ) will have width 1 t G s

19 Δ-SP-Draw – Series If G is a series composition of G1 and G2:
Recursively draw Γ1 and Γ2 Translate Γ2 so G1’s sink is on G2’s source Extend bounding triangle Δ(Γ) accordingly Note: sources differ on whether G1 is placed above or below G2. We here stick to the order of the original paper, which places G1 below G2 (and calls them G’ and G’’). G2 G1

20 Δ-SP-Draw – Parallel If G is a parallel composition of G1 and G2:
Recursively draw Γ1 and Γ2 Translate Γ2 to the “prescribed-region” of G2 (right of the dashes) Extend bounding triangle Δ(Γ) accordingly Move sources and sinks to upper and lower corners of Δ(Γ) G2 G1

21 “Prescribed Region” (v, t) and (s, u) are rightmost edges on G1
λv and λu are rays parallel to G1’s bounding triangle G2 will be translated to anywhere on the right of λv, λu and κ. Remaining question: Can the move of sources/ sinks to lower/upper corner create crossings? κ λv t v G2 u G1 s λu

22 Δ-SP-Draw invariants Is inside an isosceles right-angled triangle Δ(Γ)
Top = Sink = t Bottom = Source = s Left = nothing For any vertex u adjacent to s, in slopes –π/2 and –π/4 there’s nothing but s For any vertex v adjacent to s, in slopes π/2 and π/4 there’s nothing but t t v u s

23 Lemma Let u and v be neighbors of the source so (s, u) is left of (s, v) Let λu and λv be rays of slope -π/4 from u and v Invariant 3 ⇒ λu is below λv u v s λu λv

24 Consequence of Lemma If G2 is placed to the right of G1 and above λu where (s, u) is the rightmost edge of s on G1: No vertex of G2 is in the wedge limited by the –π/4 ray from the neighbors of s Hence, if invariant 3 is held on G1 and G2, it is also held on G Symmetrically invariant 4 can be proved u s

25 Therefore: Proving Invariants 3 and 4 guarantee that s and t can be moved as described in the algorithm without creating crossings. Invariant 2 states that left corner of Δ(Γ) is always empty, so G2’s left corner can be on the base of G1.

26 Area of the triangle So the base of resulting triangle is equals the sum of bases of both triangles. For a graph with e edges the length of the base is 2e (prove this inductively!) So the area needed is O(e2) Due to planarity, this is O(n2), where n is number of nodes

27 Calculating distances
We’ll describe Γ by: b = length of the base b’ = vertical distance to λu b’’ = vertical distance to λv κ b’’ λv t v b u s λu b’

28 Parallel distances To describe parallel combinations we’ll use: Δx = horizontal distance from Δ(Γ1) to Δ(Γ2) Δy = vertical distance from bottom ray of Δ(Γ1) to left corner of Δ(Γ2) Δx Γ1 Γ2 Δy

29 Δ-SP-label input : decomposition tree T of G output : labeling b, b’, b’’ for each subtree of T if root(T) is Q-node then b(T) = b’(T) = b’’(T) = 2 else Call Δ-SP-label for T’s subtrees T1 and T2 if root is S-node then b(T) = b(T1) + b(T2) b’(T) = b’(T1) b’’(T) = b’’(T2) else // root is P-node b(T) = b(T1) + b(T2)+2Δx if T2 is Q-node (transitive edge) then b’(T) = b’’(T) = b(T) else b’’(T) = b(T1) + 2Δx – Δy + b’’(T2) b’(T) = b’(T2) + Δy T2 T1 T1 T2

30 Δ-SP-label Δx can be 0 Δy can be b’(T1) The area needed is O(n2)
The algorithm runs in O(n) and needs O(n) space

31 Summary SP Digraphs are planar graphs, defined recursively by serial and parallel decomposition Embedding preserving, straightline, upward drawing may require exponential area Δ-SP drawing by Bertolazzi et al. changes embedding and achieves quadratic area, runs in linear time


Download ppt "5-Minute Review How does the Inorder tree layout algorithm work? Which tree drawing requirements does it (not) fulfill? What is its main drawback? How."

Similar presentations


Ads by Google