chapter 9 (layered drawings of digraphs) by: waldo & ludo uv

52
Chapter 9 (Layered drawings of digraphs) By: Waldo & Ludo u v

Upload: krystal-gord

Post on 01-Apr-2015

242 views

Category:

Documents


0 download

TRANSCRIPT

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

Chapter 9 (Layered drawings of digraphs)

By: Waldo & Ludo

u v

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

Chapter 9 (Graphically)

1. The hierarchical approach:

Cyclic

aCyclic

Layered drawing of G

DiGraph GCycle Removal

(9.4)

Layer assignment

Crossing reduction

X coordinate assignment

(9.1)

(9.2)

(9.3)

Waldo

Ludo

Waldo

Handled by :

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

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

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

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

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

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

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

Phase one (assign labels)

3

1

4

2

13

12

10

8 5

11

9

7 6

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

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.

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

1L2L3L

Phase two (assign layers)

4L

5L6L7L

13

12

10

11

9

8

5

3

1

7

4

2

6

13

12

10

8 5

3

1

11

9

7 4

2

6

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

Input: Reduced digraph G=(V,E) and a positive integer WOutput: 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|) 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. If not |Lk| < W and for every edge (u,w), w is element of preceding levels

then k++; add u to Lkc. Add u to U.

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

Phase two (adjusted)

1L2L3L4L

5L6L7L

13

12

10

11

9 5

8

3

1

7

4

26

13

12

10

8 5

3

1

11

9

7 4

2

6

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

Algorithm (Coffman-Graham layering)adjusted

1) Exercise.. (only for phase two – previous slide) A. Describe the adjusted algorithmB. Draw the iterational steps of the adjusted algorithm one by one.

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

Crossing Reduction

• Input: proper layered digraph

• Layer-by-Layer Sweep

• Two-Layer Crossing Problem

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

1L

2L

3L

x1

x2

11

ux 21

ux 31

ux

• Each vertex in the two layers gets a unique x-coordinate, purely for ordering purposes:

Two-Layer Crossing Problem

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

1L

2L

3L

x1

x2

11

ux 21

ux 31

ux

