Lecture 1 String and Language

Lecture 16
Maximum Matching
Incremental Method
• Transform from a feasible solution to
another feasible solution to increase (or
decrease) the value of objective function.
Matching in Bipartite Graph
Given a bipartite graph G  (V ,U , E ), a matching is a subset
of edges in which any two edges have no endpoint in
common.
Maximum Matching
Given a bipartite graph G  (V , E ), find a matching with
maximum cardinalit y.
1
1
Note: Every edge has capacity 1.
1. Can we do augmentation directly
in bipartite graph?
2. Can we do those augmentation
in the same time?
1. Can we do augmentation
directly in bipartite graph?
Yes!!!
Alternative Path
A vertex t hat is not the endpoint of an edge in some matching
M is called a free vertex.
An augmenting path is a path that starts at a free vertex, ends
at a free vertex, and alternates between unmatched and
matched edges within th e path.
Optimality Condition
A matching is maximum iff it has no augmenting path.
() Trivial.
() Let M and M * be two matchings with | M || M * | .
Then M  M * contains an augmenting path w.r.t . M .
M
M*
M*
M*
M
M*
M M *
deg M (v)  1
deg M * (v)  1
deg M M * (v)  2
Puzzle
If | M * |  | M | k , how many disjoint augmenting paths
w.r.t. M does M  M * contain?
Answer : exactly k , why?
Extension to Graph
Matching in Graph
Given a graph G  (V , E ), a matching is a subset
of edges in which any two edges have no endpoint in
common.
Maximum Matching
Given a graph G  (V , E ), find a matching with
maximum cardinalit y.
Note
• We cannot transform Maximum Matching
in Graph into a maximum flow problem.
• However, we can solve it with augmenting
path method.
Alternative Path
A vertex t hat is not the endpoint of an edge in some matching
M is called a free vertex.
An augmenting path is a path that starts at a free vertex, ends
at a free vertex, and alternates between unmatched and
matched edges within th e path.
Optimality Condition
A matching is maximum iff it has no augmenting path.
() Trivial.
() Let M and M * be two matchings with | M || M * | .
Then M  M * contains an augmenting path w.r.t . M .
M
M*
M*
M*
2. Can we do those augmentation
in the same time?
Hopcroft–Karp algorithm
• The Hopcroft–Karp algorithm may
therefore be seen as an adaptation of the
Edmonds-Karp algorithm for maximum
flow.
In Each Phase
In residual graph, find maximal set of disjoint shortest
paths from s to t.
In each phase, the length of the shortest augmenting
path increases by at least two.
s
t
Suppose flow f ' is obtained from flow f through an
augmentati on. If (v, u ) is on an augmenting path in G f ,
then (u, v)  G f and
 f (v)   f (u )  1   f ' (u )  1   f ' (v)  2.
s
s
u
v
in G f '
u
v
in G f
Running Time O( | V | | E |)
Each phase can be excuted in O(m) time.
Let M be the matching after
Reading Material
n phase and
M * maximum matching. Then M *  M contains
| M * |  | M | augmenting paths for M .
Each of them has length  2 n  1.
Thus, # of augmenting paths in M *  M is  n /2.
Hence, M * can be obtained from M through at most
n /2 phases.
Max Weighted Matching
Maximum Weight Matching
Given a bipartite graph G  (V , E ) with positive edge
weight w : E  R , find a matching with maximumis
total weight.
1
?
3
It is hard to be transformed to maximum flow!!!
Minimum Weight Matching
Given a graph G  (V , E ) with nonnegativ e edge weight
c : E  R , find a matching with maximumis toal weight.
Augmenting Path
A vertex t hat is not the endpoint of an edge in some matching
M is called a free vertex.
An augmenting path is a maxinal alternativ e path with propert
that, the total weight on unmatched edges  the total weight on
matched edges.
An augmenting cycle is an alternativ e cycle with the total
weight on unmatched edges  that on matched edges.
Optimality Condition
A matching is maximum - weight iff it has no augmenting
path and no augmenting cycle.
() Trivial.
() Let M and M * be two matchings with c( M )  c( M *).
Then M  M * contains an augmenting path/cycle w.r.t. M .
M
M*
M*
M*
36
37
38
39
40
41
42
43
44
45
Chinese Postman
The Chinese Postman wi shes to travel along every road
in a city in order to deliver letters, with the least possible
distance.
Given a graph with nonnegativ e edge weight, find
a shortest closed walk of the graph in which each
edge is traversed at least once.
Minimum Weight Perfect
Matching
• Minimum Weight Perfect Matching can be
transformed to Maximum Weight
Matching.
• Chinese Postman Problem is equivalent to
Minimum Weight Perfect Matching in
graph on odd nodes.