Presentation is loading. Please wait.

Presentation is loading. Please wait.

Maximum Bipartite Matching In a graph G, if no M-augmenting path exists, then M is a maximum matching in G. Idea: Iteratively seek augmenting paths to.

Similar presentations


Presentation on theme: "Maximum Bipartite Matching In a graph G, if no M-augmenting path exists, then M is a maximum matching in G. Idea: Iteratively seek augmenting paths to."— Presentation transcript:

1 Maximum Bipartite Matching In a graph G, if no M-augmenting path exists, then M is a maximum matching in G. Idea: Iteratively seek augmenting paths to enlarge the current matching till no M- augmenting path can be found. Answer: Find a vertex cover with the same size as the current matching. Question: How to show the current matching has maximum size?

2 Algorithm 3.2.1 Input: An X,Y-bigraph G, a matching M in G, and the set U of M-unsaturated vertices in X. Output: Output an M-augmenting path or a vertex cover of size |M|. X Y U We can get maximum matching in X,Y-bigraph by repeatedly apply Algorithm 3.2.1 to X,Y-bigraph.

3 Algorithm 3.2.1 Exploring M-alternating paths from U, letting S  X and T  Y be the sets of vertices reached. If no M-alternating paths are explored, report T  (X-S) as a minimum cover and M as a maximum matching. X Y U T SX-S

4 Algorithm 3.2.1 X Y S

5 3. Explore alternating path from an unmark x  S and mark x. 3.2. For each xy  E(G), include y in T and include w in S, where yw  M. X Y U T S x y ww yy w xxxxx

6 Algorithm 3.2.1 3.1 If there exists unsaturated y  N(x) such that xy  M, then stop and report an M-augmenting path from U to y. X Y S T

7 Algorithm 3.2.1 2. If S has no unmarked vertex, stop and report T  (X- S) as a minimum cover and M as a maximum matching. X-S X Y U T S x y ww yy w xxxxx

8 Algorithm 3.2.1 1. S=U and T= . 2. If S has no unmarked vertex, stop and report T  (X-S) as a minimum cover and M as a maximum matching. 3. Explore alternating path from an unmark x  S. 3.1. If there exists unsaturated y  N(x) such that xy  M, then stop and report an M-augmenting path from U to y. 3.2. For each xy  E(G), include y in T and include w in S, where yw  M. Mark x and Goto Step 2.

9 Theorem 3.2.2 Repeatedly applying Algorithm 3.2.1 to a bipartite graph produces a matching and a vertex cover of equal size 1. Let Q=T  (X-S) and M be the matching when algorithm 3.2.1 stops at step 2. 2. Q is a vertex cover. T X Y SX-S Y-T  No edge joins S to Y-T.

10 Theorem 3.2.2 3. Each y  T is M-saturated. T X Y SX-S Y-T  Q is a minimum vertex cover and M is a maximum matching. 3.4.5.  M has at least |T|+|X-S| edges. 5. No edge in M joins T to X-S. 4. Each vertex of X-S is M-saturated.

11 Maximum Weighted Bipartite Matching A farming company owns n farms and n processing plants. The profit that results from sending the output of farm i to plant j is w i,j. The company wants to select edges forming a matching to maximize total profit. Edge weight W i,j u1u1 u2u2 u3u3 v1v1 v2v2 v3v3 u1u1 u2u2 u3u3 v3v3 v2v2 v1v1 w(M)=6+5+8=19

12 Minimum Weighted Cover The government will pay u i if the company agrees not to use farm i and v j if it agrees not to use plant j. The government must offer amounts such that u i +v j >=w i,j for all i, j. Otherwise, the company makes more by using edge x i y j than taking the government payments for those vertices. The government wants to minimize  u i +  v j. Edge weight W i,j u1u1 u2u2 u3u3 v1v1 v2v2 v3v3 u1u1 u2u2 u3u3 v3v3 v2v2 v1v1 457 021 c(v) c(u) c(u,v)=19

13 Lemma 3.2.7: Duality of minimum c(u,v) and maximum w(M) For a perfect matching M and weighted cover (u,v) in a weighted bipartite graph G, (1) c(u,v)>=w(M), and (2) c(u,v) =w(M) iff M consists of edges x i y j such that u i +v j =w i,j. In (2), M and (u,v) are optimal. (1) c(u,v)>=w(M) since u i +v j >=w i,j for all i, j. (2) Trivial. u1u1 u2u2 u3u3 v3v3 v2v2 v1v1 w(M)=6+5+8=19 u1u1 u2u2 u3u3 v3v3 v2v2 v1v1 457 021 c(v) c(u) c(u,v)=19

14 Equality Subgraph Equality Subgraph: The equality subgraph G u,v for a weighted cover (u,v) is the spanning subgraph of K n,n whose edges are the pairs x i y j such that u i +v j =w i,j. In the cover, the excess for i,j is u i +v j -w i,j. Edge weight W i,j u1u1 u2u2 u3u3 v1v1 v2v2 v3v3 u1u1 u2u2 u3u3 v3v3 v2v2 v1v1 457 021 c(v) c(u) Kn,n

15 Algorithm 3.2.9 Input: A matrix of weights on the edges of K n,n with bipartition X,Y. Output: A maximum weighted matching. Idea: Iteratively adjust the cover (u,v) until the equality subgraph G u,v has a perfect matching.

