We now have all the tools we need to construct an algorithm that finds a maximal flow. \\
It works as follows:
\begin{enumerate}
\item[\texttt{00}] Take a weighted directed graph $G$.
\item[\texttt{01}] Find any flow $F$ in $G$
\item[\texttt{02}] Calculate $R$, the residual of $F$.
\item[\texttt{03}] ~~~~If $S$ and $T$ are not connected in $R$, $F$ is a maximal flow. \texttt{HALT}.
\item[\texttt{04}] Otherwise, find another flow $F_0$ in $R$.
\item[\texttt{05}] Add $F_0$ to $F$
\item[\texttt{06}]\texttt{GOTO 02}
\end{enumerate}
\problem{}
Run the Ford-Fulkerson algorithm on the following graph. \\
There is extra space on the next page.
\begin{center}
\begin{tikzpicture}
% Nodes
\begin{scope}[layer = nodes]
\node[main] (S) at (-5mm, 0mm) {$S$};
\node[main] (A) at (20mm, 20mm) {$A$};
\node[main] (B) at (20mm, 0mm) {$B$};
\node[main] (C) at (20mm, -20mm) {$C$};
\node[main] (D) at (50mm, 20mm) {$D$};
\node[main] (E) at (50mm, 0mm) {$E$};
\node[main] (F) at (50mm, -20mm) {$F$};
\node[main] (T) at (75mm, 0mm) {$T$};
\end{scope}
% Edges
\draw[->]
(S) edge node[label] {$8$} (A)
(S) edge node[label] {$7$} (B)
(S) edge node[label] {$4$} (C)
(A) edge node[label] {$2$} (B)
(B) edge node[label] {$5$} (C)
(A) edge node[label] {$3$} (D)
(A) edge node[label] {$9$} (E)
(B) edge node[label] {$6$} (E)
(C) edge node[label] {$7$} (E)
(C) edge node[label] {$2$} (F)
(E) edge node[label] {$3$} (D)
(E) edge node[label] {$4$} (F)
(D) edge node[label] {$9$} (T)
(E) edge node[label] {$5$} (T)
(F) edge node[label] {$8$} (T)
;
\end{tikzpicture}
\end{center}
\begin{solution}
The maximum flow is $17$.
\end{solution}
\vspace{5mm}
\pagebreak
\begin{center}
\begin{tikzpicture}
% Nodes
\begin{scope}[layer = nodes]
\node[main] (S) at (-5mm, 0mm) {$S$};
\node[main] (A) at (20mm, 20mm) {$A$};
\node[main] (B) at (20mm, 0mm) {$B$};
\node[main] (C) at (20mm, -20mm) {$C$};
\node[main] (D) at (50mm, 20mm) {$D$};
\node[main] (E) at (50mm, 0mm) {$E$};
\node[main] (F) at (50mm, -20mm) {$F$};
\node[main] (T) at (75mm, 0mm) {$T$};
\end{scope}
% Edges
\draw[->]
(S) edge node[label] {$8$} (A)
(S) edge node[label] {$7$} (B)
(S) edge node[label] {$4$} (C)
(A) edge node[label] {$2$} (B)
(B) edge node[label] {$5$} (C)
(A) edge node[label] {$3$} (D)
(A) edge node[label] {$9$} (E)
(B) edge node[label] {$6$} (E)
(C) edge node[label] {$7$} (E)
(C) edge node[label] {$2$} (F)
(E) edge node[label] {$3$} (D)
(E) edge node[label] {$4$} (F)
(D) edge node[label] {$9$} (T)
(E) edge node[label] {$5$} (T)
(F) edge node[label] {$8$} (T)
;
\end{tikzpicture}
\end{center}
\vfill
\pagebreak
\problem{}
You are given a large network. How would you quickly find an upper bound for the number of iterations the Ford-Fulkerson algorithm will need to find a maximum flow?
\begin{solution}
Each iteration adds at least one unit of flow. So, we will find a maximum flow in at most $\min(\text{flow out of } S,~\text{flow into } T)$ iterations.
\vspace{2ex}
A simpler answer could only count the flow on $S$.