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.

Slides:



Advertisements
Similar presentations
The Primal-Dual Method: Steiner Forest TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A A AA A A A AA A A.
Advertisements

Min-Max Relations, Hall’s Theorem, and Matching-Algorithms Graphs & Algorithms Lecture 5 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Bipartite Matching, Extremal Problems, Matrix Tree Theorem.
Transportation Problem (TP) and Assignment Problem (AP)
1 Discrete Structures & Algorithms Graphs and Trees: III EECE 320.
Graph Matching prepared and Instructed by Shmuel Wimer Eng. Faculty, Bar-Ilan University March 2014Graph Matching1.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 8 Network models.
Algorithms and Networks
Breadth-First Search of Graphs Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
(Algorithms in Bipartite Graphs). Introduction Algorithms in unweighted bipartite graph (Yehong & Gordon) Maximum matching A simple algorithm Hopcroft-Karp.
1 Maximum Flow w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
1 Weighted Bipartite Matching Lecture 4: Jan Weighted Bipartite Matching Given a weighted bipartite graph, find a matching with maximum total weight.
Linear programming Thomas S. Ferguson University of California at Los Angeles Compressive Sensing Tutorial PART 3 Svetlana Avramov-Zamurovic January 29,
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
CS 311 Graph Algorithms. Definitions A Graph G = (V, E) where V is a set of vertices and E is a set of edges, An edge is a pair (u,v) where u,v  V. If.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Matchings Matching: A matching in a graph G is a set of non-loop edges with no shared endpoints.
Maximum Bipartite Matching
Matchings Matching: A matching in a graph G is a set of non-loop edges with no shared endpoints Maximal Matching: A maximal matching in a graph is a matching.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
1 Bipartite Matching Lecture 3: Jan Bipartite Matching A graph is bipartite if its vertex set can be partitioned into two subsets A and B so that.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
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.
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck.
CSE, IIT KGP Matchings and Factors. CSE, IIT KGP Matchings A matching of size k in a graph G is a set of k pairwise disjoint edges.A matching of size.
Hungarian Algorithm Vida Movahedi Elderlab, York University June 2007.
Theory of Computing Lecture 13 MAS 714 Hartmut Klauck.
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
Graph Theory Ch. 3. Matchings and Factors 1 Chapter 3 Matchings and Factors Matchings and Covers Algorithms and Applications Matchings in General Graph.
3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and.
Matching Algorithms and Networks. Algorithms and Networks: Matching2 This lecture Matching: problem statement and applications Bipartite matching Matching.
Chapter 1 Fundamental Concepts Introduction to Graph Theory Douglas B. West July 11, 2002.
Maximum Flow. p2. Maximum Flow A flow network G=(V, E) is a DIRECTED graph where each has a nonnegative capacity u.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
Bipartite Matching. Unweighted Bipartite Matching.
EMIS 8373: Integer Programming Combinatorial Relaxations and Duals Updated 8 February 2005.
Matching Algorithms and Networks. Algorithms and Networks: Matching2 This lecture Matching: problem statement and applications Bipartite matching Matching.
COSC 2007 Data Structures II
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Exercise 6.1 Find the number of different shortest paths from point A to point B in a city with perfectly horizontal streets and vertical avenues as shown.
1 Assignment #3 is posted: Due Thursday Nov. 15 at the beginning of class. Make sure you are also working on your projects. Come see me if you are unsure.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
Matching and Factors Matchings and Covers. Definitions: A matching M in a graph G is a set of non loop edges with no shared endpoints. G M.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
A directed graph G consists of a set V of vertices and a set E of arcs where each arc in E is associated with an ordered pair of vertices from V. V={0,
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Indian Institute of Technology Kharagpur PALLAB DASGUPTA Graph Theory: Matchings and Factors Pallab Dasgupta, Professor, Dept. of Computer Sc. and Engineering,
GRAPH THEORY Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
TIRGUL 10 Dijkstra’s algorithm Bellman-Ford Algorithm 1.
Graph Theory Ch. 3. Matchings and Factors 1 Chapter 3 Matchings and Factors.
Lap Chi Lau we will only use slides 4 to 19
Topics in Algorithms Lap Chi Lau.
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
Chapter 5. Optimal Matchings
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Analysis of Algorithms
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Problem Solving 4.
Systems of distinct representations
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Presentation transcript:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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.

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