# Minimum-cost flow problem

The minimum-cost flow problem (MCFP) is an optimization and decision problem to find the cheapest possible way of sending a certain amount of flow through a flow network. A typical application of this problem involves finding the best delivery route from a factory to a warehouse where the road network has some capacity and cost associated. The minimum cost flow problem is one of the most fundamental among all flow and circulation problems because most other such problems can be cast as a minimum cost flow problem and also that it can be solved very efficiently using the network simplex algorithm.

## Definition

A flow network is a directed graph ${\displaystyle G=(V,E)}$ with a source vertex ${\displaystyle s\in V}$ and a sink vertex ${\displaystyle t\in V}$, where each edge ${\displaystyle (u,v)\in E}$ has capacity ${\displaystyle c(u,v)>0}$, flow ${\displaystyle f(u,v)\geq 0}$ and cost ${\displaystyle a(u,v)}$, with most minimum-cost flow algorithms supporting edges with negative costs. The cost of sending this flow along an edge ${\displaystyle (u,v)}$ is ${\displaystyle f(u,v)\cdot a(u,v)}$. The problem requires an amount of flow ${\displaystyle d}$ to be sent from source ${\displaystyle s}$ to sink ${\displaystyle t}$.

The definition of the problem is to minimize the total cost of the flow over all edges:

${\displaystyle \sum _{(u,v)\in E}a(u,v)\cdot f(u,v)}$

with the constraints

 Capacity constraints: ${\displaystyle \,f(u,v)\leq c(u,v)}$ Skew symmetry: ${\displaystyle \,f(u,v)=-f(v,u)}$ Flow conservation: ${\displaystyle \,\sum _{w\in V}f(u,w)=0{\text{ for all }}u\neq s,t}$ Required flow: ${\displaystyle \,\sum _{w\in V}f(s,w)=d{\text{ and }}\sum _{w\in V}f(w,t)=d}$

## Relation to other problems

A variation of this problem is to find a flow which is maximum, but has the lowest cost among the maximum flow solutions. This could be called a minimum-cost maximum-flow problem and is useful for finding minimum cost maximum matchings.

With some solutions, finding the minimum cost maximum flow instead is straightforward. If not, one can find the maximum flow by performing a binary search on ${\displaystyle d}$.

A related problem is the minimum cost circulation problem, which can be used for solving minimum cost flow. This is achieved by setting the lower bound on all edges to zero, and then making an extra edge from the sink ${\displaystyle t}$ to the source ${\displaystyle s}$, with capacity ${\displaystyle c(t,s)=d}$ and lower bound ${\displaystyle l(t,s)=d}$, forcing the total flow from ${\displaystyle s}$ to ${\displaystyle t}$ to also be ${\displaystyle d}$.

The problem can be specialized into two other problems：

## Solutions

The minimum cost flow problem can be solved by linear programming, since we optimize a linear function, and all constraints are linear.

Apart from that, many combinatorial algorithms exist, for a comprehensive survey, see [1]. Some of them are generalizations of maximum flow algorithms, others use entirely different approaches.

Well-known fundamental algorithms (they have many variations):

## Application

### Minimum weight bipartite matching

Reducing Minimum weight bipartite matching to minimum cost max flow problem

Given a bipartite graph G = (AB, E), the goal is to ﬁnd the maximum cardinality matching in G that has minimum cost. Let w: ER be a weight function on the edges of E. The minimum weight bipartite matching problem or assignment problem is to find a perfect matching ME whose total weight is minimized. The idea is to reduce this problem to a network flow problem.

Let G’ = (V’ = AB, E’ = E). Assign the capacity of all the edges in E’ to 1. Add a source vertex s and connect it to all the vertices in A’ and add a sink vertex t and connect all vertices inside group B’ to this vertex. The capacity of all the new edges is 1 and their costs is 0. It is proved that there is minimum weight perfect bipartite matching in G if and only if there a minimum cost flow in G’. (citation missing) [7]