CS6234 L1 Matching
-
Upload
beverly-paman -
Category
Documents
-
view
218 -
download
0
Transcript of CS6234 L1 Matching
-
8/9/2019 CS6234 L1 Matching
1/68
Hon Wai Leong, NUS (CS6234, Spring 2009) Page 1Copyright © 2009 y Leong Hon Wai
CS6234: Lecture 1
Matching in GraphMatching in Bipartite Graph [PS82]-Ch10
Matching in General Graph [PS82]-Ch10
!eighte" Matching in Bipartite Graph
[PS82]-Ch 11#1$11#2
%""iti&nal t&pic: Reading/Presentation by students
Lecture notes modified from those by Lap Chi LAU, CUHK.
-
8/9/2019 CS6234 L1 Matching
2/68
2
Bipartite Matching
-
8/9/2019 CS6234 L1 Matching
3/68
3
Bipartite Matching
A graph is bipartite if its vertex set can be partitionedinto to subsets A and B so that each edge has one
endpoint in A and the other endpoint in B.
A matching M is a subset of edges so that
every vertex has degree at most one in M.
A B
-
8/9/2019 CS6234 L1 Matching
4/68
4
The bipartite matching problem:!ind a matching ith the maximum number of edges.
Maximum Matching
A perfect matching is a matching in hich every vertex is matched.
The perfect matching problem: "s there a perfect matching#
-
8/9/2019 CS6234 L1 Matching
5/68
-
8/9/2019 CS6234 L1 Matching
6/68
6
Key Questions
$ Ho to te(( if a graph does not have a &perfect' matching#
$ Ho to determine the si)e of a maximum matching#
$ Ho to find a maximum matching efficient(y#
-
8/9/2019 CS6234 L1 Matching
7/68
7
Ha((*s +heorem -/012
A bipartite graph %3&A,B45' has a matching that 6saturates7 A
if and on(y if 89&:'8 ;3 8:8 for every subset : of A.
:9&:'
Existence of Perfect Matching
-
8/9/2019 CS6234 L1 Matching
8/68
8
K
-
8/9/2019 CS6234 L1 Matching
9/68
-
8/9/2019 CS6234 L1 Matching
10/68
10
%iven a matching M, an M#alternating path is a path that a(ternates
beteen edges in M and edges not in M. An M>a(ternating path
hose endpoints are unmatched by M is an M#augmenting path.
ugmenting Path
-
8/9/2019 CS6234 L1 Matching
11/68
11
=hat if there is no more M>augmenting path#
?rove the contrapositive2
A bigger matching an M >augmenting path
-. Consider@. 5very vertex in has degree at most @
/. A component in is an even cyc(e or a path
. :ince , an M>augmenting path
"f there is no M>augmenting path, then M is maximum
$ptimality %ondition
-
8/9/2019 CS6234 L1 Matching
12/68
12
AlgorithmKey: M is maximum no M -augmenting path
Ho to find efficient(y#Ho to find efficient(y#
-
8/9/2019 CS6234 L1 Matching
13/68
13
Finding -augmenting paths Orient the edges (edges in M go up, others go down)
An M -augmenting path
a direted path !etween two unmatched "erties
-
8/9/2019 CS6234 L1 Matching
14/68
14
Complexity At most n iterations
An augmenting path in time !# a $%& or a '%&
ota running time
-
8/9/2019 CS6234 L1 Matching
15/68
15
Ha((*s +heorem -/012
A bipartite graph %3&A,B45' has a matching that 6saturates7 A
if and on(y if 89&:'8 ;3 8:8 for every subset : of A.
K
-
8/9/2019 CS6234 L1 Matching
16/68
16
Ebservation2 Many short and disFoint augmenting paths.
"dea2 !ind augmenting paths simu(taneous(y in one search.
Faster lgorithms
-
8/9/2019 CS6234 L1 Matching
17/68
-
8/9/2019 CS6234 L1 Matching
18/68
18
pplication of Bipartite Matching
=ith Ha((*s theorem, no you can determine exact(y
hen a partia( chessboard can be fi((ed ith dominos.
-
8/9/2019 CS6234 L1 Matching
19/68
-
8/9/2019 CS6234 L1 Matching
20/68
-
8/9/2019 CS6234 L1 Matching
21/68
Hon Wai Leong, NUS (CS6234, Spring 2009) Page 21Copyright © 2009 y Leong Hon Wai
CS6234:
Matching in GraphMatching in Bipartite Graph
Matching in General Graph
!eighte" Matching in Bipartite Graph
%""iti&nal t&pic: Reading/Presentation by students
Lecture notes modified from those by Lap Chi LAU, CUHK.
-
8/9/2019 CS6234 L1 Matching
22/68
22
%enera( Matching
-
8/9/2019 CS6234 L1 Matching
23/68
23
+eneral Matching
%iven a graph ¬ necessari(y bipartite',
find a matching ith maximum tota( eight.
un,eighted -cardinality. 'ersion2
a matching ith maximum number of edges
-
8/9/2019 CS6234 L1 Matching
24/68
24
Today/s Plan
$ Min>max theorems no proofs1
$ ?o(ynomia( time a(gorithm
$ Chinese postman sip1
!o((o the same structure for bipartite matching.
-
8/9/2019 CS6234 L1 Matching
25/68
-
8/9/2019 CS6234 L1 Matching
26/68
26
Min#Max Theorem
+utte>Berge formu(a -012
+he si)e of a maximum matching 3
K
-
8/9/2019 CS6234 L1 Matching
27/68
27
%iven a matching M, an M#alternating path is a path that a(ternates
beteen edges in M and edges not in M. An M>a(ternating pathhose endpoints are unmatched by M is an M#augmenting path.
ugmenting Path"
=ors for genera( graphs.
-
8/9/2019 CS6234 L1 Matching
28/68
28
=hat if there is no more M>augmenting path#
?rove the contrapositive2
A bigger matching an M >augmenting path
-. Consider
@. 5very vertex in has degree at most @
/. A component in is an even cyc(e or a path
. :ince , an M>augmenting path
"f there is no M>augmenting path, then M is maximum#
$ptimality %ondition"
-
8/9/2019 CS6234 L1 Matching
29/68
29
Agorithm*
Key: M is maximum no M -augmenting path
Ho to find efficient(y#
-
8/9/2019 CS6234 L1 Matching
30/68
30
Finding ugmenting Path in Bipartite +raphs
Erient the edges &edges in M go up, others go don'
edges in M having positive eights, otherise negative eights
"n a bipartite graph, an M>augmenting path corresponds to a directed path.
-
8/9/2019 CS6234 L1 Matching
31/68
-
8/9/2019 CS6234 L1 Matching
32/68
32
o repeated "erties. &o*
+ /ust ind an aternating path without repeated "erties*
ither we ma# eude some possi!iities,
r we need to trae the path
-
8/9/2019 CS6234 L1 Matching
33/68
-
8/9/2019 CS6234 L1 Matching
34/68
-
8/9/2019 CS6234 L1 Matching
35/68
35
e# emma
+ (dmonds) M is a maimum mathing in G
M/C is a maimum mathing in G/C
Key: M is maximum no M -augmenting path
+ ∃ an M -augmenting path in G
∃ an M/C -augmenting path in G/C
-
8/9/2019 CS6234 L1 Matching
36/68
36
∃ an M/C -augmenting path
∃ an M -augmenting path
9ote2 $ne of the to paths around the b(ossomi(( be the correct one.
-
8/9/2019 CS6234 L1 Matching
37/68
-
8/9/2019 CS6234 L1 Matching
38/68
-
8/9/2019 CS6234 L1 Matching
39/68
39
Agorithm
Key: M is maximum no M -augmenting path
Ho to find efficient(y#
-
8/9/2019 CS6234 L1 Matching
40/68
40
%inding an M -augmenting path
+ %ind an aternating wa !etween two ree "erties.
+ his an !e done in inear time !# a $%& or a '%&.
+ ither an M -augmenting path or a !ossom an !e ound.
+ a !ossom is ound, shrin it, and (reursi"e#) ind an M/C -augmenting path P in G/C , and then
epand P to an M -augmenting path in G.
-
8/9/2019 CS6234 L1 Matching
41/68
41
:ompeit#
+ At most n augmentations.
+ ah augmentation does at most n ontrations.
+ An aternating wa an !e ound in O(m) time.
+ ota running time is (mn2) .
-
8/9/2019 CS6234 L1 Matching
42/68
42
5istorical 6emar7s
"n his famous paper 6paths, trees, and f(oers7, Gac 5dmonds2
$ "ntroduced the notion of a 6good7 a(gorithm.
$ 5dmonds so(ved eighted genera( matching, prima( dua(.
$ Linear programming description, a breathrough in po(yhedra( combinatorics.
n $-n8. algorithm by Pape and %onradt9 4;3
6ef: *yslo9 =eo9 Ko,ali79 Prentice#5all9 4;8
=iscrete $ptimi0ation lgorithms9 %h 8?2
-
8/9/2019 CS6234 L1 Matching
43/68
43
+utte>Berge formu(a -012
+he si)e of a maximum matching 3
Pro'ing Min#Max Theorem
Comments by LeongH=2
:ip next fe s(ides on main(ycombinatoria( resu(tsD
&Anyone ants to do this forreading assignment#'
-
8/9/2019 CS6234 L1 Matching
44/68
44
M#alternating forest
Larger forest
M>augmenting path a b(ossom
=e mae progress in any of the above cases.
-
8/9/2019 CS6234 L1 Matching
45/68
45
M#alternating forest
Etherise e find the set in +utte>Berge formu(a.
-
8/9/2019 CS6234 L1 Matching
46/68
46
Edmonds#+allai =ecomposition
Can be obtained from M>a(ternating forest.Contains a (ot of information about matching.
-
8/9/2019 CS6234 L1 Matching
47/68
47
%hinese Postman
%iven an undirected graph, a vertex v, a (ength (&e' on each edge e,
find a shortest tour to visit every edge once and come bac to v.
isit every edge exact(y once if 5u(erian.
Etherise, find a minimum eighted perfect matching beteen odd vertices.
-
8/9/2019 CS6234 L1 Matching
48/68
CS6234
-
8/9/2019 CS6234 L1 Matching
49/68
Hon Wai Leong, NUS(CS6234, Spring 2009) Page 49
Copyright © 2009 y Leong Hon Wai
CS6234:
Matching in GraphMatching in Bipartite Graph
Matching in General Graph
!eighte" Matching in Bipartite Graph
%""iti&nal t&pic: Reading/Presentation by students
Lecture notes modified from those by Lap Chi LAU, CUHK.
-
8/9/2019 CS6234 L1 Matching
50/68
50
=eighted Bipartite Matching
-
8/9/2019 CS6234 L1 Matching
51/68
-
8/9/2019 CS6234 L1 Matching
52/68
52
Today/s Plan
+hree a(gorithms
$ negative cyc(e a(gorithm
$ augmenting path a(gorithm
$ prima( dua( a(gorithm
App(ications
-
8/9/2019 CS6234 L1 Matching
53/68
53
First lgorithm
Ho to no if a given matching M is optima(#
"dea2 "magine there is a (arger matching MS
and consider the union of M and MS
!ind maximum eight perfect matching
-
8/9/2019 CS6234 L1 Matching
54/68
-
8/9/2019 CS6234 L1 Matching
55/68
55
%irst Agorithm
Key: M is maximum no negative cycle
Ho to find efficient(y#
-
8/9/2019 CS6234 L1 Matching
56/68
56
:ompeit#
+ At most nW iterations
+ A negati"e #e in (n3) time !# %o#d ;arsha
+ ota running time (n4W )
+ :an hoose minimum mean #e to a"oid W
-
8/9/2019 CS6234 L1 Matching
57/68
57
Comments by LeongH=2
:ip next fe s(ides on Augmenting ?ath A(gorithm
&Anyone ants to do this for reading assignment#'
-
8/9/2019 CS6234 L1 Matching
58/68
-
8/9/2019 CS6234 L1 Matching
59/68
59
ugmenting Path lgorithm
Theorem: 5ach matching is an optima( >matching.
Let the current matching be M
Let the shortest M>augmenting path be ?
Let 9 be a matching of si)e 8M8T-
-
8/9/2019 CS6234 L1 Matching
60/68
-
8/9/2019 CS6234 L1 Matching
61/68
61
Primal =ual lgorithm
=hat is an upper bound of maximum eighted matching#
=hat is a genera(i)ation of minimum vertex cover#
eighted vertex cover2
Minimum eighted vertex cover ≥ Maximum eighted matching
-
8/9/2019 CS6234 L1 Matching
62/68
-
8/9/2019 CS6234 L1 Matching
63/68
63
Primal =ual lgorithm
Minimum eighted vertex cover≥
Maximum eighted matching
-. Consider the subgraph formed by tight edges &the eIua(ity subgraph'.
@. "f there is a tight perfect matching, done.
/. Etherise, there is a vertex cover.
. ecrease eighted cover to create more tight edges, and repeat.
etai(ed a(gorithm i(( be covered (ater&after L? ?rima(>ua( a(gorithms'
-
8/9/2019 CS6234 L1 Matching
64/68
64
:ompeit#
+ Augment at most n times, eah O(m)
+ $erease weighted o"er at most m times,eah O(m)
+ ota running time O(m2) @ O(n4)
+ ger"ar#, ?ungarian method
5istory: +he a(gorithm as deve(oped by Kuhn ho based iton or of 5gervary -/-1, &6(atent or of . Konig and G.5gervary7' and as given the name 6Hungarian method7.:ee :chrQ@1>Ch-J for more detai(s.
-
8/9/2019 CS6234 L1 Matching
65/68
65
Quic7 *ummary
-. !irst a(gorithm, negative cyc(e, usefu( idea to consider symmetric difference
@. Augmenting path a(gorithm, usefu( a(gorithmic techniIue
/. ?rima( dua( a(gorithm, a very genera( frameor
-. =hy prima( dua(#
@. Ho to come up ith eighted vertex cover#
/. Peduction from eighted case to uneighted case
-
8/9/2019 CS6234 L1 Matching
66/68
66
Faster lgorithms
-
8/9/2019 CS6234 L1 Matching
67/68
67
pplication of Bipartite Matching
Gerry
Maring
are +om"saac
+utoria(s :o(utions 9esgroup
(ob ssignment Problem:
5ach person is i((ing to do a subset of Fobs.
Can you find an assignment so that a(( Fobs are taen care of#
$ Ad>auction, %oog(e, on(ine matching
$ !ingerprint matching
-
8/9/2019 CS6234 L1 Matching
68/68
eadingBCresentation opis