# Chapter 9 (Layered drawings of digraphs) By: Waldo & Ludo uv.

## Presentation on theme: "Chapter 9 (Layered drawings of digraphs) By: Waldo & Ludo uv."— Presentation transcript:

Chapter 9 (Layered drawings of digraphs) By: Waldo & Ludo uv

Chapter 9 (Graphically) 1.The hierarchical approach: Cyclic aCyclic Layered drawing of G DiGraph G Cycle Removal (9.4) Layer assignment Crossing reduction X coordinate assignment (9.1) (9.2) (9.3) Waldo Ludo Waldo Handled by :

Important requirements of layering: 1.The layered digraph should be compact. 2.The layering should be proper. 3.The number of dummy vertices should be small

The layering algorithm: 1.No labels are set 2.Assign labels (integer), such that s < v < t 3.Assign vertices to a layer, such that layer of t <= v <= s

selecting vertices to label 1.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) 3 1 4 2 13 12 10 85 11 9 76

selecting vertices to add to a layer 1.When choosing a vertex u all vertices v (u,v) should be placed in a layer lower than u.

Phase two (assign layers) 13 12 10 11 9 8 5 3 1 7 4 2 6 13 12 10 85 3 1 11 9 7 4 2 6

Input: Reduced digraph G=(V,E) and a positive integer W Output: Layering of G of width at most W Algorithm (Coffman-Graham layering) Initially, all vertices are unlabeled (trivial, as we’ve seen) For (i = 1 to |V|) perform a. Choose an unlabeled vertex v, such that {lbl(u) : (u,v) element of E } is minimized b. Lbl(v) = i K=1; L1=null; U=null. While U != V loop a. Choose u element of (V-U), such that every vertex in {v : (u,v) element of E} is in U, and lbl(u) is maximized b. If not |Lk| < W and for every edge (u,w), w is element of preceding levels then k++; add u to Lk c. Add u to U.

Phase two (adjusted) 13 12 10 11 9 5 8 3 1 7 4 2 6 13 12 10 85 3 1 11 9 7 4 2 6

Algorithm (Coffman-Graham layering) adjusted 1)Exercise.. (only for phase two – previous slide) A. Describe the adjusted algorithm B. 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

Each vertex in the two layers gets a unique x-coordinate, purely for ordering purposes: Two-Layer Crossing Problem

uv Crossing Numbers

uv

pur q pqur p0211 q5063 u6906 r2320

pur q pqur p0211 q5063 u6906 r2320

pur q pqur p0211 q5063 u6906 r2320

pur q pqur p0211 q5063 u6906 r2320

pur q pqur p0211 q5063 u6906 r2320

Algorithms for minimizing Adjacent Exchange  Similar to Bubble-sort Split  Similar to Quick-sort Barycenter Method Median Method Quadratic time Linear time

uv

uv

uv

Split ap

ap

pb

pb

p

apb

u 431625 Barycenter Method 7 If same barycenter: seperate arbitrarily by small amount

u 431625 Median Method 7 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 Median ???

431625 Not always optimal 7 Barycenter 4316257 Median 89 10

Bends occur at dummy vertices Objective is to: – Reduce angles of bends (minimal width) – Keep ordering of crossing reduction step Horizontal Coordinate Assignment

4 3 1 6 2 5 0123456X 2 3

Cycle Removal 1 23 654 789 1 2 3 4 5 6 7 8 9 Vertex sequence for G : Dashed edges are the leftward edges Leftward edges form feedback set R Reversing R makes G acyclic

Cycle Removal Problem: – Minimizing leftward edges / feedback set R How? – Greedy Cycle Removal Algorithm

Cycle Removal 1 23 654 789 Iterate: prepend sinks to S r and remove them from G

Cycle Removal 1 23 654 78 Iterate: prepend sinks to S r and remove them from G

Cycle Removal 1 23 654 78 Iterate: prepend sinks to S r and remove them from G Iterate: append sources to S l and remove them from G

Cycle Removal 23 654 78 Iterate: prepend sinks to S r and remove them from G Iterate: append sources to S l and remove them from G

Cycle Removal 3 654 78 Iterate: prepend sinks to S r and remove them from G Iterate: append sources to S l and remove them from G

Cycle Removal 654 78 Iterate: prepend sinks to S r and remove them from G Iterate: append sources to S l and remove them from G

Cycle Removal 54 78 Iterate: prepend sinks to S r and remove them from G Iterate: append sources to S l and remove them from G

Cycle Removal 54 78 Iterate: prepend sinks to S r and remove them from G Iterate: append sources to S l and remove them from G Choose vertex u such the outdegree(u) – indegree(u) is max, append to S l and remove from G

Cycle Removal Iterate: prepend sinks to S r and remove them from G Iterate: append sources to S l and remove them from G Choose vertex u such the outdegree(u) – indegree(u) is max, append to S l and remove from G Concatenate S l and S r to obtain S

Cycle Removal 1 2 3 6 4 5 7 8 9 1 23 654 789

1 2 3 6 4 5 7 8 9 1 23 654 789

Chapter 9 (in a nutshell) The hierarchical approach: Layer assignment Crossing reduction Horizontal coordinate assignment

Exercise 1)Prove Theorem 9.1 (Exercise 3 in book)

Download ppt "Chapter 9 (Layered drawings of digraphs) By: Waldo & Ludo uv."

Similar presentations