\documentclass[12pt]{article}



% native LaTeX packages

\usepackage{array}

\usepackage{latexsym}

\usepackage{theorem}

\usepackage{amsmath}

\usepackage{amssymb}



% my packages

\usepackage{684setup}

%\usepackage{mysetup}



\newcommand{\Fin}{f^{\text{ in}}}

\newcommand{\Fout}{f^{\text{ out}}}

\newcommand{\MCF}{{\sc mcf}}

\newcommand{\R}{\ensuremath{\mathbb{R}}}

\newcommand{\refEQ}[1]{\ensuremath{\text{(\ref{#1})}}}





\renewcommand{\thesubsection}{\arabic{subsection}}



\begin{document}

\MyTitle{9/26/01}{Min-cost flows \#1}{scribe: Alex Slivkins}



\subsection{Basic definitions.}



Let $G=(V,E)$ be a directed graph, possibly with parallel or opposite edges.

For all edges $e$ define 

\emph{capacities} $u_e\geq 0$ and \emph{costs} $c_e$.

Let a \emph{flow} be a function $f:E\rightarrow \R$ that satisfies the \emph{capacity contraints}

\begin{equation}\label{eq:caps}

	 0\leq f_e \leq u_e

\end{equation}

for each edge $e$.

Define the cost of a flow $f$  

as\footnote{This is the most common definition for the cost of a flow. Other definitions of the form

	\[ c(f)= \sum_{e\in E} h(c_e,f_e) \] 

where $h$ is a function $\R\times\R\rightarrow\R$ can also be meaningful and have been studied in literature.}

	\[ c(f)= \sum_{e\in E} c_e f_e. \]



For all nodes $v$ define \emph{demands} $b_v$ that sum up to 0.

Say a flow $f$ is \emph{feasible} if for each node $v$

it satisfies the \emph{flow conservation} constraints

\begin{equation}\label{eq:cons}

	 \Fin(v)-\Fout(v)=b_v,

\end{equation}

where 

\begin{eqnarray*}

	\Fin(v)  &=& \sum_{\text{edge $e$ enters $v$}} f_e \\

	\Fout(v) &=& \sum_{\text{edge $e$ leaves $v$}} f_e

\end{eqnarray*}

The Min-Cost Flow problem (\MCF\ in short) is (surprise surprise) to find a min-cost feasible flow.



If there are no parallel or opposite edges we can extend 

a flow $f$ to a function $V\times V \rightarrow \R$

\[f_{uv} = \begin{cases}

	f_e,	& e=(uv)\in E, \\

	-f_e,	& e=(vu)\in E, \\

	0,	& \text{otherwise}

\end{cases}\]

Then the flow conservation constraints~\refEQ{eq:cons} can be expressed shorter: for each node $v$

\begin{equation}\label{eq:smart}

	\sum_{u\in V} f_{uv} = b_v

\end{equation}





\subsection{Well-known special cases.}



\begin{description}



\item[max-flow] Given a directed graph $G$, capacities $u_e$, terminal pair $st$.

Find an $st$ flow of maximal cost.

To express as \MCF: set all costs and demands to 0;

add an extra edge $ts$ of infinite capacity and cost $-1$. 

 

\item[shortest-path] Given a directed graph $G$, lenghts $l_e$, terminal pair $st$.

Find an $st$ path of minimal length.

Express it as \MCF\ as follows.

Set costs to lengths: $c_e=l_e$;

Set all capacities to 

1.\footnote{Will also work with all capacities are set to some other number, or to infinity.}

Set demands $b_s=-1$, $b_t=1$. Set all other demands to 0.



\item[network design] Given a directed graph $G$, costs $c_e$ for building an edge $e$,

a terminal pair $st$. Find a subgraph $G'\subset G$ of minimal cost 

(defined as the sum of edges of $G'$)

s.t. $G'$ contains $k$ (edge-)disjoint $st$ paths.

Express it as \MCF\ as follows.

Set $b_s = -k$, $b_t=k$. Set all other demands to 0.

Set all capacies to 1.

Keep all costs as given.

Let $f_e$ be the \emph{integer} solution to the \MCF. 

Then $\{e: f_e=1\}$ is a solution to the Network Design problem.



\end{description}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Simple algorithm for MCF.}



Given a flow $f$, define the \emph{residue graph} $G_f=(V,E_f)$ with two kinds of edges:

\begin{itemize}

\item \emph{forward} edges $e\in E_f$ s.t. $e\in E$ and  $f_e<u_e$, of cost $c_e$.



\item \emph{backward} edges $(w,v)\in E_f$ s.t. $e=(v,w)\in E$ and $f_e>0$, of cost $-c_e$.

\end{itemize}



Define the cost of a cycle as the sum of the costs of its edges.

Say a cycle is \emph{negative} if it has a negative sum. 



\begin{lemma}\label{lm:neg}

If $G_f$ has a negative cycle, then flow $f$ is not min-cost.



\pf Say $C$ is a negative cycle in $G_f$. For $\delta\geq 0$ 

define a function $f^{\delta}: E\rightarrow\R$ by

\[ f^{\delta}_e = \begin{cases}

	f_e + \delta, & \text{if $e\in C$ is a forward edge,} \\

	f_e - \delta, & \text{if $e=(v,w)$ is s.t. $(w,v)\in C$ is a backward edge,}\\

	f_e, & \text{otherwise}

\end{cases}\]



$f^{\delta}$ has a smaller cost than $f$:

\begin{eqnarray*}

	c(f^{\delta}) - c(f) & =& 

		\sum_{\text{fwd $e\in C$}} \delta c_e - 

		\sum_{\text{bwd $e\in C$}} \delta c_e \\

	&=& \delta\ c(C) < 0

\end{eqnarray*}

Therefore, it remains to prove that if $\delta>0$ is small enough then $f^{\delta}$ 

is a feasible flow. 

An equivalent definition of $f^{\delta}_e$ is

\[ f^{\delta}_e = \begin{cases}

	f_e + \delta, & \text{if $f_e<u_v$ and $e\in C$,} \\

	f_e - \delta, & \text{if $f_e>0$ and $e=(v,w)$ is s.t. $(w,v)\in C$,}\\

	f_e, & \text{otherwise}

\end{cases}\]

Therefore, if $\delta>0$ is small enough then $f^{\delta}$ satisfies the capacity constraints \refEQ{eq:caps}.



It turns out that the flow conservation constraints~\refEQ{eq:cons} are satisfied by any $f^{\delta}$.

\refEQ{eq:cons} obviously holds for any $v\not\in C$.

Now suppose $v\in C$. If there are no parallel or multiple edges, 

it is easy to check that

\[ f^{\delta}_{uv} = \begin{cases}

	f_{uv} + \delta, 	& \text{if $(uv)\in C$,} \\

	f_{uv} - \delta, 	& \text{if $(vu)\in C$,}\\

	f_{uv}, 		& \text{otherwise}

\end{cases}\]

So if $(u,v,w)$ are consecutive vertices of $C$ then 

 	\[ f^{\delta}_{uv}+ f^{\delta}_{wv} = f_{uv}+f_{wv} \]

Therefore~\refEQ{eq:smart} holds at $v$.  

The general case is similar but a lot messier.\qed



\end{lemma}

 

Now we are ready to present a simple \emph{cycle-cancelling} algorithm for \MCF.



\begin{algorithm}\label{alg:cancel}

\rm Solves \MCF\ by \emph{cycle cancelling}.



\begin{enumerate}



\item Find \emph{some} flow $f$ by a single run of a max-flow computation (known from CS 681 or CS 482).

If all capacities and demands are integer, then wlog $f$ is an integer flow.



\item Repeatedly change $f$, each time decreasing its cost. 

Specifically, if $G_f$ has a negative cycle, 

set $f\leftarrow f^{\delta}$ where $f^{\delta}$ satisfies~\refEQ{eq:caps} 

with the largest $\delta$.



\item Stop when $G_f$ contains no negative cycles.

\end{enumerate} 

\end{algorithm}



\noindent In the next lecture we'll prove that if $G_f$ contains no negative cycles then $f$ is min-cost.



\subsection{Running time}



If all costs and capacities  are integer (and finite) then throughout the algorithm

the flow is integer.

So at each step the flow decreases by at least 1.

Since the cost of any flow is at least

	\[ N = \sum_{c_e<0} u_e c_e, \]

\#steps is at most $c(f)-N$, where $f$ is the initial flow.

Therefore, Alg.~\ref{alg:cancel} terminates and runs in pseudo-polynomial time.



If there are multiple negative cycles in $G_f$, Alg.~\ref{alg:cancel} does not specify which 

one to choose. By choosing smartly one can obtain a polynomial-time algorithm.

There are two ways to do this:

\begin{itemize}



\item (By Francisko Barahona and Eva Tardos) Choose the cycle(s) $C$ with the smallest $\Delta c= \delta^C c(C)$, 

where $\delta^C$ is the largest $\delta$ s.t. $f^{\delta}$ satisfies~\refEQ{eq:caps}.

Cancel several node-disjoint cycles at once.



\item (By Andrew Goldberg and Robert Tarjan) Select a cycle $C$ with minimal $\frac{c(C)}{|C|}$ (a \emph{min mean-cost} cycle).

This approach has the Edmonds-Karp algorithm as a special case.



\end{itemize}



\end{document}