Learn
Lesson · Graph Algorithms · Flow and matching

Augmenting Paths

A flow is an assignment of a number to every arc that respects capacities and conserves at every interior vertex. Raise its value by finding a path from source to sink with spare capacity and pushing the bottleneck along it. The whole subject turns on one detail: the path may also run backwards along an arc that already carries flow, and without that the method stops below the maximum.

capacity constraint 0 <= f(a) <= c(a) on every arc conservation in = out at every vertex but s and t residual network forward spare c - f, and backward f augment push the bottleneck along a path from s to t maximal is not maximum: no path left under a restricted rule is not the same thing
What a flow is, and the one arc that is easy to leave out

Core ideas

What this lesson establishes

The hard idea is the backward arc. The definition and the residual network exist to make it expressible.

1

A flow is two constraints, and both are checkable

Every arc carries a number between 0 and its capacity, and at every vertex other than the source and the sink the total in equals the total out. The value of the flow is what leaves the source. The lab checks both constraints on whatever it produces and reports a verdict per vertex, so “this is a flow” is a measured statement rather than an assumption.

2

The residual network is where the search happens

For each arc carrying f out of a capacity c, the residual network holds a forward arc of capacity c - f, meaning how much more can be pushed, and a backward arc of capacity f, meaning how much of the existing flow can be taken back. A path from source to sink in that network is an augmenting path, and the bottleneck is the smallest residual capacity on it.

3

Undoing an earlier choice is not an optimisation

On the lab's opening network the first-found rule takes a path through the middle arc, pushes 1, and then cannot find a second path at all — the value stops at 1. With backward arcs available the same rule finds a second path that runs backwards along the middle arc, and reaches 2. The stuck flow is a perfectly legal flow; it is maximal, in that nothing can be added to it under that restriction, and it is not maximum.

The material

What a flow is, and the one arc the search must have

The two constraints, the residual network, the augmenting step, the failure without backward arcs, and what the path rule costs.

Definition · Flow, and its value

Given a digraph with a non-negative capacity c(a) on every arc, a source s and a sink t, a flow assigns to each arc a number f(a) with 0 ≤ f(a) ≤ c(a), such that at every vertex other than s and t the total on incoming arcs equals the total on outgoing ones. Its value is the net amount leaving s.

Definition · The residual network

For a flow f, the residual network has, for each arc a from u to v, a forward arc from u to v of capacity c(a) - f(a) and a backward arc from v to u of capacity f(a). Arcs of residual capacity 0 are omitted. An augmenting path is any path from s to t in it, and its bottleneck is the least residual capacity along it.

Pushing the bottleneck along an augmenting path — adding it on each forward arc and subtracting it on each backward one — produces a flow again, whose value is higher by the bottleneck. Capacities hold because the bottleneck was the minimum, and conservation holds because each interior vertex of the path gains the same amount on one side as the other.

The method

  1. Start with zero on every arc.
  2. Build the residual network and look for a path from s to t in it.
  3. If there is one, push its bottleneck along it and repeat.
  4. If there is not, stop.
Example · Four vertices, and a first push that has to be undone

The lab opens on 1>2 1, 1>3 1, 2>3 1, 2>4 1, 3>4 1 with source 1 and sink 4, and with backward arcs switched OFF. The first-found rule takes the three-arc path 1>2, 2>3, 3>4, pushes its bottleneck of 1, and then finds nothing: the search reaches only vertices 1 and 3, although the arc 1>3 still has spare capacity. The value stops at 1. Switch the backward arcs on and the same rule finds 1>3, then backwards along 2>3, then 2>4, pushes 1 more, and reaches 2.

Look at what the second path does. It sends a new unit from 1 to 3, cancels the unit that was going 2 to 3, and sends that one on to 4 instead. The net effect is two units arriving at the sink by two disjoint routes, and it was reachable only by rewriting a decision the first path had made. That is why the backward arc is part of the algorithm and not a refinement of it.

The stuck flow is worth naming precisely. It satisfies both constraints — the lab confirms conservation at every interior vertex — and no more can be pushed without taking something back. It is MAXIMAL. The maximum is 2. Two words that differ by three letters and by the whole content of this module.

The rule that chooses the path is a second question

The failure above was exhibited with a RULE rather than with a hand-picked path, and that matters: it is a claim about what an implementation does, not about what an adversary could do. On the same network the shortest-path rule happens never to take the middle arc, so it reaches 2 even with backward arcs off. That does not rescue the forward-only method, it just means this network does not defeat that particular rule.

Example · One thin arc between two fat ones

On 1>2 100, 1>3 100, 2>3 1, 2>4 100, 3>4 100 both rules reach the maximum of 200, and they take different numbers of steps to do it. The shortest-path rule augments twice, by 100 each time. The first-found rule augments four times, by 1, then 99, then 1, then 99: it walks into the thin arc, pays for it with a backward arc later, and does it twice.

That is the case the choice of rule is usually justified by, and the lab lets you watch it rather than describing it. The shortest-path rule — always take an augmenting path with the fewest arcs — is the one the kit's own maximum-flow routine uses, and its augmentation count on this network is the one the panel reports.

