26-4 Updating maximum flow

Let G=(V,E)G = (V, E) be a flow network with source ss, sink tt, and integer capacities. Suppose that we are given a maximum flow in GG.

a. Suppose that we increase the capacity of a single edge (u,v)E(u, v) \in E by 11. Give an O(V+E)O(V + E)-time algorithm to update the maximum flow.

b. Suppose that we decrease the capacity of a single edge (u,v)E(u, v) \in E by 11. Give an O(V+E)O(V + E)-time algorithm to update the maximum flow.

a. If there exists a minimum cut on which (u,v)(u, v) doesn't lie then the maximum flow can't be increased, so there will exist no augmenting path in the residual network. Otherwise it does cross a minimum cut, and we can possibly increase the flow by 11. Perform one iteration of Ford-Fulkerson. If there exists an augmenting path, it will be found and increased on this iteration. Since the edge capacities are integers, the flow values are all integral. Since flow strictly increases, and by an integral amount each time, a single iteration of the while loop of line 3 of Ford-Fulkerson will increase the flow by 11, which we know to be maximal. To find an augmenting path we use a BFS, which runs in O(V+E)=O(V+E)O(V + E') = O(V + E).

b. If the edge's flow was already at least 11 below capacity then nothing changes. Otherwise, find a path from ss to tt which contains (u,v)(u, v) using BFS in O(V+E)O(V + E). Decrease the flow of every edge on that path by 11. This decreases total flow by 11. Then run one iteration of the while loop of Ford-Fulkerson in O(V+E)O(V + E). By the argument given in part a, everything is integer valued and flow strictly increases, so we will either find no augmenting path, or will increase the flow by 11 and then terminate. "