Professional Documents
Culture Documents
08 Network Flow Problems PDF
08 Network Flow Problems PDF
Jaehyun Park
CS 97SI
Stanford University
Ford-Fulkerson Algorithm
Bipartite Matching
Capacities
Capacities
s a b t: 11
s c a b t: 1
s c d b t: 7
s c d t: 4
Ford-Fulkerson Algorithm
Bipartite Matching
Ford-Fulkerson Algorithm 9
Ford-Fulkerson Algorithm
Ford-Fulkerson Algorithm 10
Back Edges
Ford-Fulkerson Algorithm 11
Ford-Fulkerson Pseudocode
Set ftotal = 0
Repeat until there is no path from s to t:
Run DFS from s to find a flow path to t
Let f be the minimum capacity value on the path
Add f to ftotal
For each edge u v on the path:
Decrease c(u v) by f
Increase c(v u) by f
Ford-Fulkerson Algorithm 12
Analysis
Ford-Fulkerson Algorithm 13
Computing Min-Cut
Ford-Fulkerson Algorithm 14
Computing Min-Cut
Ford-Fulkerson Algorithm 15
Computing Min-Cut
Ford-Fulkerson Algorithm 16
Computing Min-Cut
Ford-Fulkerson Algorithm 17
Outline
Ford-Fulkerson Algorithm
Bipartite Matching
Bipartite Matching 18
Bipartite Matching
Settings:
n students and d dorms
Each student wants to live in one of the dorms of his choice
Each dorm can accommodate at most one student (?!)
Fine, we will fix this later...
Bipartite Matching 19
Flow Network Construction
Bipartite Matching 20
Flow Network Construction
Bipartite Matching 21
Related Problems
Bipartite Matching 22
Outline
Ford-Fulkerson Algorithm
Bipartite Matching