Maximum Flow Neil Tang 4/8/2008 CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Class Overview The maximum flow problem Applications A greedy algorithm which does not work The Ford-Fulkerson algorithm Implementation and time complexity CS223 Advanced Data Structures and Algorithms
The 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 sink 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. CS223 Advanced Data Structures and Algorithms
The Maximum Flow Problem CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Applications Computer networks: Data traffic routing for throughput maximization. Transportation networks: Road construction and traffic management. Graph theory: Matching, assignment problems. CS223 Advanced Data Structures and Algorithms
Flow Graph and Residual Graph CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Basic 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. CS223 Advanced Data Structures and Algorithms
A Greedy Algorithm which Does Not Work Find an augmenting path s-a-d-t with flow value 3 and update the flow and residual graphs as follows: CS223 Advanced Data Structures and Algorithms
The Ford-Fulkerson Algorithm Find an augmenting path s-a-d-t with flow value 3 and update the flow and residual graphs as follows: CS223 Advanced Data Structures and Algorithms
The Ford-Fulkerson Algorithm Find an augmenting path s-b-d-a-c-t with flow value 2 and update the flow and residual graphs as follows: CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms A Bad Example CS223 Advanced Data Structures and Algorithms
The 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. 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|). CS223 Advanced Data Structures and Algorithms