In the previous section we have seen how finding the minimum cut of
carefully constructed network can give us the thresholded image
minimizing the energy function for one level value $\lambda$. We will in
-this, and the next section see how such a minimum cut can be found by
-sending flow through the network, and trying to identify the
+this and the next section see how such a minimum cut can be found by
+sending flow through the network and trying to identify the
``bottleneck''.
\subsection{Flow networks}
\end{description}
Note that we have defined $f$ with all pairs of vertices as its domain,
even though it is only non-zero on edges $(u, v) \in E$. This makes it
-easier to write sums as in the flow conservation constraint.
+easier to write sums as in the flow conservation constraint. We say that
+an edge $(u, v)$ is \emph{saturated} if $f(u, v) = c(u, v)$.
-We denote $\abs{f}$ as the net amount of flow from the source to the
+We define $\abs{f}$ as the net amount of flow from the source to the
sink in the network. Because of the flow conservation constraint, this
can be calculated as the net amount of flow going out of the source
\begin{equation}
\label{eq:flow_leq_cut}
\end{aligned}
\end{equation}
-for any $s$-$t$-cut $C = (S, T)$. We will see in the next theorem that
-this becomes an equality only when the flow is a maximum flow.
-
+for any $s$-$t$-cut $C = (S, T)$. The max-flow min-cut theorem, which
+will be presented later, states that this inequality becomes an equality
+when $f$ is a maximum flow, for some cut $C = (S, T)$, and this will
+then be a minimum cut.
+
+%Recall that we want to find the minimum $s$-$t$ cut in our network. When
+%finding this minimum cut, we make use of an important duality theorem in
+%network flow theory, stating that the capacity of a minimum $s$-$t$-cut
+%in a network, is equal to the maximum flow from the source to the sink.
\fixme{No anti-parallel edges. Or save that for the residual network
section.}
-\fixme{Whoops, a bit of a gap here.}
-
-Recall that we want to find the minimum $s$-$t$ cut in our network. When
-finding this minimum cut, we make use of an important duality theorem in
-network flow theory, stating that the capacity of a minimum $s$-$t$-cut
-in a network, is equal to the maximum flow from the source to the sink.
-\begin{theorem}[Max-flow min-cut theorem]
- If $f$ is a flow in a network $G = (V, E, c)$ with source $s$ and
- sink $t$, then the following is equivalent:
- \begin{enumerate}
- \item $f$ is a maximum flow in $G$.
- \item The residual network $G_f$ contains no augmenting paths.
- \item $\abs{f} = c(S, T)$ for some cut $(S, T)$ of $G$.
- \label{it:max_flow_min_cut}
- \end{enumerate}
-\end{theorem}
-See \cite{cormen2009introduction} for a proof, and remark that because
-of the inequality in \eqref{eq:flow_leq_cut}, the cut in statement
-\ref{it:max_flow_min_cut} is a minimum cut.
But how does this help us? We know that if we know the maximum flow
value, and we have an $s$-$t$-cut with capacity equal to the maximum
\subsection{Augmenting path algorithms}
The family of augmenting flow algorithms represent a popular approach to
the maximum flow problem. The idea is simply to look for paths from the
-source to the sink that can carry additional flow, and then send the
-maximum possible amount of flow along this path. When no such path
-exists anymore, no more flow can be sent from the source to the sink,
-and a maximum flow has been reached.
+source to the sink that can carry additional flow, a so-called
+augmenting path, and then send the maximum possible amount of flow along
+this path. When no such path exists anymore, no more flow can be sent
+from the source to the sink, and a maximum flow has been reached.
\subsubsection{Residual network}
When further discussing approaches to solving the max-flow problem we
with $c_f(u, v) > 0$. Since we can in $E_f$ at most have all the
original edges, and their reversals, we have $\abs{E_f} \leq 2 \abs{E}$.
+Note that there is ambiguity in the definition of the residual network
+in the case where the original network contains anti-parallel edges. One
+could avoid this by defining $c_f(u, v) = f(v, u) + c(u, v) - f(u, v)$
+instead, or as they do in \cite{cormen2009introduction}, disallow
+anti-parallel edges altogether. In any case it is not something we will
+have to think about in the implementation, since we will not actually
+construct the residual network.
+
+With the residual network defined, we are ready to formally present the
+max-flow min-cut theorem.
+\begin{theorem}[Max-flow min-cut theorem]
+ If $f$ is a flow in a network $G = (V, E, c)$ with source $s$ and
+ sink $t$, then the following is equivalent:
+ \begin{enumerate}
+ \item $f$ is a maximum flow in $G$.
+ \item The residual network $G_f$ contains no augmenting paths.
+ \item $\abs{f} = c(S, T)$ for some cut $(S, T)$ of $G$.
+ \label{it:max_flow_min_cut}
+ \end{enumerate}
+\end{theorem}
+See \cite{cormen2009introduction} for a proof, and remark that because
+of the inequality in \eqref{eq:flow_leq_cut}, the cut in statement
+\ref{it:max_flow_min_cut} is a minimum cut.
+
Figure \ref{fig:aug_flow} shows a simple network which already has five
units flowing from $s$ to $t$. The marked path is a possible augmenting
path, and note that it follows an edge in $E$ in the reverse direction,
network $G_f$}
\State $\alpha \gets \min\{c_f(u, v) : (u, v) \in p \}$
\ForAll{$(u, v) \in p$}
- \State $f(u, v) \mathrel{+}= \alpha$
+ \If{$(u, v) \in E$}
+ \State $f(u, v) \mathrel{+}= \Delta f$
+ \Else
+ \State $f(v, u) \mathrel{-}= \Delta f$
+ \Comment{Push flow back}
+ \EndIf
\EndFor
\EndWhile
\EndFunction
on, and described by the original author in \cite{dinitz2006dinitz}, is
a variant of the augmenting path algorithm. It maintains a distance
labeling $d(u)$ of the vertices $u \in V$ in the network, where $d(u)$
-is the shortest path from the $s$ to $u$ in the residual network. This
+is the shortest path from the $s$ to $u$ in the residual network. This
can be computed with a simple breadth-first search. The next step is to
construct a blocking flow $f'$, using only edges in $E_f' = \{ (u,v) \in
E_f : d(u) + 1 = d(v) \}$. The blocking flow is such that if we augment
\begin{equation}
\sum_{v \in V} f(v, u) \geq \sum_{v \in V} f(u, v),
\end{equation}
- i.e., for any node except the source and the sink, the
- flow into the node must greater or equal to the flow out of the
- node.
+ i.e., for any vertex except the source and the sink, the
+ flow into the vertex must greater or equal to the flow out of
+ the vertex.
\end{description}
\fixme{Vertex vs.\ node.}
-\fixme{Describe saturated in the $G_f$ section. And $N$.}
-For all vertices $u \in V$ we define the excess
+As in most of the cited push-relabel literature, we define $N =
+\abs{V}$, and for all vertices $u \in V$ we define the excess
\begin{equation}
e(u) = \sum_{v \in V} f(v, u) - \sum_{v \in V} f(u, v),
\end{equation}
-which represents the amount of flow which \emph{disappears} in node $u$.
-Equivalent to the preflow conservation constraint is stating that $e(u)
-\geq 0$ for all vertices $u \in V - \{s,t\}$.
+which represents the amount of flow which \emph{disappears} in vertex
+$u$. Equivalent to the preflow conservation constraint is stating that
+$e(u) \geq 0$ for all vertices $u \in V - \{s,t\}$.
The idea of the algorithm is to maintain a height map of the
-vertices of the network where connected nodes can not have a large
+vertices of the network where connected vertices can not have a large
height difference. Then we ``lift'' the source vertex to let as
many units as possible flow through the edges of the network towards the
sink. When a maximum preflow is reached, there will normally be excess
on the length of such a path.
A vertex $u$ is \emph{active} if $u \in V - \{s,t\}$, it has positive
-excess ($e(u) > 0$) and $d(u) < N$. These are the nodes we want to
+excess ($e(u) > 0$) and $d(u) < N$. These are the vertices we want to
operate on to increase the preflow.
\subsection{Basic operations}
Assuming that $f$ is a valid preflow, it is easy to verify that $f$
remains a valid preflow after running the push procedure on some
-admissible edge $(u, v)$. The capacity constraint is fulfilled since we
-at most increase the flow along $(u, v)$ with the residual capacity
-$c_f(u,v)$. The preflow constraint is fulfilled since the excess $e$
-increases for $v$, remains non-negative for $u$ and remains the same for
-all other vertices.
+admissible edge $(u, v)$.
+
+%The capacity constraint is fulfilled since we
+%at most increase the flow along $(u, v)$ with the residual capacity
+%$c_f(u,v)$. The preflow constraint is fulfilled since the excess $e$
+%increases for $v$, remains non-negative for $u$ and remains the same for
+%all other vertices.
The distance labels are not changed during the push procedure, however,
the residual network can change. The edge $(u, v)$ might disappear, and
\end{align}
and $d$ remains a valid labeling, even if the edge $(v, u)$ appears.
-\fixme{Change height $h$ to distance $d$.}
-
-\fixme{Operation < procedure.}
-
\begin{algorithm}
\begin{algorithmic}
\Function{Push}{$u$, $v$}
- \State $f_\text{aug} \gets \min(c_f(u, v), e(u))$
- \State $f(u, v) \mathrel{+}= f_\text{aug}$
- \State $e(u) \mathrel{-}= f_\text{aug}$
- \State $e(v) \mathrel{+}= f_\text{aug}$
+ \State $\Delta f \gets \min(c_f(u, v), e(u))$
+ \If{$(u, v) \in E$}
+ \State $f(u, v) \mathrel{+}= \Delta f$
+ \Else
+ \State $f(v, u) \mathrel{-}= \Delta f$
+ \Comment{Push flow back}
+ \EndIf
+ \Comment{Excess $e(u)$ and $e(v)$ will also change}
+ %\State $f(v, u) \mathrel{-}= f_\text{aug}$
+ %\State $e(u) \mathrel{-}= f_\text{aug}$
+ %\State $e(v) \mathrel{+}= f_\text{aug}$
\EndFunction
\end{algorithmic}
-\caption{\sf The push procedure of the Push-Relabel algorithm}
+\caption{
+ \sf The push procedure of the Push-Relabel algorithm.
+ \fixme{Here we have a problem with anti-parallel edges again, in the
+ if statement.}
+}
\label{alg:push}
\end{algorithm}
% \Call{Gap}{$u$}
% \Else
\If{there is a $v \in V$ such that $(u, v) \in E_f$}
- \State $d(u) \gets \min\{d(v), \; \forall v \in V : (u,v) \in E_f\} + 1$
+ \State $d(u) \gets \min\{d(v), \; \forall v \in V : (u,v) \in E_f\} + 1$
\Else
- \State $d(u) \gets N$
+ \State $d(u) \gets N$
+ \Comment{$u$ becomes inactive}
\EndIf
% \EndIf
\EndFunction
satisfied before the procedure was started.
\subsection{Putting it all together}
-
-\fixme{Should be clearer what is really happening, and especially when
- we are finished/what our goal is. That we are finished as soon as
- there are no more active vertices. And that how we get there does
- not matter as long as we follow our constraints.
-}
+These basic procedures are then applied to active nodes and admissible
+edges until we obtain our minimum cut. We will see later that when there
+are no more active nodes, we can extract the minimum cut from the
+network.
In the first phase of the algorithm we initialize a valid preflow and
distance labeling by saturating all edges out of the source $s$, and
then setting its distance label $d(s) = N$. We then run the push and
-relabel procedures when applicable until there are no more active nodes
-and a maximum preflow is obtained.
-
-\fixme{What is saturated?}
+relabel procedures when applicable until there are no more active
+vertices and a maximum preflow is obtained.
A vertex $u$ can only be successfully relabeled to obtain a new label if
the outgoing edges of $u$ in the residual network have changed since the
\begin{algorithmic}
\Function{Discharge}{$u$}
\ForAll{$v \in V$ such that $(u, v) \in E_f$}
- \If{$c_f(u, v) > 0$ and $d(u) = d(v) + 1$}
- \Call{Push}{$u$, $v$}
- \EndIf
+ \If{$c_f(u, v) > 0$ and $d(u) = d(v) + 1$}
+ \Call{Push}{$u$, $v$}
+ \EndIf
\EndFor
\If{$e(u) > 0$}
- \Call{Relabel}{$u$}
+ \Call{Relabel}{$u$}
\EndIf
\EndFunction
\end{algorithmic}
first phase is finished, and the following theorem allows us to do that.
\begin{theorem}[Cut identification]
Given a network $G = (V, E, c)$, assume that the first phase of
- the push-relabel algorithm has terminated and no more active nodes
- remain. Then there exists a $k \in \mathbb{N} \cap \left(0, N
- \right)$ such that there is no vertex with label $k$, and the vertex
- sets $S = \{ u \in V : d(u) > k\}$ and $T = V - S$ define a minimum
- cut $C = (S, T)$ in $G$.
+ the push-relabel algorithm has terminated and no more active
+ vertices remain. Then there exists a $k \in \mathbb{N} \cap \left(0,
+ N \right)$ such that there is no vertex with label $k$, and the
+ vertex sets $S = \{ u \in V : d(u) > k\}$ and $T = \{ u \in V : d(u)
+ < k \}$ define a minimum cut $C = (S, T)$ in $G$.
\label{thm:cut_identification}
\end{theorem}
\begin{proof}
- There are $N$ nodes, the source has label $N$ and the sink has label
- $0$, and the $N - 2$ remaining vertices can not occupy all the $N-1$
- labels in $\{1, \ldots, N-1\}$, so there must exist an $k$ as
+ There are $N$ vertices, the source has label $N$ and the sink has
+ label $0$, and the $N - 2$ remaining vertices can not occupy all the
+ $N-1$ labels in $\{1, \ldots, N-1\}$, so there must exist an $k$ as
described.
- As no vertex has label $k$, we can write $T = \{ u \in V : d(u) >
- k\}$.
-
- Assume there was an edge $(u, v) \in E_f$ such that $u \in S$ and $v
- \in T$. From the construction of $S$ and $T$, we would have $d(v)
- \leq d(u) + 2$, which contradicts the labeling constraint, so no
- such non-saturated edge from $S$ to $T$ can exist.
-
- From the construction of $E_f$ we now know that all edges in $E$
- from $S$ to $T$ are saturated, and all edges from $T$ to $S$ have no
- flow. This means that the capacity of the cut is equal to the flow
- through the cut, i.e.\ $c(S, T) = f(S, T)$.
+ These can be no edge $(u, v) \in E_f$ such that $u \in S$ and $v \in
+ T$, as this would imply $d(v) \leq d(u) + 2$ which contradicts the
+ labeling constraint. From the construction of $E_f$ we now know that
+ all edges in $E$ from $S$ to $T$ are saturated, and all edges from
+ $T$ to $S$ have no flow. This means that the capacity of the cut is
+ equal to the flow through the cut, i.e.\ $c(S, T) = f(S, T)$.
Since the first phase of the algorithm has terminated, there can be
no active vertices, and therefore no excess in $T$, except for the
always be a gap at label $k = N - 1$ such that we can construct our cut
by taking $S = \{ u \in V : d(u) \geq N \}$.
-\fixme{Sketch of proof, could be nicer, shorter (split up?) and more
-rigorous maybe.}
-
\subsection{Complexity}
In their original article \cite{goldberg1988new}, Goldberg and Tarjan
\label{alg:gap}
\end{algorithm}
-\fixme{This could be a lemma with a proof maybe? Refer to Derigs and
-Meyer.}
-
But why does this work? The only thing we need to verify is that given a
network with a valid preflow and a valid labeling, the gap relabeling
procedure will not change the validity of these two things.
Hence, both the preflow $f$ and distance labeling $d$ are valid.
- \fixme{A bit long, could be more compact since it is not really a
- very interesting proof? (And it's not really a lemma either?)}
+ \fixme{A bit too long compared to its interestingness/importance.}
\end{proof}
When running the push-relabel algorithm with the gap heuristic, we can
sets $S = \{ u \in V : d(u) \geq N\}$ and $T = V - S$ form a minimum cut
of the network.
-\fixme{Ugh, what a mess. Lemma maybe?}
-
\subsection{Parametric push-relabel algorithm}
Now we have an algorithm for finding a minimum $s$-$t$-cut in a network,
so let's return to the network constructed in Section
Through this procedure we have easily created the network for $\lambda =
k-1$, and the distance labels remain the same. As these labels always
-increase monotonically, we have a head start compared to if we had reset
-the flow and labels.
+increase monotonically, we have a head start compared to the case where
+we reset the flow and labels.
\subsubsection{Output image construction}
\fixme{More precise statement than ``stack on top of each other''}
Consider two subsequent runs of the push-relabel algorithm, for labels
-$\lambda = k$ and $\lambda = k-1$ ending with distance labels $d^k$ and
-$d^{k-1}$ respectively. We already know that the distance labels $d$ are
-monotonically increasing. This means that the set $\{ u \in V : d(u)
-\geq N \}$ is increasing in size, more precisely, we have the inclusion
+$\lambda$ and $\lambda - 1$ ending with distance labels $d^\lambda$ and
+$d^{\lambda-1}$ respectively. We already know that the distance labels
+$d$ are monotonically increasing. This means that the set $\{ u \in V :
+d(u) \geq N \}$ is increasing in size, more precisely, we have the
+inclusion
\begin{equation}
- \{ u \in V : d^k(u) \geq N \} \subseteq \{ u \in V : d^{k-1}(u) \geq
- N \}
+ \{ u \in V : d^\lambda(u) \geq N \} \subseteq \{ u \in V :
+ d^{\lambda-1}(u) \geq N \}
\end{equation}
We then construct our output image $u$ by giving each pixel the value
separately, and applying the algorithm recursively, at each time halving
the $\lambda$ interval until we have the value of every pixel.
+See \cite{goldfarb2009parametric} and \fixme{hochbaum} and \fixme{one
+more} for more information.
+
\subsection{Implementation}
A \cpp\ implementation can be found in appendix
\ref{app:c++implementation}. It uses the open computer vision library
when a gap occurs. This is done by keeping track of how many vertices
exist with each label.
-\subsection{Bleep bloop}
-
-Initially proposed in \cite{goldberg1988new} where one can also find
-proof that the algorithm maintains a valid labeling and that it
-terminates at at maximal flow. Also has the lemma that if you have a
-preflow, then there is no path from $s$ to $t$ in the residual graph.
-But what is a preflow? Also, the distance label never decreases. Also
-propose the global relabeling heuristic.
-
-Cherkassky and Goldberg present some good implementation tips in
-\cite{cherkassky1997implementing}, for example the global and gap
-relabeling heuristics. Also has OK presentations of the different ways
-of choosing the order of discharge operations. In the results I could
-include some results with and without the heuristics.
-
-\cite{ahuja1997computational} has some good performance analysis.
-
-\cite{derigs1989implementing} is also a good source for the different
-heuristics. And also on the neighbor list that should not be reset after
-each discharge (should try to implement this again, and reset at every
-relabel!). Also has some semi-usable notes on how the minimal cut is
-found after phase 1 of the algorithm is finished. Note that in this
-article the gap relabeling heuristic is also called RELABEL-GLOBAL.
-