1 Problem statement and network model
1.1 Directed graph formulation
Minimum-cost flow is defined on a directed graph \(G=(V,E)\), where each directed arc \(e=(i,j)\) can carry flow from tail node \(i\) to head node \(j\). The goal is to determine how much flow to send along each arc so that the resulting flow respects node balance requirements and arc capacity limits, while the sum of arc costs over all used flow is minimized.
1.2 Decision variables and cost structure
For each arc \((i,j)\in E\), a decision variable \(x_{ij}\) specifies the amount of flow on that arc. Each arc has an associated per-unit cost \(c_{ij}\). The total cost is computed as \(\sum_{(i,j)\in E} c_{ij}x_{ij}\). In typical formulations, costs are constants given with the input instance, and flow variables are constrained to remain within feasible bounds.
1.3 Flow conservation and balance conditions
Nodes may have supplies or demands. Let \(b_i\) denote net supply at node \(i\): positive values represent supply, negative values represent demand, and zero indicates transshipment only. Flow conservation requires that for every node \(i\), \[ \sum_{j:(i,j)\in E} x_{ij} - \sum_{k:(k,i)\in E} x_{ki} = b_i. \] When all \(b_i=0\), the problem becomes a circulation problem, seeking a flow that conserves flow at every node.
1.4 Capacity constraints and feasibility
Each arc \((i,j)\) has a capacity \(u_{ij}\), typically expressed as an upper bound \(0 \le x_{ij} \le u_{ij}\). Feasibility means there exists at least one assignment of flows satisfying both node balance constraints and all arc bounds. If no such assignment exists, the instance is infeasible until the model is transformed (for example, by adding slack arcs or balancing constructs).
1.5 Special cases and variants
The framework includes several well-known variants. If all supplies are concentrated at a source and all demands at a sink, the problem resembles a transportation of a fixed amount. If capacities are large or absent and there is a single unit of flow, the model reduces toward shortest-path computations. A min-cost circulation variant has \(b_i=0\) for all nodes and may include lower bounds on arcs in more general settings.
2 Mathematical formulations
2.1 Linear programming form
Minimum-cost flow is naturally expressed as a linear program. Let \(x\) denote the vector of all arc flows. The linear programming form is:
- Objective: minimize \(\sum_{(i,j)\in E} c_{ij} x_{ij}\)
- Constraints: flow conservation at nodes, and capacity bounds on arcs.
2.1.1 Objective function and constraints
A standard linear programming statement is: \[ \min_{x}\ \sum_{(i,j)\in E} c_{ij}x_{ij} \] subject to, for each node \(i\), \[ \sum_{j} x_{ij} - \sum_{k} x_{ki} = b_i, \] and for each arc \((i,j)\), \[ 0 \le x_{ij} \le u_{ij}. \] This directly encodes balance and feasibility.
2.1.2 Properties of the constraint matrix
The constraint matrix is built from node-arc incidence relations and is highly structured. It is sparse and totally unimodular in standard formulations (for integer supplies/demands and integral capacities). This structure underlies the frequent emergence of integral optimal solutions despite a continuous linear programming relaxation.
2.2 Integral solutions and total unimodularity
When supplies/demands \(b_i\) are integers and capacities are integral, the total unimodularity of the incidence-based constraint matrix implies that every extreme point solution to the linear program is integral. Consequently, an optimal solution can be taken to have integer arc flows, even though the model is posed with continuous variables.
2.3 Dual problem (min-cost/max-potential view)
The dual formulation introduces node potentials (often denoted \(\pi_i\) or \(p_i\)) associated with flow conservation constraints. The reduced cost of an arc depends on the difference in potentials between its endpoints. In a common dual perspective, feasibility of dual variables corresponds to ensuring no negative reduced-cost directions exist (relative to the current potentials), while optimality aligns with all arcs having reduced costs consistent with the structure of the chosen flow.
3 Optimality conditions
3.1 Reduced costs and complementary slackness
Reduced cost measures the marginal cost of sending additional flow along an arc given the current potentials. For arc \((i,j)\), a typical definition is: \[ \bar{c}_{ij} = c_{ij} + \pi_i - \pi_j. \] Complementary slackness ties the sign of reduced costs to whether the arc is saturated or unused. Intuitively, if an arc carries positive flow that is not at a bound, its reduced cost must be zero at optimality; if an arc is at a bound, reduced cost signs determine whether pushing more is prevented by capacity limits.
3.2 Potentials and shortest path in residual networks
Optimality conditions can be checked using potentials together with shortest path computations over a residual network. In such a view, the algorithm maintains potentials so that reduced costs are nonnegative on certain residual arcs. Then, finding a shortest augmenting path corresponds to locating the cheapest way to improve the current solution without violating feasibility.
3.3 Negative cycles and optimality checks
For circulation problems (and related forms), optimality is equivalent to the absence of negative-cost cycles in the residual graph. A negative cycle represents a feasible adjustment direction that decreases total cost while keeping flow conservation intact. Thus, an algorithm may search for negative cycles to certify that no further cost reduction is possible.
3.4 Sensitivity to costs and supplies
Optimal solutions depend on input data. If arc costs change slightly, reduced costs shift, potentially altering which residual directions are attractive. If supplies/demands shift, the feasible set and balance constraints change, potentially requiring different augmenting adjustments. Sensitivity analysis in min-cost flow often leverages dual variables (potentials) to describe how the objective value moves under small perturbations.
4 Residual networks and augmenting ideas
4.1 Residual graph construction
Given a current feasible flow \(x\), the residual network captures how the solution can be modified without violating conservation. Residual arcs represent either sending additional flow on an original arc that still has unused capacity, or undoing some flow on an arc where the algorithm can reduce the current amount.
4.2 Forward and backward arc capacities
For each original arc \((i,j)\) with capacity \(u_{ij}\) and current flow \(x_{ij}\), two kinds of residual edges arise:
- A forward residual arc \((i,j)\) with capacity \(u_{ij}-x_{ij}\) and cost \(c_{ij}\).
- A backward residual arc \((j,i)\) with capacity \(x_{ij}\) and cost \(-c_{ij}\).
Sending flow along a backward arc effectively decreases \(x_{ij}\) by the same amount.
4.3 Augmenting paths and cost changes
An augmenting path is a path in the residual network from a node representing excess (or supply) to a node representing deficit (or demand). Augmenting along this path increases flow on certain arcs and decreases it on others (through backward edges), preserving node balance overall. The cost improvement equals the sum of residual arc costs along the chosen path times the augmentation amount, typically limited by the bottleneck residual capacity along the path.
4.4 Cancellation of suboptimal circulation
If the model is a circulation (all \(b_i=0\)), then any feasible flow can be decomposed into cycles. Suboptimality may appear as the presence of negative-cost cycles in the residual graph, where the algorithm can “cancel” parts of the flow by sending adjustments along these cycles, thereby reducing cost without changing feasibility.
5 Core algorithm families
5.1 Successive shortest augmenting path algorithm
Successive shortest augmenting path methods repeatedly find and augment along least-cost paths in the residual network until all demands are satisfied. These algorithms are closely tied to dual potentials, which help manage negative costs efficiently.
5.1.1 Initialization and handling initial infeasibility
A common approach is to start from a feasible flow (or construct one). If an initial feasible circulation is not available, transformations such as adding super source/sink arcs, temporary costs, or slack variables can yield feasibility. Once feasibility is established, the successive augmentation process proceeds.
5.1.2 Dijkstra with potentials for nonnegative reduced costs
If reduced costs are kept nonnegative via node potentials, shortest path computations can use Dijkstra’s algorithm efficiently. Potentials are updated to maintain the reduced-cost nonnegativity condition while reflecting the new residual edge structure after augmentation. This typically yields a strong practical performance profile.
5.2 Bellman–Ford-based augmenting methods
When reduced costs may be negative and no suitable potential scheme guarantees nonnegativity, algorithms may compute shortest paths using Bellman–Ford (or related relaxations) on the residual network each iteration.
5.2.1 When negative costs occur
Bellman–Ford handles negative edge costs (provided no negative cycles reachable from the start state create undefined shortest paths). In min-cost flow, negative edges appear naturally in the residual graph due to backward arcs with cost \(-c_{ij}\).
5.2.2 Complexity considerations
Bellman–Ford’s worst-case complexity can be higher than Dijkstra’s. As a result, potential-based refinements are often used in implementations to reduce the number of costly relaxations.
5.3 Cycle-canceling algorithms
Cycle-canceling methods start with a feasible flow and repeatedly identify negative-cost cycles in the residual graph, augmenting along them to reduce total cost.
5.3.1 Detecting and canceling negative cycles
Negative cycles can be found using algorithms for shortest paths in the presence of negative edges, or by explicitly searching cycle structures. Once a negative cycle is identified, augmentation amount is limited by the residual capacities on that cycle, ensuring feasibility persists.
5.3.2 Relationship to min-cost circulation
For min-cost circulation problems, cycle-canceling directly targets the optimality criterion: once no negative residual cycles remain, the flow is optimal. This makes the method conceptually aligned with the dual “no violated reduced-cost cycle” condition.
5.4 Network simplex and related methods
Network simplex methods exploit linear programming structure and operate on a basis that corresponds to a spanning tree-like structure of the underlying graph.
5.4.1 Pivoting on spanning structures
A pivot exchanges part of the basis, effectively changing how flow variables are determined while staying within feasibility. Reduced cost information guides entering arcs, and leaving arcs are selected to maintain the spanning structure constraints.
5.4.2 Practical considerations
Network simplex can be efficient on large sparse instances but may require careful implementation details. Practical performance depends on pivot rules, degeneracy handling, and the way residual costs and potentials are updated during the algorithm.
6 Handling infeasibility and transformations
6.1 Adding super source/sink
A typical transformation converts a general supply-demand min-cost flow into a form where a single source and sink are used to drive flow. One introduces a super source connected to supply nodes and a super sink connected from demand nodes, with arcs having zero cost and large capacity (or capacities matching required amounts).
6.2 Balancing supplies and demands
If total supply does not equal total demand, feasibility fails in the original formulation. A common remedy is to add balancing nodes or dummy arcs that allow excess to be absorbed or compensated. Alternatively, model variants introduce artificial variables with penalties to detect infeasibility.
6.3 Feasible circulation with demands
For circulation problems with demands encoded via node balances, one can transform demands into edge or node constraints using standard network transformations. After this conversion, the algorithm searches for a feasible circulation that satisfies all balances, then optimizes its cost.
6.4 Cost scaling and preprocessing steps
Preprocessing may include scaling costs to improve numerical behavior, simplifying dominated edges, or removing arcs with zero capacity. Cost scaling variants (depending on the chosen algorithm) can accelerate convergence by progressively refining the solution at multiple accuracy levels.
7 Complexity and performance
7.1 Parameterized running times
Running time depends on parameters such as the number of nodes, arcs, and magnitude of supplies. Many algorithmic families have performance bounds that can be expressed in terms of these parameters and the cost structure (for example, whether costs are nonnegative after potential shifting).
7.2 Sparse vs dense network impacts
Sparse networks generally benefit from specialized shortest path and residual graph handling, since data structures like adjacency lists reduce both memory and per-iteration scanning. Dense graphs can increase computational cost due to larger residual neighborhoods and heavier relaxations.
7.3 Scalability and implementation trade-offs
Implementations trade off between per-iteration work and number of iterations. For example, Dijkstra-based augmentations may require maintaining potentials and using priority queues effectively, while Bellman–Ford-based methods may be simpler but costlier per augmentation.
7.4 Typical bottlenecks in large-scale instances
Common bottlenecks include repeated shortest path computations, large residual graph growth, degeneracy leading to many small augmentations, and expensive priority queue operations. Practical systems mitigate these issues using efficient data structures, careful augmentation grouping, and stopping criteria that rely on maintaining strong invariants.
8 Applications and use cases
8.1 Transportation and logistics planning
Min-cost flow models shipments between locations while respecting transport capacities and meeting demands. Costs may represent distance, time, or money, and supplies/demands capture warehouse inventory and customer requirements.
8.2 Assignment and bipartite matching
In assignment settings, one often constructs a bipartite network where each unit of flow corresponds to matching an agent to a task. Capacity constraints enforce that each task receives at most one assignment (or a bounded number), and minimizing cost yields an optimal assignment.
8.3 Scheduling and routing with capacities
Scheduling can be represented by time-expanded networks, where nodes correspond to time points and arcs correspond to feasible transitions. Arc capacities represent resource limits (such as number of machines), while costs model delays or switching penalties.
8.4 Telecommunications and flow-based resource allocation
Network routing in telecommunications frequently uses min-cost flow to allocate bandwidth across paths. Costs can capture congestion cost surrogates, link reliability weights, or pricing models, while constraints ensure link capacity limits are not exceeded.
8.5 Image processing and computer vision analogues
Some vision tasks can be cast as flow problems, such as segmenting images using graph-based regularization or tracking features across frames. In these analogues, nodes represent pixels or superpixels across time, and edges encode similarity or allowable transitions with associated costs.
9 Extensions and generalizations
9.1 Min-cost circulation with lower bounds
Beyond upper bounds, arcs can have lower bounds \(l_{ij} \le x_{ij} \le u_{ij}\). This adds complexity because feasibility must satisfy both minimum and maximum usage. Standard transformations convert lower-bounded circulation into an equivalent problem by adjusting node balances and redefining variables.
9.2 Multicommodity vs single-commodity flow distinction
Classic min-cost flow treats a single type of flow (single-commodity). Multicommodity variants involve multiple flows with shared capacities, leading to nontrivial coupling constraints. Those problems are generally harder; the single-commodity case remains attractive because it retains polynomial-time solvability and strong structural properties.
9.3 Stochastic or time-expanded min-cost flow
Stochastic extensions model uncertain supplies, demands, or costs, often requiring expected-cost objectives or robust formulations. Time-expanded networks convert dynamic problems into static ones by replicating nodes across time steps, enabling standard min-cost flow techniques.
9.4 Convex cost extensions and piecewise linear costs
If costs are convex in flow amount rather than linear, the problem becomes a convex optimization problem. Many such formulations can be converted into min-cost flow with additional arcs or piecewise linear segments, preserving the combinatorial network structure.
9.5 Min-cost flow with additional side constraints
Realistic models may include constraints such as limits on total flow through a subset of arcs or requirements linking multiple arcs. Some side constraints can be incorporated by extending the graph or using decomposition techniques; others change the problem class and may require hybrid approaches.
10 Practical implementation guidance
10.1 Graph representation choices
Efficient implementations store residual arcs explicitly or maintain pointers from original arcs to their residual counterparts. Adjacency lists are typical, along with arrays for capacities, costs, and current flows. Since residual networks change over time, care is needed to update only affected edges.
10.2 Numerical stability and integer arithmetic
When the model is integral, using integer arithmetic for costs and flows can prevent rounding issues. If costs or potentials become large, overflow must be avoided with appropriate integer types. For floating-point costs (in convex or approximate settings), tolerance rules are important when checking reduced costs and optimality.
10.3 Retrieving primal flows and optimal costs
Algorithms typically maintain primal variables implicitly through residual adjustments. After termination, the final flows on original arcs are obtained from the stored residual representation. The optimal cost is then computed as the dot product of arc costs and final flows, or maintained incrementally by summing augmentation contributions.
10.4 Debugging: invariants and feasibility checks
Reliable code checks invariants after each augmentation: node balance should remain satisfied (up to exact arithmetic), and all residual capacities should be nonnegative. Feasibility checks also verify that the flow never violates upper bounds and that computed potentials match reduced cost expectations used by the shortest-path subroutine.
10.5 Testing on benchmark structures
Validation commonly uses small crafted graphs (where the optimum is easy to verify), random sparse instances with known properties, and classic benchmark families such as transportation networks and grid-based graphs. Stress tests should include cases with negative residual arcs, tight capacities, and degeneracy.
11 Worked examples
11.1 Small network walkthrough (step-by-step)
Consider a directed network with a single unit of supply at a source node and unit demand at a sink. After constructing the residual network, the successive shortest augmenting path method finds the cheapest residual route from source to sink. Augmentation pushes one unit along the path’s bottleneck residual capacity (which here is one), producing a feasible flow. Termination occurs once the sink’s demand is satisfied and no remaining augmenting path can reduce total cost.
11.2 Example with negative arc costs
Suppose some original arcs carry negative per-unit costs. Even if the original graph has negative edges, the residual graph introduces additional negative edges through backward arcs. The algorithm relies on reduced costs and potentials (or Bellman–Ford) to correctly identify whether sending flow along a residual direction would further decrease total cost. If a negative cycle exists in the residual graph, cycle-canceling or shortest-path-based checks will detect it and improve the solution until all negative opportunities are exhausted.
11.3 Example with capacities and bottlenecks
Let a network contain multiple parallel routes from a supply node to a demand node, but one route has a small capacity. When augmenting, the algorithm may send as much flow as allowed through the bottleneck residual capacity on the cheapest route, then it must redirect additional demand satisfaction to alternative paths. This illustrates how capacity constraints shape both the sequence of augmentations and the final flow distribution.
11.4 Interpreting the optimal flow structure
At optimality, the flow often shows patterns that correspond to tight constraints and zero reduced-cost arcs (with respect to the final potentials). In many instances, arcs with positive flow either lie on shortest admissible routes in the residual graph sense or are saturated in a way consistent with complementary slackness. This structural interpretation helps explain why further augmentations cannot decrease the objective.