transcript
- Slide 1
- (Algorithms in Bipartite Graphs)
- Slide 2
- Introduction Algorithms in unweighted bipartite graph (Yehong
& Gordon) Maximum matching A simple algorithm Hopcroft-Karp
algorithm Stable marriage problem (Wang wei) GaleShapley algorithm
Algorithms in weighted bipartite graph (Wang Sheng & Jinyang)
Assignment problem Hungarian method & Kuhn-Munkres algorithm
Q&A 2 Outline
- Slide 3
- Definition A graph G = (V, E) is bipartite if there exists
partition V = X Y with X Y = and E X Y. Bipartite Graph types
Unweighted Weighted For every edge e E, there is a weight w(e). 3
Introduction
- Slide 4
- Example: There are a set of boys and a set of girls. Each boy
only likes girls and each girl only likes boys. A common friend
wants to match each boy with a girl such that the boy and girl are
both happy but they both will only be happy if the boy likes the
girl and the girl likes the boy. Is it possible for every
situation? 4 Introduction We can use a bipartite graph to model
this problem
- Slide 5
- Problem Testing bipartiteness Matching Maximum matching problem
Perfect matching problem Stable marriage problem Maximum weight
matching problem 5 Introduction
- Slide 6
- Yehong
- Slide 7
- Definition Matching A Matching is a subset M E such that v V at
most one edge in M is incident upon v 7 Perfect Matching A matching
which matches all vertices of the graph Maximum matching
- Slide 8
- A Matching A Maximum Matching 8 Not a Matching Definition We
say that a vertex is matched if it is incident to some edge in M.
Otherwise, the vertex is free matched free (not perfect) Maximum
matching
- Slide 9
- Definition Alternating Paths A path is alternating if its edges
alternate between M and E M. Augmenting Paths An alternating path
is augmenting if both endpoints are free Alternating Tree A tree
rooted at some free vertex v in which every path is an alternating
path. Alternating paths ( Y 1, X 2, Y 2, X 4 ) Augmenting Path (Y
1, X 2, Y 2, X 4, Y 4, X 5 ) 9 Maximum matching
- Slide 10
- Property of Augmenting Paths Replacing the M edges by the E M
ones increments size of the matching (Path: Y 1, X 2, Y 2, X 4, Y
4, X 5 ) 10 Berge's Theorem: A matching M is maximum iff it has no
augmenting path (Proof: Lec01 Page 3)Lec01 Maximum matching
- Slide 11
- A simple algorithm 11 X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4
Maximum matching
- Slide 12
- A simple algorithm 12 X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4 X2X2
X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4 X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4
Maximum matching
- Slide 13
- A simple algorithm 13 X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4 X2X2
X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4 X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4
X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4 Maximum matching
- Slide 14
- A simple algorithm 14 X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4 X2X2
X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4 X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3 Y4Y4
Maximum matching
- Slide 15
- A simple algorithm 15 Commonly search algorithm (BFS, DFS) O(E)
At most V times Complexity: O(VE) X2X2 X3X3 X1X1 Y1Y1 Y2Y2 Y3Y3
Y4Y4 Maximum matching
- Slide 16
- An algorithm to find the maximum matching given a bipartite
graph Gordon
- Slide 17
- Introduction The Hopcroft-Karp algorithm was published in 1973
It is a matching algorithm that finds a maximum matching in
bipartite graphs The main idea is to augment along a set of
vertex-disjoint shortest augment paths simulatenously The
complexity is O(|V||E|) In this section, some Theorems and Lemmas
from graph theory will be stated without showing the proof.
- Slide 18
- Definition We let the set A B denote the symmetric difference
of the set A B = (A B) (A B) A maximal set of vertex-disjoint
minimum length augmenting path is defined as follows : It is a set
of augmenting path No two path share a same vertex If the minimum
length augmenting path is of length k, then all paths in S are of
length k If p is an augmenting path not in S, then p shares a
vertex with some path p in S
- Slide 19
- Algorithm The algorithm of Hopcroft and Kraft is as follows :
Given a graph G = (X Y),E) 1) Let M = {}, 2) Find S = {P 1, P 2, P
k } 3) While S {} M = M S Find S 4) Output M
- Slide 20
- Demonstration of algorithm at some stage Let the dark edges
represent the edges in a matching M
- Slide 21
- Demonstration of algorithm at some stage Pink edges represent
an augmenting path Deleting them
- Slide 22
- Demonstration of algorithm at some stage Another augmenting
path No more paths
- Slide 23
- Demonstration of algorithm at some stage Pink edges represent
the paths in maximal set S M S Note the before and after
- Slide 24
- Algorithm Question : How do we know that this algorithm
produces the result that we want ? Theorem 1 (Berge) : A matching M
is maximum if and only if there is no augmenting path with respect
to M This theorem guarantees the correctness of the algorithm We
will now prove that the complexity of the algorithm is
O(|V||E|)
- Slide 25
- Lemma 2 : A maximal set S of vertex-disjoint minimum length
augmenting paths can be found in O(|E|) time Proof : Let G = (U
V,E) be the graph that we are working on and M be a matching First,
we construct a tree-like/directed acyclic graph graph given G We
start with all the free vertices in U at level 0
- Slide 26
- Starting at level 2k (even), the vertices at level 2k+1 are
obtained by following free edges from edges at level 2k Starting at
level 2k+1 (odd), the level at 2k+2 are obtained by following
matched edges from vertices at level 2k+1 Note that the even levels
contain vertices from U and odd levels from V Continuation of proof
of lemma 2 Recall the earlier example : There are 3 levels here U
V
- Slide 27
- Continuation of proof of lemma 2 We continue building the tree
until all vertices have been visited or until a free vertex is
encountered (say t) Note that in the latter case, the free vertices
are encountered at V Complexity of this portion of building the
tree is linear to the size of the edges ( similar to BFS)
- Slide 28
- Continuation of proof of lemma 2 Example : 0123 Dashed line
represent edges while the normal lines represent edges in the
matching M Free-vertex
- Slide 29
- Continuation of proof of lemma 2 Now we find a maximal set S of
vertex disjoint paths in this tree that we constructed We assign a
counter to all vertices after level 0 This counter represents the
number of edges entering the vertex previous level (think of it
like an indegree) Starting at a free vertex v at level t, we trace
a path until we reach a free vertex u at level 0
- Slide 30
- Continuation of proof of lemma 2 This path is an augmenting
path and we add it into S After which, we add the vertices in this
path into a deletion queue As long as the deletion queue is non
empty, we delete the vertex in the queue and from the constructed
tree This includes all the edges incident onto it Recall the
earlier example
- Slide 31
- Continuation of proof of lemma 2 Whenever an edge is deleted,
the counter associated with its right endpoint are all decremented
If the counter becomes 0, put the vertex into the deletion queue
(there can be no augmenting path from this vertex) After emptying
the deletion queue, if there are still free vertex at level t, it
means that an augmenting path must still exist
- Slide 32
- Continuation of proof of lemma 2 We continue until there are no
more free vertex at level t This entire process takes linear time,
since it is proportional to the number of edges deleted Therefore
this part takes O(|E|) Total time complexity for both parts is
O(|E|)
- Slide 33
- Continuation of proof of lemma 2 Example : Consider the path :
v6 u6 v5 u1 V6U6V5U1 Deletion Queue Counter of v1 decreases by
1
- Slide 34
- Continuation of proof of lemma 2 Example : Now consider the
path : v3 u3 v1 u2 V3U3V1U2 Deletion Queue V2U4V4 000
- Slide 35
- Theorems and Lemmas cited without proof Lemma 3 : Let M* be a
maximum matching, and let M be any matching in G. If the length of
the shortest augmenting path with respect to M is k, then |M*| -
|M| (|V|/k) Lemma 4 : Let k be the length of the shortest
augmenting path with respect to M and let S be a maximal set of
shortest disjoint augmenting paths with respect to M, then the
length of the shortest augmenting path with respect to M S is
larger than k
- Slide 36
- Theorem 5: The Hopcroft-Karp algorithm finds a maximum matching
in a bipartite graph in O(|V||E|) time Proof : Now we run the
algorithm for |V| and let M be matching after running those rounds
Lemma 4 implies that we have that in each phrase of the algorithm,
the length of the shortest augmenting path increases by at least 1
Therefore the size of the shortest augmenting path must be at least
|V|
- Slide 37
- Now from Lemma 3, we have that |M*| - |M| (|V|/|V|) = |V| In
each phrase, we increase the size of the matching by at least 1, so
therefore, at most |V| more phrases needed Therefore at most 2 |V|
phrases are needed for this entire algorithm. Therefore with lemma
2, the time complexity of the algorithm is O(|V| |E|) Continuation
of proof of Theorem 5
- Slide 38
- Wang Wei
- Slide 39
- Problem definition: Given n men and n women, each person has a
preference list for all members of the opposite sex; Find a
one-to-one match M. If m(a man) and w (a woman) are matched in M,
then m is the partner of w, and vice verse. Blocking pair in a
match M: (m, w), m prefers w than his partner in M, and w prefers m
than her partner. Stable match: no blocking pair exist.
Terminology
- Slide 40
- For each man, try to find a woman, with whom they form a
blocking pair; if no such woman exist, then the match is stable.
Complexity: O(n 2 )
Example:http://mathsite.math.berkeley.edu/smp/smp.html
Stability-checking algorithm
- Slide 41
- For man, propose to every women on his preference list until
get engaged; For woman, wait for proposal, accept if free or prefer
the proposer than current partner/fiance; otherwise reject the
proposal; Complexity: O(n 2 ) Basic Gale-Shapley algorithm
- Slide 42
- For any given instance of the stable marriage problem, the
Gale- Shapley algorithm terminates, and, on termination, the
engaged pairs constitute a stable matching. Termination: Stability:
if m prefers w than his partner, then w must have rejected m, i.e.,
w prefers her partner to m. (m,w) cannot be a block pair no block
pair exists. If GS not terminate, then at least one man is free He
must be rejected by all women Once a woman is engaged, she will
never be free To reject a man, the woman must be engaged All women
are engaged All men are engaged Theorem 1.
- Slide 43
- Theorem 2: All possible executions of the Gale-Shapley
algorithm(with the men as the proposers) yield the same stable
matching, in which, man has the best partner he can have in any
stable matching. Theorem 3: In the man-optimal stable matching,
each woman has the worst partner that she can have in any stable
matching.
- Slide 44
- Jinyang
- Slide 45
- Suppose we have n resources to which we want to assign to n
tasks on a one-to-one basis. Suppose we also know the cost(gain) of
assigning a given resource to a given task. We wish to nd an
optimal assignmentone which minimizes(maximizes) total cost(gain).
Min-Cost or Max-Weight Perfect Matching in Bipartite Graph.
Assignment Problem
- Slide 46
- Three students collaborate to finish a project. Their
efficiency is different. codingtestwriting John4 hours3 hours
Terry6 hours4 hours5 hours Eric7 hours 5 hours Example
- Slide 47
- We will formula this problem in a matrix representation. It is
easier to illustrate its key idea and how it works. We will explain
how to implement it into algorithm and show its complexity later.
We will use minimum cost form of the problem. For maximum problem,
we just reverse the num. Matrix Representation
- Slide 48
- Slide 49
- Difficulty
- Slide 50
- If a number is added to or subtracted from all of the entries
of any one row or column of a cost matrix, then on optimal
assignment for the resulting cost matrix is also an optimal
assignment for the original cost matrix. You have to choose one
entry in each row or column any way. So this operation add or
reduce the same number for all assignment. Theorem 1
- Slide 51
- Assignment Problem
- Slide 52
- When there exist a assignment has a zero cost in a non-negative
matrix. This assignment is an optimal assignment. Theorem 2
- Slide 53
- The key idea of Hungarian Method is to transform the original
matrix to a non-negative matrix which have a zero assignment by add
or subtract operation in each row and column. There will be some
slight difference in different implementation. Hungarian
Method
- Slide 54
- Step 1: Subtract the smallest entry in each row from all the
entries of its row. Step 2: Subtract the smallest entry in each
column from all the entries of its column. This two step is not
necessary. But it can reduce the number of iterations later. The
only requirement is that it comes to a non-negative matrix.
Hungarian Method
- Slide 55
- Step 3: Draw lines through appropriate rows and columns so that
all the zero entries of the cost matrix are covered and the minimum
number of such lines is used. Step 4: If the minimum number of
covering lines is n, an optimal assignment of zeros is possible and
we are nished. Else continue step 5. Step 5: Determine the smallest
entry not covered by any line. Subtract this entry from each
uncovered row, and then add it to each covered column. Return to
Step 3. Hungarian Method
- Slide 56
- Example 1
- Slide 57
- Example 2
- Slide 58
- Slide 59
- Slide 60
- The lines is a minimum dominating set of all zero point.
Transform the solution of maximum matching to minimum dominating
set. How to Draw Lines
- Slide 61
- 0*** ***0 0*** *0**
- Slide 62
- Find a maximum assignment(maximum match). 0*** ***0 0*** *0**
How to Draw Lines
- Slide 63
- Find a maximum assignment(maximum match). Mark all rows having
no assignments. 0***$ ***0 0*** *0** How to Draw Lines
- Slide 64
- Find a maximum assignment(maximum match). Mark all rows having
no assignments. Then mark all columns having zeros in marked
row(s). $ 0***$ ***0 0*** *0** How to Draw Lines
- Slide 65
- Find a maximum assignment(maximum match). Mark all rows having
no assignments. Then mark all columns having zeros in marked
row(s). Then mark all rows having assignments in marked
columns.Repeat this until a closed loop is obtained. $ 0***$ ***0
0***$ *0** How to Draw Lines
- Slide 66
- Find a maximum assignment(maximum match). Mark all rows having
no assignments. Then mark all columns having zeros in marked
row(s). Then mark all rows having assignments in marked
columns.Repeat this until a closed loop is obtained. Then draw
lines through all marked columns and unmarked rows. $ 0***$ ***0
0***$ *0** How to Draw Lines
- Slide 67
- Why Always Stop?
- Slide 68
- Wang Sheng
- Slide 69
- 1955, Harold Kuhn Hungarian method was published and was
largely based on the earlier works of two Hungarian mathematicians
1957, James Munkres Munkres observed it is polynomial in O(n 4 )
and since then the algorithm was also known as Kuhn-Munkres
algorithm 1960, Edmonds and Karp The KM algorithm was modified to
achieve an O(n 3 ) running time Evolvement of Hungarian Method
- Slide 70
- Basic Hungarian method Consider assignment problem in terms of
matrix Idea: add/subtract X from all entries of a row/column Goal:
choose 0s from nonnegative matrix Easy to understand Kuhn-Munkres
algorithm Consider assignment problem in terms of bipartite graph
Easy to analysis and implement Our Goal Introduce KM and show both
of them are equivalent Introduction to KM Algorithm
- Slide 71
- Matrix vs. Bipartite graph For each entry C i,j in matrix,
there is an edge in bipartite graph from X i to Y j with weight
equal to C i,j In order to be consistent with theorems introduced
in the algorithm we consider max-weight matching Y1Y1 Y2Y2 Y3Y3
X1X1 X2X2 X3X3 3 33 222 1 10 Restate Assignment Problem
- Slide 72
- Feasible labeling L A vertex labeling is a function L : V R A
feasible labeling is one such that L(x)+L(y) w(x, y), x X, y Y
Equality Graphs Equality Graph is G = (V,E L ) where E L = {(x, y)
: L(x)+L(y) = w(x, y)} 212 111 3 33 222 1 10 Definitions
- Slide 73
- If L is feasible and M is a perfect matching in E L then M is a
max-weight matching each node is covered exactly once and L(x)+L(y)
w(x, y) therefore the upper-bound of the weight is the sum of
labels Power of the theorem Transform problem from weighted
matching to un-weighted perfect matching 111 Kuhn-Munkres
Theorem
- Slide 74
- Key idea find a good feasible labeling that remains enough
edges in equality graph to ensure perfect matching can be done
Algorithm proposal Start with any feasible labeling L and some
matching M in E L While M is not perfect, repeat: Find an
augmenting path in E L to increase the size of M or if no path
exists, improve L to L such that E L E L Inspiration from KM
Theorem
- Slide 75
- Simplest assignment Maximize L(x) while Minimize L(y) y Y, L(y)
= 0 x X, L(x) = max{w(x,y)}, y Y It is obvious that x X, y Y, w(x,
y) L(x)+L(y) Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 4 68 1 6 Finding an
Initial Feasible Labeling
- Slide 76
- Neighbor of u V and S V N L (u) = { v : (u,v) E L } N L (S) = u
S N L (u) Lemma Let S X and T = N L (S) Y. Set L = min { L(x) +
L(y) w(x,y) }, x S, y T Update the labels (1) if v SL(v) = L(v) - L
(2) if v TL(v) = L(v) + L (3) otherwiseL(v) = L(v) Then L is a
feasible labeling Improving Labeling
- Slide 77
- L = min { L(x) + L(y) w(x,y) }, x S, y T Consider a matrix C
with w(x,y) as its elements For row x X / column y Y, add L(x)/
L(y) to each element Problem is equivalent to solve the min-cost
assignment in C Edge with L(x) + L(y) = w(x,y) is the 0 element in
matrix C (1) if v S, L(v) = L(v) - L (2) if v T, L(v) = L(v) + L S
: set of uncovered rowsT : set of covered columns L : the smallest
entry not covered by any line Subtract this entry from each
uncovered row, and then add it to each covered column Equivalence
of Graph and Matrix
- Slide 78
- Edges in E L (1) if v SL(v) = L(v) - L (2) if v TL(v) = L(v) +
L (3) otherwiseL(v) = L(v) If (x,y) E L for x S, y T then (x,y) E L
If (x,y) E L for x S, y T then (x,y) E L There is some edge (x,y) E
L for x S, y T With good choice of S, we can guarantee there are
more edges in new Equality Graph Effectiveness of Label Update
- Slide 79
- 1. Generate initial labeling L and matching M in E L 2. If M is
perfect, terminate. Otherwise pick free vertex u X. Set S = {u}, T
= {}. 3. If N L (S) = T, update labels(forcing N L (S) T) L = min {
L(x) + L(y) w(x,y) }, x S, y T (1) if v SL(v) = L(v) - L (2) if v
TL(v) = L(v) + L (3) otherwiseL(v) = L(v) 4. If N L (S) T, pick y N
L (S) T. If y is free, augmenting u-y and go to 2. If y is matched
to z, S = S {z}, T = T {y}. Go to 3. Kuhn-Munkres Algorithm
- Slide 80
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 1 68 4 1 6 Original Graph Y1Y1
Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching Example
- Slide 81
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching
Example
- Slide 82
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching
Example
- Slide 83
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching
Example
- Slide 84
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1 }
T = {} Example
- Slide 85
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1 }
T = {} Example
- Slide 86
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1 }
T = {} Example
- Slide 87
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1,X
2 } T = {Y 2 } Example
- Slide 88
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 0Y 3 0 X 1 6X 2 8X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1,X
2 } T = {Y 2 } Example
- Slide 89
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 2Y 3 0 X 1 4X 2 6X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1,X
2 } T = {Y 2 } Example
- Slide 90
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 2Y 3 0 X 1 4X 2 6X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1,X
2 } T = {Y 2 } Example
- Slide 91
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 2Y 3 0 X 1 4X 2 6X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1,X
2 } T = {Y 2 } Example
- Slide 92
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 2Y 3 0 X 1 4X 2 6X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1,X
2 } T = {Y 2 } Example
- Slide 93
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 2Y 3 0 X 1 4X 2 6X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1,X
2 } T = {Y 2 } Example
- Slide 94
- Generate initial labeling and matching Pick a free vertex, set
S={u} T={}; otherwise stop If N L (S) = T, update labels (force N L
(S) T) If N L (S) T, pick y to be N L (S) T If y is free, augment u
y, go to step 2 If y is matched to z, S = S {z}, T = T {y}. go to
step 3 Y 1 0Y 2 2Y 3 0 X 1 4X 2 6X 3 4 1 68 4 1 6 Original Graph
Y1Y1 Y2Y2 Y3Y3 X1X1 X2X2 X3X3 Equality Graph + Matching S = {X 1,X
2 } T = {Y 2 } max-weight is 16 Example
- Slide 95
- In each phase of algorithm, |M| increases by 1, so there are at
most V phases. y T keep track of slack y = min{L(x)+L(y)-w(x,y)} In
each phase Initializing all slacks. O(V) When a vertex moves into
S, all slacks need update. O(V) Only |V| vertices can be moved into
S. O(V 2 ) When updating labels, L = min(slack y ). O(V) After
getting L, must update slack y = slack y - L. O(V) L can be
calculated |V| times per phase. O(V 2 ) Total time per phase is O(V
2 ) Total running time is O(V 3 ) Complexity
- Slide 96
- Slide 97
- References Maximum matching / Hopcroft-Karp Algorithm :
http://en.wikipedia.org/wiki/Matching_(graph_theory)
http://www.cs.dartmouth.edu/~ac/Teach/CS105-
Winter05/Notes/kavathekar-scribe.pdf
http://www.cs.dartmouth.edu/~ac/Teach/CS105-
Winter05/Notes/kavathekar-scribe.pdf
http://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp _algorithm
http://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp _algorithm
http://www2.informatik.huberlin.de/alkox/lehre/lvss12/g
a/notes/HK.pdf
http://www2.informatik.huberlin.de/alkox/lehre/lvss12/g
a/notes/HK.pdf
http://www.dis.uniroma1.it/~leon/tcs/lecture2.pdf
- Slide 98
- References Stable Matching Problem :
http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/1
5251-f10/Site/Materials/Lectures/Lecture21/lecture21.pdf
http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/1
5251-f10/Site/Materials/Lectures/Lecture21/lecture21.pdf Hungarian
Method & Kuhn Munkres Algorithm
http://www.cse.ust.hk/~golin/COMP572/Notes/Matchin g.pdf
http://www.cse.ust.hk/~golin/COMP572/Notes/Matchin g.pdf
http://www.math.harvard.edu/archive/20_spring_05/ha
ndouts/assignment_overheads.pdf
http://www.math.harvard.edu/archive/20_spring_05/ha
ndouts/assignment_overheads.pdf
http://en.wikipedia.org/wiki/Hungarian_algorithm
http://en.wikipedia.org/wiki/Dominating_set