Presentation is loading. Please wait.

Presentation is loading. Please wait.

3.2.1. Augmenting path algorithm Two theorems to recall: Theorem 3.1.10 (Berge). A matching M in a graph G is a maximum matching in G iff G has no M-augmenting.

Similar presentations


Presentation on theme: "3.2.1. Augmenting path algorithm Two theorems to recall: Theorem 3.1.10 (Berge). A matching M in a graph G is a maximum matching in G iff G has no M-augmenting."— Presentation transcript:

1 Augmenting path algorithm Two theorems to recall: Theorem (Berge). A matching M in a graph G is a maximum matching in G iff G has no M-augmenting path. Theorem (König,Egerváry) If G is bipartite, then a maximum matching and a minimum vertex cover of G have the same size (  ’(G)=  (G)). Augmenting path algorithm for maximum bipartite matching Input: X,Y-bigraph.Output: M,Q with |M|=|Q| Use modified breadth-first search to find augmenting paths. Initialize with empty matching and iteratively increase by 1. Produce a vertex cover of same size to certify the output. 1

2 Augmenting path algorithm Algorithm (Augmenting path algorithm) Input An X,Y-bigraph G, a (partial matching) M, and the set U of M-unsaturated vertices of X Idea Explore augmenting paths to all possible vertices, marking explored vertices and their predecessors, and tracking reached vertices SµX and TµY Initialization S=U and T=; Iteration If S is all marked, stop and output M and Q=T[(X-S). Otherwise, explore from an unmarked x2S. For any edge xy2E(G)-M: (1) mark y and put y in T. (2) For any edge yw2M, mark w and put w in S. Stop if an unsaturated y is found; report an M-augmenting path. Otherwise continue exploring in this fashion. 2

3 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 Iteration 1 Input: M=; S=U=X, T=;, x=x 1 3 S S S SS

4 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 Iteration 1: y 1 unsaturated. Halt and augment M. 4 T S S S SS

5 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 5 Iteration 2 Input: M={x 1 y 1 } S={x 2, x 3, x 4, x 5 }, T=;, x=x 2 S SSS

6 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 6 Iteration 2: From x 2, explore y 1 and its matched neighbors T S S S SS

7 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 7 Iteration 2: From x 1, explore y 2 and its matched neighbors. y 2 is unsaturated: halt and augment M. T S S S SS T

8 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 8 Iteration 3 Input: M={x 1 y 2, x 2 y 1 } S={x 3, x 4, x 5 }, T=;, x=x 3 S SS

9 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 9 Iteration 3: From x 3, explore y 3 and its matched neighbors. y 3 unsaturated, so terminate and report augmenting path. S S S T

10 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 10 Iteration 4 Input: M={x 1 y 2, x 2 y 1, x 3 y 3 } S={x 4, x 5 }, T=;, x=x 4 SS

11 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 11 Iteration 4: From x 4, explore y 2,y 3 and their (distinct) matched neighbors. S S S T T S

12 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 12 Iteration 4: From x 1, and x 3, explore to find y 1 via non- matching edges. Explore back up to x 2 via a matching edge. S S S T T S T S

13 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 13 Iteration 4 (continued): x 5 is still unexplored. Explore from x 5 to find unsaturated vertex y 4. Terminate and report an M-augmenting path. S S S S T TT S T

14 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 14 Iteration 5 Input: M={x 1 y 2,x 2 y 1,x 3 y 3,x 5 y 4 } S={x 4 }, T=;, x=x 4 S

15 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 15 Iteration 5: From x 4, explore y 2,y 3 and their (distinct) matched neighbors. S S S T T

16 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 16 Iteration 5: From x 1, and x 3, explore to find y 1 via non- matching edges. Explore back up to x 2 via a matching edge. S S S S T TT

17 Augmenting path algorithm example x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 17 Termination: No vertex of S is unexplored. Output: maximum matching M={x 1 y 2,x 2 y 1,x 3 y 3,x 5 y 4 } Minimum vertex cover Q=T[(X-S) ={x 5,y 1,y 2,y 3 }. S S S S T TT Q Q QQ

18 Maximum Weighted Transversal Transversal: A set M of n entries of an n£n, matrix, no two in the same column or row. Its weight is the sum of the entries. Cover: A pair of vectors (u,v)=(u 1,…,u n ;v 1,…,v n ) such that every entry w i,j of the matrix satisfies w i,j · u i +v j. u v w(M)=23 w(u,v)=32

19 Maximum Transversal = Minimum Cover Lemma. (Duality of weighted matching and weighted cover problems) For a perfect matching M and a weighted cover (u,v) in a weighted bipartite graph G, c(u,v)¸w(M). Also, c(u,v)=w(M) iff M consists of edges x i y j such that u i +v j =w i,j. In this case, M and (u,v) are optimal u v w(M)=12 w(u,v)=12

20 Hungarian Algorithm (Maximum Weighted Matching/Minimum Weighted Cover) Algorithm (Hungarian Algorithm) Input An n£n matrix of nonnegative edge weights of K n,n Idea Iteratively adjust the cover (u,v) until the equality subgraph G u,v has a perfect matching Initialization Any cover (u,v), such as u i =max i w i,j and v j =0 Iteration Find a maximum matching M in G u,v. If M is a perfect matching, stop and output M and (u,v) as a maximum weight matching and minimum weight cover. Otherwise: Let  = smallest excess in G u,v of an edge from X-R to Y-T. Replace u i à u i -  for all x i 2 X-R. Replace v j à v j +  for all y j 2 Y-T. Form the new equality subgraph G u,v and repeat. 20

21 Hungarian Algorithm Example u v w(M)=21w(u,v)= u v excess matrix TT R x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 TT R Equality subgraph vertex cover: Q=R[T  Add  =1 to T, subtract from X-R.

22 Hungarian Algorithm Example u v w(M)=21w(u,v)= u v excess matrix TT x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 TT T Equality subgraph vertex cover: Q=R[T T  Add  =1 to T, subtract from X-R.

23 Hungarian Algorithm Example u v w(M)=31w(u,v)= u v excess matrix TT x1x1 x2x2 x3x3 x4x4 x5x5 y1y1 y2y2 y3y3 y4y4 y5y5 T Matching weight=cover weight. Halt and output M, and (u,v). equality subgraph


Download ppt "3.2.1. Augmenting path algorithm Two theorems to recall: Theorem 3.1.10 (Berge). A matching M in a graph G is a maximum matching in G iff G has no M-augmenting."

Similar presentations


Ads by Google