Chapter 8 · Simulation

Network Flow

← Chapter 8
sourcesinkaugmenting pathmin cut

Ready.

 

 

Network Flow

Ford-Fulkerson and Edmonds-Karp are compared on the same directed network with the same capacities.

How to use

  • Enter the number of nodes (4–12) and press New Graph. Node 0 is the source and the last node is the sink; capacities range from 5 to 15 and every edge points from left to right.
  • Drag nodes to rearrange the drawing (not while an algorithm is running).
  • Run Ford-Fulkerson or Edmonds-Karp; every run starts again from zero flow, so the two methods can be compared on the same network. Cancel stops the animation; the speed selector changes the pace.
  • Each edge is labelled flow/capacity and gets thicker as its flow grows. The current augmenting path is highlighted; a dashed segment means the path uses that edge backwards (cancelling flow).
  • When a run ends, the nodes still reachable from the source in the residual network are coloured and the edges of the minimum cut are marked: their capacities add up to the maximum flow.

Ford-Fulkerson

Repeatedly finds any augmenting path in the residual network. This demo uses depth-first search to pick the path. With integer capacities at most |f*| augmentations are needed, so the running time is O(E · |f*|).

Edmonds-Karp

Uses breadth-first search to pick the augmenting path with the fewest edges, which gives a polynomial bound of O(VE²).

Max-flow min-cut theorem

The value of a maximum flow equals the capacity of a minimum s–t cut. The cut shown after a run is found from the final residual network.