ShusenWang 图数据结构和算法课程笔记 Slides
- Bottleneck capacity = 2
- Iteration 2:
- Find an augmenting path: s -> v_1 -> v_3 -> t
- Update residuals
- Remove saturated edge
- Iteration 3:
- Find an augmenting path: s -> v_1 -> v_4 -> t
- Update residuals
- Remove saturated edge
- Iteration 4:
- Cannot find an augmenting path: end of procedure
- Summay
- Inputs: a weighted directed graph, the source , and the sink .
- Goal: Send as much water as possible from to
- Constraints:
- Each edge has a weight (i.e., the capacity of the pipe).
- The flow must not exceed capacity.
- naïve algorithm
- Build a residual graph; initialize the residuals to the capacity.
- While augmenting path can be found:
- a. Find an augmenting path (on the residual graph.)
- b. Find the bottleneck capacity in the augmenting path.
- c. Update the residuals. (residual ← residual − .)
- The naïve algorithm can fail
- The naïve algorithm always finds the blocking flow.
- However, the outcome may not be the maximum flow.
Summary
- Procedure
- On the level graph, no flow can be found!
- End of Procedure
- Summary
1. Initially, the residual graph is a copy of the original graph.
2. Repeat:
1. Construct the level graph of the residual graph.
2. Find a blocking flow on the level graph.
3. Update the residual graph (update the weights, remove saturated edges, and add backward edges.)
- Time complexity: $O(m \cdot n^2)$ . (m is #edges; n is #vertices.)
- Capacity (S, T) = sum of weights of the edges leaving S.
- In the figure, three edges leave S.
- Capacity (S,T) = 2 + 2 + 2 = 6
- Max-Flow Min-Cut Theorem
- In a flow network, the maximum amount of flow from s to t is equal to the capacity of the minimum s-t cut.
- In short, amount of max-flow = capacity of min-cut.
- Algorithm
- Run any max-flow algorithm to obtain the final residual graph.
- E.g., Edmonds–Karp algorithm or Dinic’s algorithm.
- Ignore the backward edges on the final residual graph
- Find the minimum s-t cut (S,T) :
- On the residual graph, find paths from source to all the other vertices.
- S ← all the vertices that have finite distance. (Reachable from s.)
- T ← all the remaining vertices. (Not reachable from s.)
- Example