Shortest path, maximum flow, transportation, assignment — you have met these as separate puzzles. Here is the surprise: they are all the same puzzle wearing different clothes. The minimum-cost flow problem is the master network model that contains them all. Once you can recognise a decision as "route flow through a network at least cost", you inherit fast algorithms, integer solutions for free, and a way of thinking that unifies half of operations research.
Take a directed network — nodes joined by arcs. Each node
The heart of it is flow conservation: at every node, flow out minus flow in equals that
node's supply/demand. Nothing is created or lost except at the sources and sinks. This is
Node
The power of min-cost flow is how many familiar problems collapse into it once you set the numbers right:
| Classic problem | How it becomes min-cost flow |
|---|---|
| Shortest path | Send 1 unit from source to sink; arc cost = length; capacities unlimited |
| Maximum flow | All arc costs 0; add a return arc from sink to source with cost −1 to reward flow |
| Transportation | Sources with supply |
| Assignment | A transportation problem with every supply and demand equal to 1 |
Learn to translate into this table and a huge range of problems becomes a single solved model.
Min-cost flow is a linear program, so in general its optimum could sit at fractional coordinates. It does
not. The node–arc incidence matrix of any directed network is
totally unimodular: every square sub-determinant is
Specialised algorithms beat the general simplex handsomely on networks. The network simplex keeps the basis as a spanning tree and pivots by swapping one arc for another — extremely fast in practice. Successive shortest paths repeatedly sends flow along the cheapest remaining route from a source to a sink (using arc costs as distances), while cycle-cancelling starts from any feasible flow and keeps pushing flow around any negative-cost cycle it can find until none remain — at which point the flow is provably optimal. All run in polynomial time.
The hard part of min-cost flow is almost never the arithmetic — solvers handle that. It is seeing that a messy operational question ("route these repairs", "schedule these shifts", "match these donations") is a min-cost flow in disguise, and modelling it as nodes, arcs, supplies, capacities and costs. Miss the pattern and you reach for a slow, bespoke solver; spot it and you get a polynomial algorithm and integer answers for nothing. When a problem smells like "move stuff through a network subject to limits", stop and ask whether it is really min-cost flow.