16 Algorithm 3.2.9 Initialization: Let (u,v) be a cover, such that u i =max j w i,j and v j =0. 4 1 6 2 3 5 0 3 7 6 2 3 4 5 8 3 4 6 3 4 4 6 5 8 6 → u 1 = max {4, 1, 6, 2, 3} = 6, v 1 = 0 u 2 = max {5, 0, 3, 7, 6} = 7, v 2 = 0 u 3 = max {2, 3, 4, 5, 8} = 8, v 3 = 0 u 4 = max {3, 4, 6, 3, 4} = 6, v 4 = 0 u 5 = max {4, 6, 5, 8, 6} = 8, v 5 = 0 A matrix of weight 6786867868 0 0 0 0 0

17 Algorithm 3.2.9 0 0 0 0 0 6786867868 4 1 6 2 3 5 0 3 7 6 2 3 4 5 8 3 4 6 3 4 4 6 5 8 6 T R 2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0 3 2 4 2 3 0 2 excess matrix X Y T R 6+0-4 6+0-1 6+0-6 6+0-2 6+0-3 7+0-5 7+0-0 7+0-3 7+0-7 7+0-6 8+0-2 8+0-3 8+0-4 8+0-5 8+0-8 6+0-3 6+0-4 6+0-6 6+0-3 6+0-4 8+0-4 8+0-6 8+0-5 8+0-8 8+0-6

18 Algorithm 3.2.9 How to adjust the cover (u,v) such that the equality subgraph G u,v has a perfect matching? –Add any edge incident to a vertex in Q=R  T into G u,v does not work. –Decrease the excess for each edge not incident to a vertex in Q=R  T. –No edge has a negative excess after adjusting the cover (u,v).

19 Algorithm 3.2.9 ε T R 2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0 3 2 4 2 3 0 2 min X Y T R TTT 0 0 0 0 0 6-1 7-1 8 6-1 8-1 1 4 0 4 2 1 6 4 0 0 6 5 5 4 0 2 1 0 3 1 5 1 3 0 1 ε min 6786867868 0 0 0 0 0 0 0 1+1 1+1 0+1 5-1 6-1 8-1 5-1 7-1 0 3 0 4 2 0 5 4 0 0 5 4 5 4 0 1 0 0 3 1 2 0 3 0 1 T T T +1 +1

20 Algorithm 3.2.9 1. Find a maximum matching M in G u,v. If M is perfect matching, stop and report M as a maximum weighted matching. 2. Let Q be a vertex cover of size |M| in G u,v. Let R=X  Q and T=Y  Q. Letε=min{u i +v j - w i,j : x i  X-R, y j  Y-T}. 3. Decreases u i byεfor x i  X-R, and increases v j byεfor y j  Y. 4. Form the new equality graph and Goto Step 1.

21 Theorem 3.2.11 Algorithm 3.2.9 finds a maximum weight matching and a minimum cost cover 1.Let (u,v) be the current cover and suppose that the equality subgraph has no perfect matching. Let (u’,v’) be the new lists of numbers assigned to the vertices. 2.Show (u’,v’) is a cover by discuss 3 cases: 1) edge from X-R to T or from R to Y-T, 2) edges from R to T, and 3) edge from X-R to Y-T.

22 Theorem 3.2.11 Case 1: u i ’+v j ’= u i +v j for edges x i y j from X-R to T or from R to Y-T.  (u’,v’) is a cover T R 2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0 3 2 4 2 3 0 2 0 0 0 0 0 6786867868 0 0 0+1 0+1 0 6-1 7-1 8 6-1 8-1 1 4 0 4 2 1 6 4 0 0 6 5 5 4 0 2 1 0 3 1 5 1 3 0 1 R T

23 Theorem 3.2.11 Case 2: u i ’+v j ’= u i +v j +ε for edges x i y j from R to T.  (u’,v’) is a cover T R 2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0 3 2 4 2 3 0 2 0 0 0 0 0 6786867868 0 0 0+1 0+1 0 6-1 7-1 8 6-1 8-1 1 4 0 4 2 1 6 4 0 0 6 5 5 4 0 2 1 0 3 1 5 1 3 0 1 R T

24 Theorem 3.2.11 Case 3: u i ’+v j ’= u i +v j -ε for edges x i y j from X-R to Y-T.  (u’,v’) is a cover since ε=min{u i +v j - w i,j : x i  X-R, y j  Y-T}. T R 2 5 0 4 3 2 7 4 0 1 6 5 4 3 0 3 2 0 3 2 4 2 3 0 2 0 0 0 0 0 6786867868 0 0 0+1 0+1 0 6-1 7-1 8 6-1 8-1 1 4 0 4 2 1 6 4 0 0 6 5 5 4 0 2 1 0 3 1 5 1 3 0 1 R T

25 Theorem 3.2.11 2. It terminates only when the equality subgraph has a perfect matching.  equal value for the current matching and cover. 3. We need to show Algorithm 3.2.9 always terminate. It suffices to show at each iteration the cost of the cover is reduced at least ε because the cost starts at some value and is bounded below by the weight of a perfect matching.

26 Theorem 3.2.11 M is not a perfect matching.  |Q|=|M|<|X|.  |R|+|T|<|X-R|+|R|. X-R R T -ε +ε X Y  |T|<|X-R|.


Download ppt "Maximum Bipartite Matching In a graph G, if no M-augmenting path exists, then M is a maximum matching in G. Idea: Iteratively seek augmenting paths to."

Similar presentations


Ads by Google