On the six-vertex network with capacities from 4 to 20, the shortest-path rule reaches 23 in three augmentations, pushing 12, then 4, then 7. Three numbers that add to the answer, and the third path is four arcs long where the first two were three — the rule takes the shortest available, and what is available changes as the residual network does.

Measured against proved, and this lesson is where the two are furthest apart. Three augmentations reaching 23 is a measurement. That 23 cannot be beaten is not something any number of augmentations can establish, because stopping means only that this search found no path. “Max Flow and Min Cut” supplies the missing half, and it is the one place on this course where the algorithm hands back its own proof.

Interactive

Maximum flow by augmenting paths

The residual network carries the flow already sent, so a later path can take it back

Augmenting paths in the residual networka backward arc carries the flow already sent, so a later path can take it back
on this augmenting patha backward arcsaturated, no residual left

Method

Augmenting by hand

Build the residual network first; the search is then an ordinary reachability question.

1

Draw the residual network, both directions

For every arc write its spare capacity forwards and its current flow backwards, and omit anything at 0. Doing the search on the original network with the flow in your head is where the backward arcs get lost, and losing them does not look like an error — it looks like being finished.

2

Take the bottleneck, and take it everywhere on the path

The amount pushed is the smallest residual capacity on the path, added on forward arcs and subtracted on backward ones. Pushing different amounts on different arcs breaks conservation, and pushing more than the minimum breaks a capacity.

3

Check that what you have is still a flow

Both constraints, every arc and every interior vertex. It is Θ(V + E) and it catches a sign error on a backward arc immediately, which is the mistake that otherwise survives until the final value is compared with something.

4

When no path is left, do not conclude anything yet

“My search found no path” and “no augmenting path exists” are the same statement only if the search was on the full residual network. The lab's opening preset is the case where they differ, and the honest report at this point is a value plus the rule that produced it.

Flows, residuals, and stopping

Score 0 / 0

The same four-vertex network, with and without the backward arc

The network is 1>2 1, 1>3 1, 2>3 1, 2>4 1, 3>4 1, every capacity 1, source 1 and sink 4. The rule is first-found, which takes arcs in the order they were typed.

backward arcs OFF path 1>2 2>3 3>4 bottleneck 1 value 1 residual 1>2 full, 2>3 full, 3>4 full, 1>3 spare 1, 2>4 spare 1 search from 1 reaches 3 through 1>3, and 3>4 is full: stop reachable {1, 3} value stays 1 is it a flow? yes: conserved at 2 and at 3, inside every capacity backward arcs ON, same rule, same network path 1 1>2 2>3 3>4 bottleneck 1 value 1 path 2 1>3 3>2 backwards 2>4 bottleneck 1 value 2 reachable afterwards {1} no path exists what the second path did new unit 1 -> 3 , cancel the unit 2 -> 3 , send that one 2 -> 4 net 1 -> 2 -> 4 and 1 -> 3 -> 4 two disjoint routes, value 2 the shortest-path rule, backward arcs OFF path 1 1>2 2>4 value 1 path 2 1>3 3>4 value 2

The forward-only run ends with the source's own arcs not both full: 1>3 still has its whole unit of spare capacity. That is the signature of being stuck rather than finished, and it is visible without knowing the answer — a maximum flow in this network would have to saturate one side of every cut, and the source's two arcs are a cut.

The last three lines are the reason the failure was demonstrated with a rule. The shortest-path rule never enters the middle arc here, so it does not need to undo anything on this particular network. A reader who saw only that rule would conclude the backward arcs are optional, and on a slightly larger network they would be wrong.

For a faded rehearsal, raise the capacity of 2>3 from 1 to 5 and predict what the first-found rule does with backward arcs off. The supplied first move is this: the first path is still 1>2, 2>3, 3>4 and its bottleneck is still 1, because 1>2 and 3>4 are unchanged. Say whether the run still stops at 1, and then say what happens if you raise 1>2 to 5 as well.

Common mistakes

1
Searching the original network instead of the residual oneThe arcs with spare capacity are only half of what is available, and the half that is missing is the one that makes the method correct. The symptom is a run that terminates cleanly with a legal flow below the maximum, which is the hardest kind of wrong answer to notice: nothing crashes and every constraint holds.
2
Reading a failed search as a proof that no path existsThey are the same statement only when the search covered the full residual network and the graph is the one you think it is. The lab's opening preset separates them deliberately, and the separation is the reason the certificate in “Max Flow and Min Cut” matters: it is what turns a failed search into a proof.
3
Concluding the backward arcs are unnecessary because one rule managed without themThe shortest-path rule reaches the maximum on the opening preset with backward arcs off, which is a fact about that network and that rule. Change the network and it stops being true. A demonstration that a restriction sometimes does no harm is not an argument that the restriction is safe.

Check your understanding

✓
Finish when you can augment by hand, including backwards, and say what stopping does and does not prove.

You should be able to build a residual network from a flow, find a path in it, push the bottleneck with the right sign on each arc, verify both constraints afterwards, and say precisely why a run that finds no further path has not yet established that its value is the maximum.

Note: “Max Flow and Min Cut” closes that gap, and it closes it completely. When the search fails, the set of vertices it reached is itself a cut, and the total capacity of the arcs leaving that set equals the value of the flow — which means the algorithm hands back a proof of its own optimality rather than needing one.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.