Fact-checked by Grok 2 weeks ago

Minimum-cost flow problem

The minimum-cost flow problem is a cornerstone of network optimization, seeking a feasible in a that satisfies capacity limits on edges and supply/ balances at while minimizing the aggregate cost of transporting units of along the edges. Formally, the problem is defined on a G = (V, E) with set V and edge set E, where each edge e \in E has a nonnegative capacity c(e), a lower bound l(e) (often 0), and a cost per unit \gamma(e) (which may be positive, negative, or zero), and each v \in V has a balance b(v) representing net supply (if positive) or (if negative), with \sum_{v \in V} b(v) = 0. The objective is to find a f: E \to \mathbb{R} such that l(e) \leq f(e) \leq c(e) for all edges and holds at each v (inflow - outflow = -b(v)), minimizing the total cost \sum_{e \in E} \gamma(e) \cdot f(e). If all supplies, demands, and capacities are , the problem admits an optimal , ensuring that basic feasible solutions via methods like the yield integral . Several efficient algorithms solve the minimum-cost flow problem in polynomial time, including the successive shortest path algorithm, which iteratively augments flow along minimum-cost paths using techniques like with potentials, and the cycle canceling algorithm, which eliminates negative-cost cycles until optimality. More advanced variants, such as Orlin's algorithm from the early 1990s, achieve strongly polynomial . Recent breakthroughs, starting with van den Brand et al. (2022) achieving almost-linear time for graphs with polynomially bounded demands and costs, followed by a deterministic version in 2023 (Chen, Kyng, Peng) and extensions to dynamic networks in 2024, have further improved runtimes. The problem encompasses numerous special cases and has broad applications in logistics and beyond, such as the transportation problem (shipping goods from warehouses to retailers), the (allocating workers to jobs or students to seminars to minimize costs or maximize preferences), and communication networks ( data flows efficiently). It also serves as a unifying framework for other optimization tasks, including maximum-weight bipartite matching, minimum cuts, and Gomory-Hu trees in . Historically, the minimum-cost flow problem traces its roots to early 20th-century work on transportation networks, with the transportation problem formalized by Frank Hitchcock in 1941 and in 1947, and broader network flow variants developed by and Delbert Fulkerson in the 1950s; the cycle canceling approach was introduced by in 1967.

Mathematical Formulation

Network Model

The minimum-cost flow problem is formulated on a G = (V, A), where V is the finite set of vertices representing nodes and A \subseteq V \times V is the set of directed arcs connecting pairs of nodes. Each node v \in V may represent a supply point, demand point, or point, while each arc a \in A models a possible pathway for flow transmission between nodes. This graph-theoretic structure captures the topological and directional constraints inherent in flow networks, such as or communication systems. For each arc a = (i, j) \in A, the model specifies a lower bound l(a) \geq 0 on the flow amount, an upper bound or u(a) > l(a) limiting the maximum flow, and a c(a) representing the per unit of flow along that arc. These parameters ensure that flows respect physical or operational limits, such as pipeline capacities or budget constraints, while the costs quantify the economic or resource implications of routing flow through specific paths. Lower bounds are often zero in basic formulations but allow for mandatory minimum flows in more general cases. Each node v \in V is associated with a supply/demand value b(v), where b(v) > 0 indicates net supply available at v, b(v) < 0 denotes net demand to be satisfied at v, and b(v) = 0 signifies a transshipment node with no net inflow or outflow requirement. For the problem to be feasible, the total supply must equal the total demand across all nodes, i.e., \sum_{v \in V} b(v) = 0. This conservation condition ensures that the network can be balanced without excess or deficit accumulation. A simple illustrative network might consist of four nodes: sources s_1 and s_2 with b(s_1) = 5, b(s_2) = 3; sinks t_1 and t_2 with b(t_1) = -4, b(t_2) = -4; and a transshipment node v with b(v) = 0. Arcs could include (s_1, v) with capacity 5 and cost 2, (s_2, v) with capacity 3 and cost 1, (v, t_1) with capacity 4 and cost 3, and (v, t_2) with capacity 4 and cost 1, demonstrating how flows originate at sources, route through intermediate nodes, and terminate at sinks. Such a diagram highlights the directional flow from supplies to demands via interconnected arcs. Networks are classified as balanced if \sum_{v \in V} b(v) = 0, allowing direct feasibility, or unbalanced otherwise, where the imbalance \sum_{v \in V} b(v) \neq 0 implies infeasibility without modification. To address imbalance, a common technique introduces a dummy node connected by additional arcs to absorb the excess supply or fulfill the unmet demand, effectively restoring balance while adjusting capacities and costs accordingly. For instance, if total supply exceeds demand, arcs from the dummy node to excess supply nodes can be added with infinite capacity and zero cost.

Objective Function and Constraints

