520 likes | 717 Views
Chapter 9 (Layered drawings of digraphs). u. v. By: Waldo & Ludo. Chapter 9 (Graphically). Handled by :. DiGraph G. Cyclic. (9.4). Waldo. Cycle Removal. aCyclic. Ludo. (9.1). Layer assignment. Waldo. (9.2). Crossing reduction. Layered drawing of G. (9.3).
E N D
Chapter 9 (Layered drawings of digraphs) u v By: Waldo & Ludo
Chapter 9 (Graphically) Handled by : DiGraph G Cyclic (9.4) Waldo Cycle Removal aCyclic Ludo (9.1) Layer assignment Waldo (9.2) Crossing reduction Layered drawing of G (9.3) X coordinate assignment • The hierarchical approach:
Important requirements of layering: • The layered digraph should be compact. • The layering should be proper. • The number of dummy vertices should be small
The layering algorithm: • No labels are set • Assign labels (integer), such that s < v < t • Assign vertices to a layer, such that layer of t <= v <= s
selecting vertices to label • When choosing a vertex v all preceding vertices u (u,v) should be labeled and minimized.Minimization is accomplished by looking at the most significant labels.Example {6} < {3,7}; {1,2,9} < {2,3,9}; etc. For more on this definition see page 274 of the book
Phase one (assign labels) 7 6 9 8 5 10 11 12 13 1 2 4 3
selecting vertices to add to a layer • When choosing a vertex u all vertices v (u,v) should be placed in a layer lower than u.
Phase two (assign layers) 1 2 1 3 2 7 3 6 4 5 4 9 8 5 10 8 7 6 11 12 13 10 9 12 11 13
Algorithm (Coffman-Graham layering) Input: Reduced digraph G=(V,E) and a positive integer WOutput: Layering of G of width at most W Initially, all vertices are unlabeled (trivial, as we’ve seen) For (i = 1 to |V|) performa. Choose an unlabeled vertex v, such that {lbl(u) : (u,v) element of E } is minimizedb. Lbl(v) = i K=1; L1=null; U=null.While U != V loopa. Choose u element of (V-U), such that every vertex in {v : (u,v) element of E} is in U, and lbl(u) is maximizedb. Ifnot |Lk| < W and for every edge (u,w), w is element of preceding levelsthen k++; add u to Lkc. Add u to U.
Phase two (adjusted) 2 1 1 7 3 6 4 4 3 9 8 5 10 8 7 11 12 10 9 13 12 11 5 6 13 2
Algorithm (Coffman-Graham layering)adjusted • Exercise.. (only for phase two – previous slide) A. Describe the adjusted algorithmB. Draw the iterational steps of the adjusted algorithm one by one.
Crossing Reduction Input: proper layered digraph Layer-by-Layer Sweep Two-Layer Crossing Problem
Two-Layer Crossing Problem Each vertex in the two layers gets a unique x-coordinate, purely for ordering purposes:
Two-Layer Crossing Problem Two-Layer Crossing Problem
CrossingNumbers u v
CrossingNumbers v u
CrossingNumbers p q u r
CrossingNumbers p q u r
CrossingNumbers p q u r
CrossingNumbers p q u r
Crossing Numbers p q u r
Algorithms for minimizing Quadratic time Linear time • Adjacent Exchange • Similar to Bubble-sort • Split • Similar to Quick-sort • Barycenter Method • Median Method
Split a p
Split p a
Split p b
Split b p
Split p
Split p a b
Barycenter Method u 1 2 3 4 5 6 7 If same barycenter: seperate arbitrarily by small amount
Median Method u 1 2 3 4 5 6 7 Median ??? • X-coordinate of u is the median of its neighbours • If no neighbours, then med(u) = 0 • Special case, if med(u) = med(v)...odd degree left, even right
Not always optimal Barycenter 1 2 3 4 5 6 7 Median 10 1 2 3 4 5 6 7 8 9
Horizontal Coordinate Assignment • Bends occur at dummy vertices • Objective is to: • Reduce angles of bends (minimal width) • Keep ordering of crossing reduction step
Horizontal Coordinate Assignment X 0 1 2 3 4 5 6 1 2 2 3 3 4 5 6
Cycle Removal • Vertex sequence for G: 1 2 3 4 5 6 • Dashed edges are the leftward edges • Leftward edges form feedback set R • Reversing R makes G acyclic 7 8 9 1 2 3 4 6 7 9 8 5
Cycle Removal • Problem: • Minimizing leftward edges / feedback set R • How? • Greedy Cycle Removal Algorithm
Cycle Removal 1 2 3 • Iterate: prepend sinks to Sr and remove them from G 4 5 6 7 8 9
Cycle Removal 1 2 3 • Iterate: prepend sinks to Sr and remove them from G 4 5 6 7 8
Cycle Removal 1 2 3 • Iterate: prepend sinks to Sr and remove them from G 4 5 6 • Iterate: append sources to Sl and remove them from G 7 8
Cycle Removal 2 3 • Iterate: prepend sinks to Sr and remove them from G 4 5 6 • Iterate: append sources to Sl and remove them from G 7 8
Cycle Removal 3 • Iterate: prepend sinks to Sr and remove them from G 4 5 6 • Iterate: append sources to Sl and remove them from G 7 8
Cycle Removal • Iterate: prepend sinks to Sr and remove them from G 4 5 6 • Iterate: append sources to Sl and remove them from G 7 8
Cycle Removal • Iterate: prepend sinks to Sr and remove them from G 4 5 • Iterate: append sources to Sl and remove them from G 7 8
Cycle Removal • Iterate: prepend sinks to Sr and remove them from G 4 5 • Iterate: append sources to Sl and remove them from G 7 8 • Choose vertex u such the outdegree(u) – indegree(u) is max, append to Sl and remove from G
Cycle Removal • Iterate: prepend sinks to Sr and remove them from G • Iterate: append sources to Sl and remove them from G • Choose vertex u such the outdegree(u) – indegree(u) is max, append to Sl and remove from G • Concatenate Sl and Sr to obtain S
Cycle Removal 1 2 3 4 5 6 7 8 9 1 2 3 6 5 7 9 8 4
Cycle Removal 1 2 3 4 5 6 7 8 9 1 2 3 6 5 7 9 8 4