← All problemsFree · Python · 55 min

Algorithm design / guarantees under an adversary

The Pipeline Detours

How many augmentations can Ford-Fulkerson take? Count them on the classic four-junction network, design a small network that forces a bad rule into hundreds, then compute a maximum flow and prove it with a minimum cut.

0 / 3 graded parts passSaved in this browser · loading saved work…
Jump to your work ↓

A water utility moves water from a reservoir s to a town t through pipes between junctions. Each pipe carries water in one direction, up to its capacity. A flow says how much each pipe carries. Every junction except s and t passes on exactly what it receives, and the value of the flow is what reaches t.

10001000110001000sabt
Part A's network: four pipes of 1000 and a middle pipe of 1.

Ford–Fulkerson starts with no flow and repeats: find a path from s to t in the residual network, then push as much as the path's tightest pipe allows. The residual network has each pipe's spare capacity, plus arcs that send back flow already pushed. Which path it picks is left open, and that choice matters.

A cut is a set of junctions containing s but not t. Every unit of flow crosses a cut's outgoing pipes, so no flow is larger than their total capacity. A flow whose value equals some cut's capacity is therefore maximum, and the cut proves it.

In code, a network is n junctions numbered 0 to n−1 and a list of pipes (from, to, capacity).

Background: Network Flow and Matchings.

easy · Part A

The slowest run on four junctions

Four junctions: s, a, b, t. Pipes s→a, s→b, a→t and b→t each hold 1000, and a middle pipe a→b holds 1. With the worst choice of paths, how many augmentations can Ford–Fulkerson take?

Explore in the sandbox

Experiment here, then copy a rule into the editor and test its guarantees.