1),,( 21 xxGcross

),,(min),( 2112

xxGcrossxGoptx

Two-Layer Crossing Problem

Two-Layer Crossing Problem

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

1L

2L u v

x1

x2

11

ux 21

ux 31

ux

Crossing Numbers

0uvc

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

1L

2L uv

x1

x2

11

ux 21

ux 31

ux

Crossing Numbers

0uvc 1vuc

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

p u r

Crossing Numbers

q

p q u r

p 0 2 1 1

q 5 0 6 3

u 6 9 0 6

r 2 3 2 0

)()(

21

22

),,(vxuxuvcxxGcross

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

p u r

Crossing Numbers

q

p q u r

p 0 2 1 1

q 5 0 6 3

u 6 9 0 6

r 2 3 2 0

)()(

21

22

),,(vxuxuvcxxGcross

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

p u r

Crossing Numbers

q

p q u r

p 0 2 1 1

q 5 0 6 3

u 6 9 0 6

r 2 3 2 0 19

636112

)()(

21

22

),,(vxuxuvcxxGcross

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

p u r

Crossing Numbers

q

p q u r

p 0 2 1 1

q 5 0 6 3

u 6 9 0 6

r 2 3 2 0

vu

vuuv ccxGopt,

1 ),min(),(

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

p u r

Crossing Numbers

q

p q u r

p 0 2 1 1

q 5 0 6 3

u 6 9 0 6

r 2 3 2 0

vu

vuuv ccxGopt,

1 ),min(),(

15

236112

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

Algorithms for minimizing

• Adjacent Exchange Similar to Bubble-sort

• Split Similar to Quick-sort

• Barycenter Method• Median Method

Quadratic time

Linear time

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

Adjacent-Exchange

u v

1L

2L

3uvc

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

Adjacent-Exchange

uv

1L

2L

3uvc 0vuc

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

Adjacent-Exchange

u v

1L

2L

2uvc

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

Adjacent-Exchange

uv

1L

2L

2uvc

2 uvc

1vuc

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

Split

a p

1L

2L

3apc

{}leftV {}rightV

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

Split

ap

1L

2L

0pac3apc

{}leftV {}rightV

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

Split

p b

1L

2L

{}leftV }{aVright

1pbc

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

Split

pb

1L

2L

{}leftV }{aVright

1pbc 2bpc

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

Split

p

1L

2L

{}leftV },{ baVright

1pbc 2bpc

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

Split

ap b

1L

2L

{}leftV },{ baVright

3 uvc

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

u

431 62 5

Barycenter Method

7

uNv

vxu

uavg )()deg(

1)( 1

5.2)41(2

1)( uavgIf same barycenter: seperate arbitrarily by small amount

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

u

431 62 5

Median Method

7

)()( 2/1 jvxumed

• 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

??? )()( 2/1 jvxumed

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

431 62 5

Not always optimal

7

Barycenter

431 62 5 7

Median

8 9 10

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

• Bends occur at dummy vertices

• Objective is to:– Reduce angles of bends (minimal width)– Keep ordering of crossing reduction step

Horizontal Coordinate Assignment

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

4

3

1

6

2

5

6k

)()(1

1)()( 11 vxvxk

ivxvx ki

2)16(

5

2

ia

0 1 2 3 4 5 6X

2

3p

3i

1

2

2))(()(k

i ii avxpg

p

pg )(

)()( zxwx

Horizontal Coordinate Assignment

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

Cycle Removal

1 2 3

654

7 8 9

1 2 3 4 5 6 7 8 9

• Vertex sequence for G:

),...,,( 21 nvvvS • Dashed edges are the leftward edges • Leftward edges form feedback set R

• Reversing R makes G acyclic

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

Cycle Removal

• Problem:– Minimizing leftward edges / feedback set R

• How?– Greedy Cycle Removal Algorithm

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

Cycle Removal

1 2 3

654

7 8 9

{}lS {}rS

• Iterate: prepend sinks to Sr and remove them from G

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

Cycle Removal

1 2 3

654

7 8

{}lS }9{rS

• Iterate: prepend sinks to Sr and remove them from G

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

Cycle Removal

1 2 3

654

7 8

{}lS }9{rS

• Iterate: prepend sinks to Sr and remove them from G

• Iterate: append sources to Sl and remove them from G

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

Cycle Removal

2 3

654

7 8

}1{lS }9{rS

• Iterate: prepend sinks to Sr and remove them from G

• Iterate: append sources to Sl and remove them from G

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

Cycle Removal

3

654

7 8

}2,1{lS }9{rS

• Iterate: prepend sinks to Sr and remove them from G

• Iterate: append sources to Sl and remove them from G

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

Cycle Removal

654

7 8

}3,2,1{lS }9{rS

• Iterate: prepend sinks to Sr and remove them from G

• Iterate: append sources to Sl and remove them from G

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

Cycle Removal

54

7 8

}6,3,2,1{lS }9{rS

• Iterate: prepend sinks to Sr and remove them from G

• Iterate: append sources to Sl and remove them from G

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

Cycle Removal

54

7 8

}6,3,2,1{lS }9{rS

• 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

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

Cycle Removal

}8,7,5,4,6,3,2,1{lS }9{rS

• 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

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

Cycle Removal

1 2 3 6 4 5 7 8 9

1 2 3

654

7 8 9

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

Cycle Removal

1 2 3 6 4 5 7 8 9

1 2 3

654

7 8 9

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

Chapter 9 (in a nutshell)

The hierarchical approach:Layer assignmentCrossing reductionHorizontal coordinate assignment

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

Exercise

1) Prove Theorem 9.1 (Exercise 3 in book)