Download - Maximum Flow Neil Tang 3/30/2010
![Page 1: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/1.jpg)
CS223 Advanced Data Structures and Algorithms 1
Maximum Flow Maximum Flow
Neil TangNeil Tang3/30/20103/30/2010
![Page 2: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/2.jpg)
CS223 Advanced Data Structures and Algorithms 2
Class OverviewClass Overview
The maximum flow problem Applications A greedy algorithm which does not work The Ford-Fulkerson algorithm Implementation and time complexity Another approach: linear programming An Application: maximum matching in a bipartite graph
![Page 3: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/3.jpg)
CS223 Advanced Data Structures and Algorithms 3
The Maximum Flow ProblemThe Maximum Flow Problem
The weight of a link (a.k.a link capacity) indicates the maximum amount of flow allowed to pass through this link.
The maximum flow problem: Given a weighted directed graph G, a source node s and a sink node t, find the maximum amount of flow that can pass from s to t and a corresponding feasible link flow allocation.
Flow feasibility: Both the flow conservation constraint and the capacity constraint must be satisfied.
![Page 4: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/4.jpg)
CS223 Advanced Data Structures and Algorithms 4
The Maximum Flow ProblemThe Maximum Flow Problem
![Page 5: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/5.jpg)
CS223 Advanced Data Structures and Algorithms 5
ApplicationsApplications
Computer networks: Data traffic routing for throughput maximization.
Transportation networks: Road construction and traffic management.
Graph theory: Matching, assignment problems.
![Page 6: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/6.jpg)
CS223 Advanced Data Structures and Algorithms 6
Flow Graph and Residual GraphFlow Graph and Residual Graph
![Page 7: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/7.jpg)
CS223 Advanced Data Structures and Algorithms 7
Basic IdeaBasic Idea
Keep finding s-t augmenting paths until no such paths can be found in the residual graph.
Update the flow and residual graph according to the augmenting path in each step.
![Page 8: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/8.jpg)
CS223 Advanced Data Structures and Algorithms 8
A Greedy Algorithm which Does Not WorkA Greedy Algorithm which Does Not WorkFind an augmenting path s-a-d-t with flow value 3 and update the flow and residual graphs as follows:
![Page 9: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/9.jpg)
CS223 Advanced Data Structures and Algorithms 9
The Ford-Fulkerson AlgorithmThe Ford-Fulkerson AlgorithmFind an augmenting path s-a-d-t with flow value 3 and update the flow and residual graphs as follows:
![Page 10: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/10.jpg)
CS223 Advanced Data Structures and Algorithms 10
The Ford-Fulkerson AlgorithmThe Ford-Fulkerson AlgorithmFind an augmenting path s-b-d-a-c-t with flow value 2 and update the flow and residual graphs as follows:
![Page 11: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/11.jpg)
CS223 Advanced Data Structures and Algorithms 11
The Implementation and Time ComplexityThe Implementation and Time Complexity
If all the link capacities are integers, then the time complexity of the Ford-Fulkerson algorithm is bounded by O(f|E|), where f is the max flow.
A bad example for random path selection.
![Page 12: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/12.jpg)
CS223 Advanced Data Structures and Algorithms 12
The Implementation and Time ComplexityThe Implementation and Time Complexity
In each step, find an augmenting path which allows largest the increase in flow using a modified Dijkstra’s algorithm. It has been proved that it terminates after O(|E|logCapmax) steps, so the time complexity is O(|E|2log|V|logCapmax).
The Edmonds-Karp algorithm: In each step, find an augmenting path with minimum number of edges using BFS. It has been proved that it terminates after O(|E||V|) steps. So the time complexity is O(|E|2|V|).
![Page 13: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/13.jpg)
13
Another Approach: Linear Programming Another Approach: Linear Programming
LP in the standard form
CS223 Advanced Data Structures and Algorithms
An LP can be solved by existing algorithms in polynomial time.
![Page 14: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/14.jpg)
14
Maximum Flow Problem - LPMaximum Flow Problem - LP
CS223 Advanced Data Structures and Algorithms
![Page 15: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/15.jpg)
15
Shortest Path Problem - ILPShortest Path Problem - ILP
CS223 Advanced Data Structures and Algorithms
![Page 16: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/16.jpg)
16
Maximum Matching in A Bipartite GraphMaximum Matching in A Bipartite Graph
CS223 Advanced Data Structures and Algorithms
A matching (a.k.a. independent edge set): a set of edges without common
vertices.
The maximum matching problem: find the matching with the maximum number of edges.
![Page 17: Maximum Flow Neil Tang 3/30/2010](https://reader035.vdocument.in/reader035/viewer/2022062517/568139b5550346895da150cc/html5/thumbnails/17.jpg)
17
Maximum Matching in A Bipartite GraphMaximum Matching in A Bipartite Graph
CS223 Advanced Data Structures and Algorithms
A max-flow based algorithm