The minimum-cost flow problem is defined on a directed graph with nodes V and arcs A, where each arc a \in A has a cost c(a), lower bound l(a), and upper bound u(a) on the flow f(a) it can carry, and each node v \in V has a supply/demand b(v). The goal is to determine a feasible flow that minimizes the total transportation cost while respecting arc capacities and nodal requirements. The objective function is to minimize the total cost: \min \sum_{a \in A} c(a) f(a) This linear objective captures the aggregate cost of sending flow f(a) along each arc at unit cost c(a). The constraints consist of capacity bounds and flow balance equations. For each arc a = (i,j) \in A, l(a) \leq f(a) \leq u(a), ensuring that the flow on every arc lies within its specified limits; typically, l(a) \geq 0 and flows are non-negative, though general lower bounds allow for bidirectional or required flows. For each node v \in V, \sum_{a \in \delta^+(v)} f(a) - \sum_{a \in \delta^-(v)} f(a) = b(v), where \delta^+(v) is the set of arcs leaving v and \delta^-(v) is the set entering v; here, b(v) > 0 indicates net supply at v, b(v) < 0 indicates net demand (with |b(v)| as the demand amount), and b(v) = 0 for transshipment nodes. Together, these form the complete linear programming formulation: \begin{align*} \min &\quad \sum_{a \in A} c(a) f(a) \\ \text{s.t.} &\quad l(a) \leq f(a) \leq u(a) & \forall a \in A, \\ &\quad \sum_{a \in \delta^+(v)} f(a) - \sum_{a \in \delta^-(v)} f(a) = b(v) & \forall v \in V, \\ &\quad f(a) \in \mathbb{R} & \forall a \in A. \end{align*} A feasible solution to this program requires that the total supply equals the total demand across all nodes, i.e., \sum_{v \in V} b(v) = 0; this balance condition is necessary for the existence of any flow satisfying the conservation equations, as it ensures no net imbalance in the network. Without this, the problem is infeasible, as excess supply or unmet demand cannot be resolved within the given structure. The flow conservation constraints derive from the mass balance principle in network flows, analogous to the steady-state conservation of mass in physical systems: for any node v, the net inflow must equal the external supply or demand b(v), preventing accumulation or depletion at intermediate points and ensuring that flow is preserved along paths from sources to sinks. This principle translates directly into the balance equation, where positive b(v) represents injection of flow (outflow exceeds inflow by b(v)) and negative b(v) represents extraction (inflow exceeds outflow by -b(v)).

Connections to Other Problems

Relation to Maximum Flow

The minimum-cost flow problem generalizes the maximum flow problem by extending the objective beyond merely maximizing the net flow from a source to a sink; instead, it seeks to satisfy supply and demand constraints while minimizing the total transportation cost across capacitated edges. In this framework, the maximum flow problem emerges as a special case when all edge costs are set to zero, reducing the optimization to finding the largest feasible flow value without regard to cost. This relationship highlights how minimum-cost flow incorporates cost minimization as a natural extension, allowing for more nuanced modeling of real-world networks where efficiency in resource allocation involves both capacity and expense. When demands are fixed—such as requiring exactly D units of flow from source to sink—and all edge costs are uniform (e.g., zero or constant), the minimum-cost flow problem simplifies to verifying feasibility or achieving the maximum possible flow under those constraints, effectively reverting to the maximum flow formulation. The core algorithmic insight connecting the two lies in the augmenting path concept: the Ford-Fulkerson method for maximum flow iteratively augments along any residual path to increase total flow, whereas minimum-cost flow adapts this by selecting the cheapest augmenting path in the residual graph with respect to edge costs, ensuring cost efficiency at each step. This cost-aware variant preserves the augmenting structure while optimizing the objective, enabling algorithms like successive shortest paths to solve minimum-cost instances. Historically, the Ford-Fulkerson algorithm, published in 1956, provided the foundational augmenting path paradigm that directly influenced subsequent developments in minimum-cost flow algorithms, which build upon it to handle costs. For instance, a maximum flow instance can be transformed into a minimum-cost flow problem by setting the supply at the source node to -D and the demand at the sink to +D (where D is the target flow value), with all edge costs at zero; the resulting solution achieves the desired flow at minimal (zero) cost if feasible, or reveals infeasibility otherwise. This reduction demonstrates the versatility of minimum-cost flow as a unifying framework for flow-based optimizations.

Relation to Minimum-Cost Circulation

The minimum-cost circulation problem is a special case of the minimum-cost flow problem where the supply/demand function b(v) = 0 for all nodes v \in V, requiring the identification of a feasible circulation f—a flow that conserves flow at every node and respects arc capacities—that minimizes the total cost \sum_{(i,j) \in A} c_{ij} f_{ij}. Any instance of the minimum-cost flow problem can be transformed into an equivalent minimum-cost circulation problem by introducing additional arcs to balance the supplies and demands; specifically, add a super-source connected to all nodes with positive supply via arcs of capacity equal to the supply and cost zero, and a super-sink connected from all nodes with negative demand (i.e., positive demand) via arcs of capacity equal to the absolute demand and cost zero, ensuring the overall network admits a circulation that satisfies the original balances. This equivalence preserves the optimal cost and allows algorithms for one problem to solve the other, with the circulation formulation often simplifying analysis in balanced networks. In both formulations, optimality relies on the residual network G_f, constructed from a feasible flow f by including forward arcs with residual capacity u_{ij} - f_{ij} at cost c_{ij} and backward arcs with capacity f_{ij} at cost -c_{ij}; a flow f is optimal if and only if G_f contains no negative-cost directed cycles, as augmenting along such a cycle would reduce the total cost while maintaining feasibility. For the circulation problem, these conditions align with the Karush-Kuhn-Tucker (KKT) optimality criteria of the associated linear program, where dual multipliers (node potentials) ensure complementary slackness: for each arc (i,j), the reduced cost c_{ij} + \pi_i - \pi_j \geq 0 if f_{ij} < u_{ij}, c_{ij} + \pi_i - \pi_j \leq 0 if f_{ij} > 0, and equality holds when the arc is partially used, with no negative reduced-cost cycles in the residual graph. As an illustrative example, consider a minimum-cost flow instance with a single source s supplying value v and sink t demanding v; this can be converted to a circulation by adding a return arc from t to s with lower and upper capacity v and cost 0, forcing exactly v units to circulate back and ensuring the minimum-cost solution matches the original .

