lecture 17 max flow bipartite matching

Lecture 17: Max Flow Bipartite Matching Tim LaRock - PowerPoint PPT Presentation

Lecture 17: Max Flow Bipartite Matching Tim LaRock larock.t@northeastern.edu bit.ly/cs3000syllabus Business Homework 5 due Tuesday night 11:59 Boston time No class Monday, per President Aouns office Class Tuesday and Wednesday next


  1. Lecture 17: Max Flow Γ  Bipartite Matching Tim LaRock larock.t@northeastern.edu bit.ly/cs3000syllabus

  2. Business Homework 5 due Tuesday night 11:59 Boston time No class Monday, per President Aoun’s office Class Tuesday and Wednesday next week, no class Thursday Wednesday will include midterm review similar to last time

  3. Last Time: Mechanics of Reductions Input x for Input u for Problem B Problem A SolveA Output y in B(x) Output v in A(u) for Problem B for Problem A In the simplest case, we just call SolveA a single time. In fact we may use SolveA as a subroutine to a more complex reduction.

  4. A = MaxFlow Last Time: Minimum Cut B = MinCut Input x for Input u for Problem B Problem A SolveA Output y in B(x) Output v in A(u) for Problem B for Problem A Input 𝑦 for B: 𝐻 = (π‘Š, 𝐹, 𝑑, 𝑒, 𝑑 + ) Output 𝑧 ∈ 𝐢(𝑦) : 𝐻 = (π‘Š, 𝐹, 𝑑, 𝑒, 𝑑 + ) Input 𝑣 for A: 𝐻 = (π‘Š, 𝐹, 𝑑, 𝑒, 𝑑 + ) 1. Take 𝑔 , compute the residual graph 𝐻 4 2. Find the nodes reachable from 𝑑 in 𝐻 4 3. Output these nodes Output 𝑀 ∈ 𝐡(𝑣) : 𝐻 = (π‘Š, 𝐹, 𝑑, 𝑒, 𝑑 + )

  5. Bipartite Matching from Maximum Flow

  6. Bipartite Matching β€’ Input: bipartite graph 𝐻 = (π‘Š, 𝐹) with π‘Š = 𝑀 βˆͺ 𝑆 𝑀 𝑆 Models any problem where one type of object is assigned to another type: β€’ doctors to hospitals β€’ jobs to processors β€’ advertisements to websites

  7. Bipartite Matching β€’ Input: bipartite graph 𝐻 = (π‘Š, 𝐹) with π‘Š = 𝑀 βˆͺ 𝑆 β€’ Output: a maximum cardinality matching β€’ A matching 𝑁 βŠ† 𝐹 is a set of edges such that every node 𝑀 is an endpoint of at most one edge in 𝑁 𝑀 𝑆 Models any problem where one type of object is assigned to another type: β€’ doctors to hospitals β€’ jobs to processors β€’ advertisements to websites

  8. Bipartite Matching β€’ Input: bipartite graph 𝐻 = (π‘Š, 𝐹) with π‘Š = 𝑀 βˆͺ 𝑆 β€’ Output: a maximum cardinality matching β€’ A matching 𝑁 βŠ† 𝐹 is a set of edges such that every node 𝑀 is an endpoint of at most one edge in 𝑁 β€’ Cardinality = 𝑁 𝑀 𝑆 Models any problem where one type of object is assigned to another type: β€’ doctors to hospitals β€’ jobs to processors β€’ advertisements to websites

  9. Bipartite Matching Input x for Input u for Problem B Problem A SolveA Output y in B(x) Output v in A(u) for Problem B for Problem A β€’ There is a reduction that uses integer maximum s-t flow to solve maximum bipartite matching. β€’ Problem B: maximum bipartite matching (MBM) β€’ Problem A: integer maximum s-t flow

  10. Bipartite Matching 1 2 Input x for Input u for Problem B Problem A SolveA Output y in B(x) Output v in A(u) for Problem B for Problem A 3 β€’ There is a reduction that uses integer maximum s-t flow to solve maximum bipartite matching. β€’ Problem B: maximum bipartite matching (MBM) β€’ Problem A: integer maximum s-t flow

  11. Step 1: Transform the Input Input G for Input G’ for MCBM MAXFLOW 𝑀 𝑆

  12. Step 1: Transform the Input Input G for Input G’ for MCBM MAXFLOW 𝑀 𝑀 𝑆 𝑆 Set all edge capacities to 𝑑 𝑓 = 1

  13. Step 2: Receive the Output Input G’ for MAXFLOW SolveA Output f for MAXFLOW Red arrow means f(e)=1 Black means f(e) = 0

  14. Step 2: Receive the Output Input G’ for The matching will be all MAXFLOW of the edges from 𝑀 to SolveA 𝑆 with nonzero flow! Output f for MAXFLOW Red arrow means f(e)=1 Black means f(e) = 0

  15. Step 3: Transform the Output Output M for Output f for MCBM MAXFLOW

  16. Reduction Recap β€’ Step 1: Transform the Input β€’ Given G = (L,R,E), produce G’ = (V,E,{c(e)},s,t) by... β€’ ... orienting edges e from L to R β€’ ... adding a node s with edges from s to every node in L β€’ ... adding a node t with edges from every not in R to t β€’ ... seting all capacities to 1 β€’ Step 2: Receive the Output β€’ Find an integer maximum s-t flow f in G’ β€’ Step 3: Transform the Output β€’ Given an integer s-t flow f(e)… β€’ Let M be the set of edges e going from L to R that have f(e)=1

  17. Correctness β€’ Need to show: β€’ (1) This algorithm returns a matching β€’ (2) This matching is a maximum cardinality matching

  18. Correctness β€’ This algorithm returns a matching Since the capacity on every edge is 1, by conservation of flow we have: β€’ For any node in 𝑀 , exactly one outgoing edge can have flow β€’ For any node in 𝑆 , exactly one incoming edge can have flow

  19. Correctness β€’ Claim: G has a matching of cardinality at least k if and only if G’ has an s-t flow of value at least k

  20. Correctness β€’ Claim: G has a matching of cardinality at least k if and only if G’ has an s-t flow of value at least k A matching of size 𝑙 immediately implies a valid flow of value 𝑙

  21. Correctness β€’ Claim: G has a matching of cardinality at least k if and only if G’ has an s-t flow of value at least k A flow of value 𝑙 must have 𝑙 edges carrying flow from 𝑀 to 𝑆

  22. Correctness β€’ Claim: G has a matching of cardinality at least k if and only if G’ has an s-t flow of value at least k A matching of size 𝑙 immediately A flow of value 𝑙 must have 𝑙 edges implies a valid flow of value 𝑙 carrying flow from 𝑀 to 𝑆 When 𝑙 is the maximum cardinality matching, there must be a flow, and vice versa!

  23. Running Time β€’ Need to analyze the time for: β€’ (1) Producing G’ given G β€’ G’ has π‘œ + 2 nodes and π‘œ + 𝑛 edges, so we can construct it in 𝑃(π‘œ + 𝑛) time β€’ (2) Finding a maximum flow in G’ β€’ MaxFlow with all capacities 1 can be solved in 𝑃(π‘œπ‘›) β€’ (3) Producing M given G’ β€’ We can scan the edges of G’ to find the max flow in 𝑃(π‘œ + 𝑛) time β€’ Adding the three together, we have 𝑃 2 β‹… (π‘œ + 𝑛 + π‘œπ‘›) = 𝑃(π‘œπ‘›)

  24. Running Time β€’ Need to analyze the time for: β€’ (1) Producing G’ given G β€’ G’ has π‘œ + 2 nodes and π‘œ + 𝑛 edges, so we can construct it in 𝑃(π‘œ + 𝑛) time β€’ (2) Finding a maximum flow in G’ β€’ MaxFlow with all capacities 1 can be solved in 𝑃(π‘œπ‘›) β€’ (3) Producing M given G’ β€’ We can scan the edges of G’ to find the max flow in 𝑃(π‘œ + 𝑛) time β€’ Adding the three together, we have 𝑃 2 β‹… (π‘œ + 𝑛 + π‘œπ‘›) = 𝑃(π‘œπ‘›)

  25. Running Time β€’ Need to analyze the time for: β€’ (1) Producing G’ given G β€’ G’ has π‘œ + 2 nodes and π‘œ + 𝑛 edges, so we can construct it in 𝑃(π‘œ + 𝑛) time β€’ (2) Finding a maximum flow in G’ β€’ MaxFlow with all capacities 1 can be solved in 𝑃(π‘œπ‘›) β€’ (3) Producing M given G’ β€’ We can scan the edges of G’ to find the max flow in 𝑃(π‘œ + 𝑛) time β€’ Adding the three together, we have 𝑃 2 β‹… (π‘œ + 𝑛 + π‘œπ‘›) = 𝑃(π‘œπ‘›)

  26. Running Time β€’ Need to analyze the time for: β€’ (1) Producing G’ given G β€’ G’ has π‘œ + 2 nodes and π‘œ + 𝑛 edges, so we can construct it in 𝑃(π‘œ + 𝑛) time β€’ (2) Finding a maximum flow in G’ β€’ MaxFlow with all capacities 1 can be solved in 𝑃(π‘œπ‘›) β€’ (3) Producing M given G’ β€’ We can scan the edges of G’ to find the max flow in 𝑃(π‘œ + 𝑛) time β€’ Adding the three together, we have 𝑃 2 β‹… (π‘œ + 𝑛 + π‘œπ‘›) = 𝑃(π‘œπ‘›)

  27. Running Time β€’ Need to analyze the time for: β€’ (1) Producing G’ given G β€’ G’ has π‘œ + 2 nodes and π‘œ + 𝑛 edges, so we can construct it in 𝑃(π‘œ + 𝑛) time β€’ (2) Finding a maximum flow in G’ β€’ MaxFlow with all capacities 1 can be solved in 𝑃(π‘œπ‘›) β€’ (3) Producing M given G’ β€’ We can scan the edges of G’ to find the max flow in 𝑃(π‘œ + 𝑛) time β€’ Adding the three together, we have 𝑃 2 β‹… (π‘œ + 𝑛 + π‘œπ‘›)

  28. Summary Solving maximum integer s-t flow in a graph with n+2 nodes and m+n edges and c(e) = 1 in time T Solving maximum bipartite matching in a graph with n nodes and m edges in time T + O(m+n) β€’ Can solve max bipartite matching in time O(nm) using Ford-Fulkerson β€’ Improvement for maximum flow gives improvement for maximum bipartite matching

  29. Wrap-up No class Monday, per President Aoun’s office Homework 5 due Tuesday night 11:59 Boston time Class Tuesday and Wednesday next week, no class Thursday Wednesday will include midterm review of some kind Stay safe and enjoy your weekend

Recommend


More recommend