9D

Flow networks and maximum flow

The language of flow networks (source, sink, capacity, flow), drawing a network from a table, the rules every flow must obey, and finding the maximum flow by sending flow along paths.

Picture Sydney's water supply: water starts at a dam, travels through pipes of different sizes, and ends up at a reservoir that feeds the suburbs. Each pipe can carry only so much per day. How much can reach the reservoir in total? That is a maximum flow problem, and the same idea works for traffic on roads, passengers through train lines, or data through a network.

The language of flow

  • The source is where everything starts. Flow only leaves it.
  • The sink is where everything ends. Flow only enters it.
  • The capacity of an edge is the most it can carry, such as $9$ megalitres per day. It is the weight on the edge.
  • The flow along an edge is how much is actually being sent. Diagrams often show both as flow/capacity, like $6/9$.

Edges are directed: a pipe or a one-way street only carries flow in the direction of its arrow. Every flow must obey two rules:

  1. Capacity rule: the flow along an edge can't exceed its capacity.
  2. Conservation rule: at every vertex except the source and sink, flow in $=$ flow out. Water doesn't appear or vanish at a junction.

Together these mean the total flow leaving the source equals the total flow entering the sink.

Example 1●

At junction $A$, pipes bring in $4$ and $3$ ML/day. Two pipes leave: one carries $5$ ML/day. How much does the other carry?

Flow in $= 4 + 3 = 7$
Conservation: what flows in must flow out.
Other pipe $= 7 - 5 = 2$ ML/day
The two outgoing pipes share those 7.

From a table to a network

Capacities are often given in a table, read as "from the row, to the column". A dash means there is no pipe in that direction.

From / ToABT
S$5$$4$–
A–$2$$3$
B––$6$

Draw a vertex for S, A, B and T, then one arrow for each number: S→A $5$, S→B $4$, A→B $2$, A→T $3$, B→T $6$. Check the count: $5$ numbers in the table, $5$ arrows.

Finding the maximum flow

For a small network, build the flow up one path at a time:

  1. Pick a path from source to sink that still has spare capacity on every edge.
  2. The most you can send along it is its smallest spare capacity (the bottleneck).
  3. Send that much, update the spare capacities, and repeat until no path has spare capacity left.
Example 2●●

Find the maximum flow from S to T in the network drawn from the table above.

Send $3$. Spare: S→A $2$, A→T $0$.
Path S→A→T: capacities 5 and 3, so the bottleneck is 3.
Send $4$. Spare: S→B $0$, B→T $2$.
Path S→B→T: capacities 4 and 6, bottleneck 4.
Send $2$. Spare: S→A $0$, A→B $0$, B→T $0$.
Path S→A→B→T: spare 2, 2 and 2.
Maximum flow $= 3 + 4 + 2 = 9$
Every edge out of S is now full, so no more can leave the source.
InteractiveSending water through pipes
Try this

This is a water network in megalitres per day. Click a path to send as much water along it as its narrowest pipe allows. Red pipes are full. Try S→A→C→T, then S→B→D→T, then S→A→B→D→T. What total do you reach?

Reset and start with the long path S→A→C→B→D→T instead. Why do you get stuck lower? Section 9E shows how to prove what the true maximum is.

Your turn

A network has S→A $8$, S→B $5$, A→B $3$, A→T $6$, B→T $7$. Find the maximum flow.

Show the working

S–A–T: $6$ (spare S→A $2$). S–B–T: $5$ (spare B→T $2$). S–A–B–T: bottleneck $\min(2, 3, 2) = 2$. Total $6 + 5 + 2 = 13$. Both edges out of S are now full ($8 + 5 = 13$), so $13$ is the maximum.

Flashcards
Source and sink
Source: where flow starts. Sink: where flow ends.
Two rules every flow obeys
Flow along an edge ≤ its capacity; flow in = flow out at every vertex except the source and sink
Most flow along one path
The smallest spare capacity on that path (the bottleneck)
Practice
  1. In a flow network, the sink is:

  2. The capacity of an edge is:

  3. Flows of $7$ and $5$ enter a junction. Two pipes leave it, and one carries $8$. How much does the other carry?

  4. A path S→A→C→T has capacities $9$, $6$ and $7$. What is the most that can be sent along this path on its own?

  5. A network has S→A $8$, S→B $5$, A→B $3$, A→T $6$, B→T $7$. Find the maximum flow from S to T.

  6. A flow of $10$ is shown on an edge with capacity $8$. This is:

  7. In a valid flow, the edges leaving the source carry $6$, $5$ and $3$. What is the total flow entering the sink?

  8. Exam style: Traffic (cars per minute) flows from S to T along one-way streets: S→A $10$, S→B $8$, A→C $4$, A→D $7$, B→D $5$, C→T $9$, D→T $9$. Find the maximum flow.

  9. Exam style: In the previous network, D→T is widened to carry $12$ cars per minute. Find the new maximum flow.

Formula sheet