Algorithms

Successive Shortest Path Algorithm

The successive shortest algorithm is a primal algorithm for solving the minimum-cost problem in capacitated networks with supplies and demands. It initializes the to zero (or any feasible pseudoflow) and repeatedly identifies a shortest in the residual graph from a with excess supply to a with excess , using reduced costs to account for potentials, then augments the along this by the minimum residual or unmet until all supplies and demands are balanced. This approach ensures that each augmentation increases the total while maintaining minimum cost at each step, leveraging the fact that the residual graph encodes possible adjustments. The algorithm was originally proposed by and Fulkerson in the mid-1950s and independently rediscovered by Jewell in 1958. To implement the algorithm efficiently, node potentials \pi(v) are maintained for each v, initially set to zero or computed as shortest-path distances in the initial residual graph. These potentials transform the original costs c(u,v) into reduced costs c_\pi(u,v) = c(u,v) + \pi(u) - \pi(v), ensuring non-negative reduced costs in the residual graph and allowing the use of for shortest-path computations after the first iteration. After each augmentation, the potentials are updated by adding the shortest-path distances from the current computation to the existing potentials, preserving non-negativity. The following outlines the process, assuming a with vertex supplies/demands b(v) (positive for supply, negative for demand), capacities u(e), and costs c(e); B tracks the total unmet demand:
SuccessiveShortestPath(G = (V, A), b, c, u):
    f(e) ← 0 for all e ∈ A  // Initialize zero flow
    π(v) ← 0 for all v ∈ [V](/page/V.)  // Initialize node potentials
    B ← ∑_{v: b(v)>0} b(v)  // Total supply to satisfy
    while B > 0:
        Construct residual graph G_f with reduced costs c_π
        Let s be a supply node with positive residual supply
        Let t be a demand [node](/page/Node) with positive residual demand
        Compute shortest path P from s to t in G_f using c_π (via Bellman-Ford or Dijkstra)
        if no such path exists: return "Infeasible"
        δ ← min{ residual capacity along P, residual supply at s, residual demand at t }
        Augment f along P by δ
        Update B ← B - δ
        Update potentials: π(v) ← π(v) + dist_π(s, v) for all v
    return f
Augmentation involves increasing flow on forward arcs and decreasing on backward arcs along P. The algorithm terminates when no augmenting exists in the graph under reduced costs, meaning all supplies are met and demands satisfied, at which point the flow is feasible. Optimality follows from the absence of negative reduced-cost cycles or paths, which by complementary slackness conditions in the dual ensures the flow minimizes . Each reduces B by at least the minimum or , bounding the number of augmentations by the total flow value. Without potentials, using Bellman-Ford for each shortest path yields a time complexity of O(|V| |A|) per iteration times up to O(B) iterations, where B is the total flow value, but this is pseudo-polynomial. With reduced costs and Dijkstra's algorithm (implemented via binary heaps), the per-iteration cost drops to O(|A| + |V| \log |V|), leading to an overall complexity of O(B (|A| + |V| \log |V|)) for networks with integral data; Fibonacci heaps further improve the per-iteration cost to O(|A| + |V| \log |V|), but the algorithm remains pseudo-polynomial due to the dependence on B. To achieve polynomial time, scaling techniques such as capacity scaling are employed.

Cycle Canceling Algorithms

Cycle canceling algorithms solve the minimum-cost problem by starting with a feasible and iteratively improving it until optimality is reached. These methods maintain feasibility throughout the process, unlike primal-dual approaches that may temporarily violate constraints. The core idea is to identify and augment along negative-cost cycles in the residual graph, which reduces the without altering the net at nodes. To initiate the algorithm, an initial feasible flow is computed, often by solving a on the network while ignoring costs, ensuring the flow satisfies and constraints. Then, while a negative-cost exists in the residual graph, the algorithm detects it and augments the flow along the cycle by the minimum residual on that , thereby decreasing the . typically employs the Bellman-Ford applied to the reduced costs in the residual graph, where reduced costs are defined using node potentials to preserve costs while potentially eliminating negative edges. The process terminates when no negative-cost cycles remain, at which point the flow is optimal because any further improvement would require augmenting along a negative , which does not exist. Klein's algorithm, introduced in 1967, is the seminal cycle canceling method, which guarantees convergence but may require exponentially many iterations in the worst case. Polynomial-time variants address this limitation; for instance, the minimum mean cycle canceling algorithm selects the cycle with the smallest mean cost (total cost divided by the number of edges) at each step, ensuring the number of iterations is bounded by a in the number of nodes and edges. This variant, developed by and Tarjan in 1989, runs in strongly time using an efficient implementation of minimum mean cycle detection.

