Skip to the workspace
Pebellslearn by building
Flow & Matching  ›  Lesson

Min Cut & Duality

Min Cut & Duality 30 minThe nodes still reachable from source in the final residual graph, and the pipes crossing out of them, sum to exactly the max flow

dsa / Min Cut & Duality

Explore each scene at your own pace.

01 · The reachable set, after the fact

The reachable set, after the fact

Min Cut & Duality

Definition
A minimum cut is the cheapest set of edges whose removal separates the source from the sink, and the max-flow min-cut theorem says its total capacity equals the maximum flow. It is found as the edges leaving the set of nodes still reachable from the source in the final residual graph.
In plain words
The most water you can push through is the same as the narrowest bottleneck you would have to block to stop it all. Once no more can flow, the pipes that are completely full show you exactly where that bottleneck is.

In short: Once max flow stops growing, ask one question: which nodes can still be reached from the source using leftover residual capacity? That set is the source side of a cut, and the original pipes leaving it — the crossing edges — are exactly the ones running at full capacity. Their capacities always sum to the max flow. This is max-flow min-cut duality: the biggest amount you can push and the smallest set of pipes you'd have to sever to stop everything are the same number, proven by one reachability check on the graph the last lesson already built.

A network split by a dashed vertical line: depot, dock, mill, axle and berth shaded green on the left as reachable, harbour alone in white on the right, with two red pipes (axle-harbour at 4, berth-harbour at 1) crossing the line and a note that 4 plus 1 equals the exact max flow

The reachable set, after the fact

The last lesson's Edmonds-Karp run on Meridian's depot network stopped because BFS couldn't reach harbour any more. Look at why, in the final residual graph: every pipe still carrying forward residual capacity, plus every reverse edge flow has opened.

watch it move · graph

The residual graph after max flow stops growing. A dashed line through the numbers would show it, but the real test is simpler — just walk from depot using whatever still has capacity.

Start at depot, the source, and walk only edges with capacity left — forward pipes that aren't full, and reverse edges flow has opened. 6 nodes, 14 edges, directed. At depot.

1 / 6
Scene 1 of 7
Project context and further resources
You're building a piece ofMeridian — the dispatcher
This piece — limiting_cut(): Names the exact pipes that are choking the network and proves no more can get through them.
Scenario Dispatch doesn't just want the number — they want to know WHICH pipes are actually choking the network, so maintenance knows what's worth widening and what isn't.
limiting_cut.py
Call the function you wrote — just like your app's frontend would. Edit the inputs and hit Call.
limiting_cut(pipes, source, sink) → dictThe max flow, the source-reachable set after it, the pipes crossing out of it, and their capacity.
try:
returned
Press Run to execute your code.
Press Check to run the tests for this lesson.
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.