chapter 9 (layered drawings of digraphs) by: waldo & ludo uv
TRANSCRIPT
Chapter 9 (Layered drawings of digraphs)
By: Waldo & Ludo
u v
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 :
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
8 5
11
9
7 6
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.
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
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.
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
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.
Crossing Reduction
• Input: proper layered digraph
• Layer-by-Layer Sweep
• Two-Layer Crossing Problem
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
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
1L
2L u v
x1
x2
11
ux 21
ux 31
ux
Crossing Numbers
0uvc
1L
2L uv
x1
x2
11
ux 21
ux 31
ux
Crossing Numbers
0uvc 1vuc
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
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
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
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(),(
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
Algorithms for minimizing
• Adjacent Exchange Similar to Bubble-sort
• Split Similar to Quick-sort
• Barycenter Method• Median Method
Quadratic time
Linear time
Adjacent-Exchange
u v
1L
2L
3uvc
Adjacent-Exchange
uv
1L
2L
3uvc 0vuc
Adjacent-Exchange
u v
1L
2L
2uvc
Adjacent-Exchange
uv
1L
2L
2uvc
2 uvc
1vuc
Split
a p
1L
2L
3apc
{}leftV {}rightV
Split
ap
1L
2L
0pac3apc
{}leftV {}rightV
Split
p b
1L
2L
{}leftV }{aVright
1pbc
Split
pb
1L
2L
{}leftV }{aVright
1pbc 2bpc
Split
p
1L
2L
{}leftV },{ baVright
1pbc 2bpc
Split
ap b
1L
2L
{}leftV },{ baVright
3 uvc
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
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
431 62 5
Not always optimal
7
Barycenter
431 62 5 7
Median
8 9 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
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
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
Cycle Removal
• Problem:– Minimizing leftward edges / feedback set R
• How?– Greedy Cycle Removal Algorithm
Cycle Removal
1 2 3
654
7 8 9
{}lS {}rS
• Iterate: prepend sinks to Sr and remove them from G
Cycle Removal
1 2 3
654
7 8
{}lS }9{rS
• Iterate: prepend sinks to Sr and remove them from G
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
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
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
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
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
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
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
Cycle Removal
1 2 3 6 4 5 7 8 9
1 2 3
654
7 8 9
Cycle Removal
1 2 3 6 4 5 7 8 9
1 2 3
654
7 8 9
Chapter 9 (in a nutshell)
The hierarchical approach:Layer assignmentCrossing reductionHorizontal coordinate assignment
Exercise
1) Prove Theorem 9.1 (Exercise 3 in book)