Example

Consider a simple network with three nodes A, B, and C, and directed edges A \to B with capacity 5 and cost 2, B \to C with capacity 5 and cost 3, and C \to A with capacity 5 and cost -6. Suppose the initial feasible flow is zero everywhere, satisfying conservation for a circulation problem. In the residual graph, the cycle A \to B \to C \to A has total cost $2 + 3 + (-6) = -1 and minimum residual capacity 5.
EdgeCapacityCostInitial Flow
A \to B520
B \to C530
C \to A5-60
Augmenting by 5 units along this negative updates the flows to 5 on each , reducing the by $5 \times (-1) = -5. The new residual graph has backward s with negated s: B \to A -2, C \to B -3, A \to C 6, but no negative cycles remain, confirming optimality. This illustrates how a single cancellation eliminates the negative and achieves minimum .

Capacity Scaling Algorithms

Capacity scaling algorithms address the minimum-cost flow problem by decomposing the solution process into phases that progressively refine the flow using a scaling parameter \Delta, which starts at the largest power of 2 not exceeding the maximum arc capacity and is halved in each subsequent phase. This approach, introduced by and Orlin, ensures a logarithmic number of phases, O(\log U) where U is the maximum capacity, making the method efficient for networks with large capacities. In each phase, the algorithm computes an \epsilon-optimal flow for a scaled subproblem, where \epsilon = \Delta \cdot c_{\max} and c_{\max} is the maximum arc cost, by performing successive shortest path augmentations in the graph using reduced costs to account for current flow potentials. Augmentations are restricted to residual arcs with capacity at least \Delta, and shortest paths are efficiently computed via with node potentials to maintain non-negative reduced costs. The integration of these shortest path steps, potentially augmented by cycle canceling to resolve residual imbalances, guarantees progress toward optimality while preserving polynomial time per phase. For instances with unit arc costs, the Ahuja-Orlin algorithm achieves a of O(|A| \log |V| (|A| \log |A| + |V| \log |V|)), where |A| is the number of arcs and |V| is the number of vertices; this bound is strongly , independent of capacity and cost magnitudes. Lower bounds on arc flows are handled via circulation reduction, transforming the original problem into an equivalent minimum-cost circulation by first computing a feasible circulation in a modified , often using a maximum subroutine, before applying the scaling phases. These algorithms outperform non-scaling approaches on large-scale instances with substantial capacities, as the logarithmic dependence on U avoids the potentially exponential iterations tied to total value in methods like basic successive shortest paths.

Applications

Transportation and Transshipment Problems

The is a classic application of the minimum-cost flow problem, modeling the distribution of goods from multiple suppliers to multiple demanders while minimizing total shipping costs. In this setup, is represented as a bipartite , with supplier nodes serving as sources and demander nodes as sinks. Arcs connect each supplier to each demander, each with an associated unit transportation cost and capacity limit (often unbounded in the basic formulation). The goal is to determine shipment quantities along these arcs that satisfy all requirements at minimum cost. The transshipment problem extends the transportation problem by incorporating intermediate nodes, such as distribution hubs or transshipment points, allowing flows to route through these nodes before reaching final demanders. These intermediate nodes have no net supply or demand, enabling more flexible networks that reflect real-world supply chains with or rerouting. The structure includes arcs from suppliers to intermediates, between intermediates, and from intermediates to demanders, all with respective costs and capacities. This generalization maintains the core minimum-cost flow structure while accommodating multi-stage distribution. Within the minimum-cost , both problems are formulated by assigning balances b(v): b(v) = -s_i for each supplier i with supply s_i > 0, b(v) = +d_j for each demander j with d_j > 0, and b(v) = 0 for any , ensuring supply (\sum b(v) = 0). Flows on arcs must satisfy conservation at each and bounds, with the objective to minimize \sum c_e f_e over arc costs c_e and flows f_e. The transportation problem was first formally introduced by Hitchcock in 1941 as a method for optimal product distribution across multiple sources and localities. Subsequently, Dantzig in adapted the specifically for solving transportation problems, demonstrating its efficiency for large-scale instances and influencing early computational approaches in . Consider a representative transportation problem with two suppliers (S1 with supply 300 units, S2 with supply 400 units) and three demanders (D1 requiring 200 units, D2 requiring 300 units, D3 requiring 200 units). The unit shipping costs are given in the following table:
D1D2D3
S1435
S2623
The optimal solution ships 0 from S1 to D1, 300 from S1 to D2, 0 from S1 to D3, 200 from S2 to D1, 0 from S2 to D2, and 200 from S2 to D3, yielding a minimum total cost of 2700.

Bipartite Matching and Assignment Problems

