CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25
Certificate of Optimality Corollary: Let f be any flow, and let (A, B) be any cut. If v(f) = cap(A, B), then f is a max flow and (A, B) is a min cut Value of flow = 28 Cut capacity = 28 Flow value s t A
Max-Flow Min-Cut Theorem The Ford-Fulkerson algorithm terminates when the flow has not s-t path in the residual graph There exists a flow which has the same value of the minimum cut –Proof: Consider a flow where the residual graph has no s-t path with positive capacity –Let A be the set of vertices in the residual graph reachable from s with paths of positive capacity –What can we say about the flows and capacity between u and v? stuv A B PROOF DONE IN CLASS
Max-Flow Min-Cut Theorem Ford-Fulkerson algorithm finds a flow where the residual graph is disconnected, hence FF finds a maximum flow If we want to find a minimum cut, we begin by looking for a maximum flow
Problem Reduction Reduce Problem A to Problem B –Convert an instance of A to an instance of B –Use a solution of B to get a solution to A Practical –Use a program for B to solve A Theoretical –Show that B is at least as hard as A E.g., reduce the problem of finding the Maximum of a set of integers to finding the Minimum of a set of integers Network flow can be applied to many problems that on the surface do not resemble network flow
Bipartite Matching Input: Bipartite graph –A graph G = (V, E) is bipartite if V can be partitioned into sets L and R such that every edge in E has one end in L and the other end in R Goal: Find maximum cardinality matching –A matching is M E with property that each node in V appears in at most one edge of M C A E 3 B D4 professors courses can teach From Lecture #3: Five Representative Problems n k max-flow based algorithm
Bipartite Matching Bipartite matching –Input: undirected, bipartite graph G = (L R, E) –M E is a matching if each node appears in at most edge in M –Max matching: find a max cardinality matching ' 3' 5' 2 4 2' 4' matching 1-2', 3-1', 4-5' RL
Bipartite Matching Bipartite matching –Input: undirected, bipartite graph G = (L R, E) –M E is a matching if each node appears in at most edge in M –Max matching: find a max cardinality matching ' 3' 5' 2 4 2' 4' RL max matching 1-1', 2-2', 3-3' 4-4'
Converting Matching to Network Flow ts
Bipartite Matching Max flow formulation –Create digraph G' = (L R {s, t}, E' ) –Direct all edges from L to R, and assign unit capacity –Add source s, and unit capacity edges from s to each node in L –Add sink t, and unit capacity edges from each node in R to t s ' 3' 5' t 2 4 2' 4' RL G'
Bipartite Matching: Proof of Correctness Theorem: Max cardinality matching in G = value of max flow in G‘. Pf. –Given max matching M of cardinality k –Consider flow f that sends 1 unit along each of k paths –f is a flow, and has cardinality k s ' 3' 5' t 2 4 2' 4' ' 3' 5' 2 4 2' 4' G' G
Bipartite Matching: Proof of Correctness Theorem: Max cardinality matching in G = value of max flow in G'. Pf. –Let f be a max flow in G' of value k –Consider M = set of edges from L to R with f(e) = 1 Each node in L and R participates in at most one edge in M |M| = k: consider cut (L s, R t) ' 3' 5' 2 4 2' 4' G s ' 3' 5' t 2 4 2' 4' G'