PrevNext
StatusSourceProblem NameDifficultyTags
Wesley's Anger ContestNormal

Tutorial

So far, every edge in our flow network has had a capacity that serves as an upper bound on the flow through it: 0f(e)c(e)0 \le f(e) \le c(e). We now consider networks where each edge ee additionally has a lower bound (e)\ell(e), so that any valid flow must satisfy

(e)f(e)c(e).\ell(e) \le f(e) \le c(e).

In other words, we're now required to push at least (e)\ell(e) units of flow along ee. This single extension is surprisingly powerful: many problems that look nothing like flow ("each task must be performed at least xx times", "each person sings between aa and bb songs") reduce to it.

Feasible Circulation

Let's start with the simplest version, where there is no source or sink. A circulation is an assignment of flow to every edge such that

  • every edge respects its bounds: (e)f(e)c(e)\ell(e) \le f(e) \le c(e), and
  • conservation holds at every vertex: the flow in equals the flow out.

The question is whether a valid circulation exists at all.

I will first illustrate the flow graph we can set up to solve this problem, then explain why it works. First, we create two new nodes SS and TT and connect TST \rightarrow S with capacity \infty. Then, we apply the following transformation to every edge e=uve = u \rightarrow v:

  • Connect uTu \rightarrow T and SvS \rightarrow v with capacity l(e)l(e).
  • Reduce the capacity of uvu \rightarrow v to c(e)l(e)c(e) - l(e).

The idea is that in this transformed network, flow through ee will first be routed through the blue cycle (uTSvu \rightarrow T \rightarrow S \rightarrow v) until all l(e)l(e) units are saturated, and only the excess will pass through ee itself. This then means that all lower bounds will be satisfied iff all blue edges are saturated. To determine whether this is possible, we just need to run a maximum flow from SS to TT and check whether the resultant flow is exactly l(e)\sum l(e).

To recover the actual circulation, just take the flow g(e)g(e) found in the auxiliary network and add back the lower bound: f(e)=g(e)+(e)f(e) = g(e) + \ell(e).

Feasible Flow With a Source and Sink

Now suppose we do have a source ss and sink tt, and we want any flow from ss to tt respecting the lower bounds. The conservation constraint should hold everywhere except ss and tt.

We reduce this to the circulation case with one extra edge: add an edge from tt back to ss with lower bound 00 and capacity \infty. This "return edge" carries the net flow value back from the sink to the source, so conservation now holds at ss and tt as well, and the whole network becomes a circulation problem. Apply the construction above, and the flow value of the original network is exactly the flow sent along the tst \to s edge.

Maximum / Minimum Flow With Lower Bounds

Often we don't just want a feasible flow — we want the maximum (or minimum) flow from ss to tt subject to the lower bounds. Do it in two phases:

  1. Find a feasible flow using the construction above. If the blue edges can't be saturated, no valid flow exists and we stop.

  2. Augment in the residual network. Remove the auxiliary SS, TT, and the tst \to s edge, then run an ordinary max flow from ss to tt on the leftover residual graph. Adding these augmenting paths to the feasible flow keeps it feasible (we only ever increase flow on edges that have spare capacity) while pushing the sts \to t value as high as possible.

    For minimum flow, instead run a max flow from tt to ss in the residual graph and subtract it: we cancel as much circulating flow as possible while keeping every edge above its lower bound.

Problems

StatusSourceProblem NameDifficultyTags
CFNormal
CFNormal
CFNormal
ACNormal
CFVery Hard

Module Progress:

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!

PrevNext