The minimum-weight problem in a arises in scenarios where entities from two disjoint sets must be paired optimally based on associated costs. Consider a with partitions U = \{u_1, \dots, u_n\} and W = \{w_1, \dots, w_n\}, and directed arcs from each u_i to each w_j with costs c(u_i, w_j) \geq 0. A assigns each u_i to exactly one w_j such that no two assignments share a , minimizing the total cost \sum c(u_i, w_{\pi(i)}) over permutations \pi. This problem, known as the when |U| = |W| = n, can be solved as a minimum-cost problem by constructing a on the . Set the capacity of each (u_i, w_j) to u(u_i, w_j) = 1 and lower bound l(u_i, w_j) = 0, with costs c(u_i, w_j) unchanged. Assign node supplies and demands such that b(u_i) = -1 (supply of 1) for each u_i \in U and b(w_j) = +1 (demand of 1) for each w_j \in W, with b(v) = 0 for all other nodes (if any). The minimum-cost of value n then corresponds to a minimum-weight , as the unit capacities enforce at most one unit of per , and the supplies/demands ensure each is incident to exactly one unit of . An equivalent formulation adds a source s and sink t: connect s to each u_i with capacity 1 and cost 0, and each w_j to t with capacity 1 and cost 0. Set supply b(s) = -n and demand b(t) = n, with all other nodes balanced at 0. The minimum-cost flow from s to t of value n yields the same optimal assignment. This unit-capacity structure distinguishes the assignment problem from more general transportation problems, which allow higher capacities on arcs. The Kuhn-Munkres algorithm, also known as the , provides a specialized primal- method for solving the in O(n^3) time, which can be interpreted as optimizing the of the corresponding minimum-cost linear on the bipartite . While the operates directly on the cost matrix via augmenting paths and potential adjustments, minimum-cost algorithms like successive shortest paths can solve the same instance by finding n augmenting paths in the residual , offering a unified for generalizations beyond unit capacities. Illustrative Example
Consider assigning three jobs A, B, C to three machines X, Y, Z with the following cost matrix, where entries represent the cost of assigning job i to machine j:
Job \ MachineXYZ
A192831
B111716
C121513
In the flow network, U = \{A, B, C\} and W = \{X, Y, Z\}, with arcs from jobs to machines having unit capacities and the given costs. Supplies are 1 at each job node, and demands are 1 at each machine node. The minimum-cost flow of value 3 sends one unit along paths corresponding to the optimal assignment: A \to X (cost 19), B \to Y (cost 17), C \to Z (cost 13), for a total cost of 49. This matching saturates all nodes with minimum total cost, verifiable via flow algorithms or the Hungarian method applied to the matrix.

Economic Interpretations

The minimum-cost flow problem finds natural economic interpretations in settings where resources must be allocated across interconnected stages or agents to minimize total expenses while satisfying constraints. In this framework, s represent economic entities such as production stages, markets, or facilities, while arcs denote transformation processes, transportation routes, or transactions, each with associated unit costs and capacities. The formulation provides particularly insightful economic meaning: potentials act as prices or values for commodities at each location, and reduced costs on arcs reflect net profits or losses from routing one unit of from origin to destination after accounting for buy-sell price differences. In , the minimum-cost flow model captures multi-stage or by modeling nodes as temporal or sequential phases—from raw materials to —and arcs as processes or options with associated costs. For instance, in seasonal goods like , nodes correspond to periods (e.g., quarters), arcs from a source to each period represent with costs based on variable expenses and capacities limited by output, while inter-period arcs model carryover with holding costs and limits; demand arcs to a enforce sales requirements, ensuring minimal total and expenses. This setup optimizes resource timing and allocation, preventing shortages or excess buildup. Arbitrage detection in financial s leverages the model's sensitivity to negative cycles, where such cycles signal profitable, riskless opportunities by indicating paths where the total is negative, allowing unlimited gains through repeated transactions like currency exchanges or security trades. In a circulation-based , nodes represent assets or markets, and arcs denote trades with costs as negative returns (e.g., differentials); solving for minimum-cost circulation identifies these cycles, quantifying exploitable deviations from , such as covered violations in markets. At optimality, the absence of negative cycles ensures no further exists, aligning flows with market efficiency. Extensions to multi-commodity flows adapt the single-commodity model for scenarios involving distinct goods sharing capacities, such as diverse products in supply chains, but retain the core economic focus on cost minimization under shared constraints. A practical application appears in crew scheduling, where the problem minimizes operational costs by assigning crews to flight legs as flows through a time-space : nodes are duty periods or , arcs connect feasible pairings with costs for salaries, per diems, and , subject to coverage demands and regulatory limits on hours. Policy implications arise from shadow prices, interpreted as the dual variables on supply-demand constraints, which quantify the marginal economic value or cost of adjusting resource availability at each —guiding decisions on subsidies, taxes, or investments by revealing how small changes in balances affect total system costs.

Implementation Considerations

Complexity Analysis

