For a directed graph, the uncapacitated minimum-cost flow problem is
Positive is external supply and negative is demand; summing the flow balances requires . There are no finite upper arc capacities. Let be the oriented incidence matrix with tail and head . For free dual potentials , the Lagrangian is
Its infimum over nonnegative flows is exactly when every network reduced cost is nonnegative; otherwise the infimum is minus infinity. Thus the dual maximizes subject to these inequalities. For a primal feasible flow and dual feasible potentials,
This derives weak duality and the complementary slackness condition . A feasible pair satisfying it has equal objectives and certifies optimality.
A spanning tree gives candidate network dual potentials by making all its arcs tight: choose one root potential and propagate along each tree arc, reversing this equation when traversing against the arc. An arbitrary tree does not automatically make the non-tree reduced costs nonnegative; those inequalities must be checked. If a guaranteed feasible construction is needed and there is no negative directed cycle, use dual network potentials from shortest-path distances: add an auxiliary source reaching every vertex, calculate distances , and take . The shortest-path inequality proves dual feasibility, with tightness on the shortest-path tree.
For the printed dashed tree, set all non-tree flows to zero and solve the balances from the leaves. This gives
The remaining arcs have zero flow. The total initial cost is . This is a basic feasible solution, though degenerate because the tree flow on is zero.
Normalize . Tree tightness gives
The non-tree reduced costs are
The negative reduced cost on identifies an improving entering arc for the network simplex algorithm. Adding it to the tree creates a unique undirected cycle. Sending along increases the flows on by and decreases those on by ; all other flows are unchanged. This balanced displacement preserves every node equation. Nonnegativity limits to the minimum of the four decreasing flows, namely . Choose arc to leave among the tied limiting arcs.
After this one pivot the nonzero flows are
and every other arc flow is zero. The objective decreases by , giving cost .
For the new tree, tight potentials normalized at vertex 1 are
All tree reduced costs are zero. For the non-tree arcs they are , respectively, so the potentials are dual feasible. Their dual objective is
matching the primal cost. Complementary slackness therefore proves
This is the stopping test of the network simplex method: maintain a feasible tree flow, compute tight potentials, enter a negative-reduced-cost non-tree arc, make a maximal feasible cycle adjustment and exchange a limiting tree arc, until all reduced costs are nonnegative. Here exactly one improving step suffices.