The successive shortest path algorithm for the minimum-cost flow problem has a worst-case time complexity of O(|V| |A|^2 \log |V| C), where |V| is the number of vertices, |A| is the number of arcs, and C is the maximum arc cost magnitude; this bound assumes the use of reduced costs, node potentials to ensure non-negative reduced costs, and implemented with heaps for finding augmenting paths. variants of this algorithm, such as capacity scaling combined with successive shortest paths, achieve improved bounds like O(|A| \log |V| (|A| + |V| \log |V|)) under general capacities, by processing phases that halve the residual capacities iteratively and augmenting along multiple paths in parallel where possible. Strongly algorithms, which run in time in the input size regardless of the magnitudes of costs or capacities, represent a key advancement for the minimum-cost flow problem. The Goldberg-Tarjan algorithm from , based on a push-relabel with node potentials and cost scaling, achieves a time complexity of O(|V| |A| \log(|V|^2 / |A|)) for finding a minimum-cost circulation, which can be adapted to the general flow problem; this bound relies on dynamic tree data structures for efficient shortest-path computations in the residual graph. More recent progress includes Orlin's 1993 algorithm, which solves the minimum-cost flow problem in O(|A| \log |V| (|A| + |V| \log |V|)) time, offering a simpler and faster strongly solution through a refinement of the Edmonds-Karp capacity that avoids dependence on cost magnitudes. Even more recent theoretical advancements, as of 2022–2023, have introduced almost-linear time algorithms for minimum-cost flow on directed graphs with polynomially bounded integral demands and costs, achieving running times of m^{1 + o(1)}, where m = |A|. These algorithms, such as those by et al. (2023), use interior-point methods combined with dynamic data structures for solving sequences of undirected min-ratio problems. While highly efficient in theory, partial implementations were available as of 2024, but full practical integrations into standard libraries remain under development. The following table compares the time complexities of major minimum-cost flow algorithms under different assumptions:
AlgorithmGeneral CapacitiesUnit Capacities
$O(V
$O(A
$O(V
$O(A
Although the minimum-cost flow problem is solvable in polynomial time and thus in P, it is P-complete under logarithmic-space reductions, implying that it cannot be solved efficiently in parallel (in NC) unless P = NC; this hardness holds even for approximating the minimum-cost maximum flow to within a factor related to the maximum edge cost. However, the integrality theorem guarantees that if all supplies, demands, and arc capacities are integers, then there exists an optimal minimum-cost flow that is integer-valued, allowing algorithms to focus on solutions without loss of optimality.

Practical Software Tools

Several open-source libraries provide implementations for solving minimum-cost flow problems, enabling researchers and practitioners to model and compute solutions efficiently in various programming environments. , a library for graph analysis, includes the min_cost_flow function, which computes a minimum-cost flow satisfying node demands while respecting edge capacities and costs using successive shortest path algorithms. Similarly, the graph template library in C++ offers high-performance algorithms for minimum-cost flows, including cost-scaling and network simplex methods, optimized for large-scale networks through efficient data structures and sparse representations. Commercial solvers integrate minimum-cost flow capabilities as specialized subroutines within broader frameworks, often outperforming general-purpose methods on network-structured problems. supports minimum-cost flow modeling via its interface, leveraging barrier and algorithms with automatic detection of network structures for faster solves. CPLEX provides a dedicated network optimizer in its callable library, which exploits flow conservation constraints to reduce problem size and accelerate solutions using primal-dual variants. For practical usage, Google's library offers an accessible interface with the SimpleMinCostFlow class, suitable for prototyping small to medium networks. The following code snippet demonstrates solving a basic minimum-cost flow problem with five nodes and nine arcs, where node 0 supplies 20 units, node 3 demands 5 units, and node 4 demands 15 units:
python
from ortools.graph import pywrapgraph
smcf = pywrapgraph.SimpleMinCostFlow()

# Define arcs: start_nodes, end_nodes, capacities, unit_costs
start_nodes = [0, 0, 1, 1, 1, 2, 2, 3, 4]
end_nodes = [1, 2, 2, 3, 4, 3, 4, 4, 2]
capacities = [15, 8, 20, 4, 10, 15, 4, 20, 5]
unit_costs = [4, 4, 2, 2, 6, 1, 3, 2, 3]

for i in range(len(start_nodes)):
    smcf.add_arc_with_capacity_and_unit_cost(start_nodes[i], end_nodes[i],
                                             capacities[i], unit_costs[i])

# Set supplies/demands
supplies = [20, 0, 0, -5, -15]
for i in range(len(supplies)):
    smcf.set_node_supply(i, supplies[i])

if smcf.solve() == smcf.OPTIMAL:
    print('Minimum cost:', smcf.optimal_cost())
    for arc in range(smcf.num_arcs()):
        print('Flow:', smcf.flow(arc), 'on arc', smcf.tail(arc), '->',
              smcf.head(arc), 'with capacity', smcf.capacity(arc),
              'and unit cost', smcf.unit_cost(arc))
This example yields an optimal cost of 150, routing flows to minimize total transportation expenses. Handling large-scale instances, where exact solutions become computationally intensive, often requires parallelization or heuristic approximations. Parallel network simplex implementations, such as those extending LEMON's algorithms, distribute pivot operations across multiple processors to scale on DIMACS benchmark instances with millions of arcs. For even larger or time-critical applications, heuristic methods like successive approximation or provide near-optimal solutions quickly, integrated in solvers like Gurobi via callback functions. Benchmarks on the DIMACS minimum-cost flow dataset, comprising instances from sparse networks to dense random graphs, highlight performance differences among tools. LEMON's network simplex implementation solves most DIMACS problems fastest, often in under 1 second for medium instances (up to 10,000 nodes), outperforming CPLEX's network optimizer by factors of 2-5 on uncapacitated cases due to specialized pivoting. Gurobi and show competitive runtimes on structured instances but lag on highly sparse graphs compared to LEMON, with excelling in ease of use for Python-based workflows.

References

  1. [1]
    [PDF] Minimum-Cost Flows | Jeff Erickson
    $$(e) · f (e). The minimum-cost flow problem asks for a feasible flow with minimum cost, instead of a feasible flow with maximum value.
  2. [2]
    [PDF] The Minimum Cost Flow Problem - MIT OpenCourseWare
    Apr 23, 2013 · If the supplies, demands, and capacities of a minimum cost flow problem are all integral, then every basic feasible solution is integer valued.
  3. [3]
    Almost-Linear-Time Algorithms for Maximum Flow and Minimum ...
    Dec 13, 2023 · Several important algorithmic problems can be reduced to minimum-cost flows, for example, max-weight bipartite matching, min-cut, and Gomory-Hu ...
  4. [4]
    [PDF] Min Cost Flow - cs.Princeton
    Assignment Problem Applications. Many important real world applications. Left. Right. Optimize service personnel military postings relocation cost bachelors.
  5. [5]
    [PDF] Network flows - DSpace@MIT
    A |. The minimum cost network flow problem canbe formulated as follows: Minimize. ^ C;; x;:. (1.1a). (i,j)€A^. ' subject to. X^ii -. Xxji =b(i), foralli€N,. ( ...
  6. [6]
  7. [7]
    [PDF] 1 Minimum-Cost Flows
    Oct 13, 2022 · Today, we consider a generalization of max flow called minimum-cost flows, where edges now have costs as well as capacities, and the goal is to ...
  8. [8]
    Network Flows: Theory, Algorithms, and Applications - Google Books
    presents in-depth, self-contained treatments of shortest path, maximum flow, and minimum cost flow problems, including descriptions of polynomial-time ...
  9. [9]
  10. [10]
    [PDF] 1 Minimum-Cost Flows
    Mar 21, 2023 · The goal of the minimum-cost flow problem is to find feasible flows of minimum possible cost. ... flows, they satisfy the flow conservation ...Missing: derivation mass balance
  11. [11]
    [PDF] 14.1 Minimum Cost Flow Algorithms
    The shortest augmenting path algorithm for solving the minimum cost max flow problem is the natural generalization of the shortest augmenting path algorithm ...
  12. [12]
    [PDF] 8.5 Minimum-Cost Network Flow Problems
    Let us show that transportation and maximum-flow problems are special cases of the minimum-cost network flow problem. Formulating a Transportation Problem as an ...
  13. [13]
    [PDF] Min-Cost Flow Algorithms 10.1 Shortest Augmenting Paths
    The shortest augmenting path algorithm for solving the MCF problem is the natural extension of the SAP algorithm for the max flow problem. Note that here the ...
  14. [14]
    [PDF] 13.1 Minimum Cost Flow Problem - DSpace@MIT
    A Min-Cost Circulation problem is a min-cost ow problem on a graph with no source and no sink. A circulation is a ow that satisfies all edge capacities and ...<|separator|>
  15. [15]
    [PDF] Lecture 11 1 Minimum-Cost Circulations
    Oct 11, 2007 · From here on, we will consider only the minimum-cost circulation problem and algo- rithms to solve it. We will now change our notation slightly ...
  16. [16]
    [PDF] Minimum-cost Flows - Carnegie Mellon University
    Formally, the min-cost max flow problem is defined as follows. Our goal is to find, out of all possible maximum flows, the one with the least total cost. What ...
  17. [17]
    [PDF] The Minimum Cost Flow Problem - DSpace@MIT
    A feasible flow x is optimal for the minimum cost flow problem if and only if there is no negative cost cycle in the residual network G(x). Page 20. 20.
  18. [18]
    [PDF] Lecture 10: Minimum Cost Network Flows - University of Connecticut
    • Minimum cost circulation problem as a generalization. ▫ Special cases o Maximum flow problem o Transportation problem o Assignment problem. • Dual problem ...<|separator|>
  19. [19]
    Minimum Cost Multicommodity Circulation Problem with Convex Arc ...
    The Kuhn-Tucker conditions necessary and sufficient for a circu lation / to be optimal are that there exist multipliers rk for all x e N and all k = 1, 2 ...
  20. [20]
    [PDF] FINDING MINIMUM-COST CIRCULATIONS - BY CANCELING ...
    A standard way to convert a maximum flow problem into a minimum- cost circulation problem is to give every original arc a cost of zero and to add a return are ...
  21. [21]
    Optimal Flow through Networks with Gains - jstor
    Establish any routing of flow in the network that obeys conservation and capacity restrictions, and absorbs the desired input flow. Page 8. William S. Jewell ...
  22. [22]
    A Primal Method for Minimal Cost Flows with Applications to the ...
    Abstract. A simple procedure is given for solving minimal cost flow problems in which feasible flows are maintained throughout. It specializes to give primal ...
  23. [23]
    Finding minimum-cost circulations by canceling negative cycles
    A classical algorithm for finding a minimum-cost circulation consists of repeatedly finding a residual cycle of negative cost and canceling it.<|control11|><|separator|>
  24. [24]
    [PDF] Application of the simplex method to a transportation problem
    It is useful to reformulate the transportation problem in terms of a system of activities that have various items in common.
  25. [25]
    [PDF] Module 4: Transportation Problem and Assignment problem
    Types of Transportation problems: Balanced: When both supplies and demands are equal then the problem is said to be a balanced transportation problem.Missing: demanders | Show results with:demanders
  26. [26]
    [PDF] The Hungarian method for the assignment problem
    THE HUNGARIAN METHOD FOR THE ASSIGNMENT PROBLEM arguments of those sections. ... Kuhn, ONR Logistics. Project, Princeton (1953), mimeographed). (41 Hall, P ...
  27. [27]
    [PDF] Algorithms for the Assignment and Transportation Problems
    Feb 6, 2006 · Algorithms for the Assignment and Transportation Problems. James Munkres. STOR. Journal of the Society for Industrial and Applied Mathematics ...
  28. [28]
    [PDF] Unit 4: ASSIGNMENT PROBLEM - Cloudfront.net
    Step I :- Create Zero elements in the cost matrix by subtract the smallest element in each row column for the corresponding row and column. Step II:- Drop the ...
  29. [29]
    [PDF] Minimum Cost Flow Problem - David Duan
    Economic Interpretation​​ We could dual potentials as price of goods and reduced costs as the outcome for buying one unit at , transporting through , then ...
  30. [30]
    [PDF] Minimum cost flow problem - Pramesh Kumar
    Apr 4, 2024 · A feasible solution x∗ is an optimal solution if and only if the residual network G(x∗) contains no negative cost (directed) cycles. 6 ...<|separator|>
  31. [31]
    [PDF] Combinatorial Optimization Lab 09: Minimum Cost Flow
    Apr 7, 2020 · Let uj be the capacity of the production. You, as the ice-cream maker, want to plan the production for the following year with minimal cost.
  32. [32]
    A Circulation Network Model for the Exchange Rate Arbitrage Problem
    Dec 20, 2012 · In this article we present a circulation network model for the detection of arbitrage opportunities in the currencies and securities markets ...
  33. [33]
    [PDF] Minimum-Cost Multicommodity Flow - Stanford University
    Dec 15, 1997 · The minimum-cost multicommodity flow problem involves simultaneously shipping multiple commodities through a single network so that the total.Missing: economic | Show results with:economic
  34. [34]
    Survey Airline crew scheduling: models, algorithms, and data sets
    The crew pairing forms a minimum-cost set of anonymous feasible pairings from the scheduled flights such that all flights are covered exactly once and all ...
  35. [35]
    Finding Minimum-Cost Circulations by Successive Approximation
    GOLDBERG* AND ROBERT E. TARJAN? We develop a new approach to solving minimum-cost circulation problems. Our approach combines methods for solving the maximum ...
  36. [36]
    A Faster Strongly Polynomial Minimum Cost Flow Algorithm
    In this paper, we present a new strongly polynomial time algorithm for the minimum cost flow problem, based on a refinement of the Edmonds-Karp scaling ...
  37. [37]
    Approximating the minimum-cost maximum flow is P-complete
    Abstract. We show that it is impossible, in NC, to approximate the value of the minimum-cost maximum flow unless P = NC.
  38. [38]
    min_cost_flow — NetworkX 3.5 documentation
    Returns a minimum cost flow satisfying all demands in digraph G. G is a digraph with edge costs and capacities and in which nodes have demand.
  39. [39]
    Minimum Cost Flow Algorithms - LEMON
    LEMON contains several algorithms for this problem. In general, NetworkSimplex and CostScaling are the most efficient implementations.Missing: complexity | Show results with:complexity
  40. [40]
    Minimum-Cost Flow - gurobi-optimods documentation v2.4.0
    The minimum-cost flow problem routes flow through a graph in the cheapest possible way. It is a fundamental problem in graphs.
  41. [41]
    Optimizing Network Flow Models in the CPLEX Callable Library (C ...
    These routines optimize a network flow model. If part of your problem is structured as a network, then you may want to consider calling the CPLEX Network ...
  42. [42]
    Minimum Cost Flows | OR-Tools - Google for Developers
    Aug 28, 2024 · The problem is to find a flow with the least total cost. The min cost flow problem also has special nodes, called supply nodes or demand nodes.
  43. [43]
    gokcehan/pns: Parallel network simplex algorithm for the ... - GitHub
    Parallel network simplex algorithm for the minimum cost flow problem. This code is structured as a standalone tool to use as a solver for DIMACS minimum cost ...
  44. [44]
    [PDF] A Parallel, Linear Programming Based Heuristic for Large Scale Set ...
    Our implementation is carefully designed to exploit parallelism to greatest advantage in advanced techniques like preprocessing and probing, primal heuristics, ...
  45. [45]
    Minimum-cost flow algorithms: an experimental evaluation
    Abstract. An extensive computational analysis of several algorithms for solving the minimum-cost network flow problem is conducted.
  46. [46]
    Benchmark Data for the Minimum-Cost Flow Problem - LEMON
    Feb 23, 2015 · This page provides benchmark input data for the minimum-cost network flow problem. This test suite was used in the experiments of the paper.