212 lines
5.4 KiB
TeX
Raw Normal View History

2022-11-21 22:01:21 -08:00
\section{Residual Graphs}
As our network gets bigger, finding a maximum flow by hand becomes much more difficult. It will be convenient to have an algorithm that finds a maximal flow in any network.
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
\vspace{1ex}
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
The first thing we'll need to construct such an algorithm is a \textit{residual graph}.
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
\vspace{2ex}
\hrule
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
\begin{center}
\begin{minipage}[t]{0.48\textwidth}
We'll start with the following network and flow:
\begin{center}
\begin{tikzpicture}[node distance = 20mm]
% Nodes
\begin{scope}[layer = nodes]
\node[main] (S) {$S$};
\node[main] (A) [above right of = S] {$A$};
\node[main] (B) [below right of = S] {$B$};
\node[main] (T) [above right of = B] {$T$};
\end{scope}
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
% Edges
\draw[->]
(S) edge node[label] {$1$} (A)
(A) edge node[label] {$3$} (T)
(B) edge node[label] {$2$} (A)
(S) edge node[label] {$2$} (B)
(B) edge node[label] {$1$} (T)
;
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
% Flow
\draw[path]
(S) -- node[above left, flow] {$(1)$} (A)
-- node[above right, flow] {$(1)$} (T)
;
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
\end{tikzpicture}
2022-11-13 13:03:14 -08:00
\end{center}
\end{minipage}
2022-11-21 22:01:21 -08:00
\hfill
\begin{minipage}[t]{0.48\textwidth}
First, we'll copy all nodes and \say{unused} edges:
\begin{center}
\begin{tikzpicture}[node distance = 20mm]
% Nodes
\begin{scope}[layer = nodes]
\node[main] (S) {$S$};
\node[main] (A) [above right of = S] {$A$};
\node[main] (B) [below right of = S] {$B$};
\node[main] (T) [above right of = B] {$T$};
\end{scope}
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
% Edges
\draw[->]
(B) edge node[label] {$2$} (A)
(S) edge node[label] {$2$} (B)
(B) edge node[label] {$1$} (T)
;
\end{tikzpicture}
\end{center}
\end{minipage}
\end{center}
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
\hrule
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
\begin{center}
\begin{minipage}[t]{0.48\textwidth}
Then, we'll add the unused capacity of \say{used} edges: (Note that $3 - 1 = 2$)
\begin{center}
\begin{tikzpicture}[node distance = 20mm]
% Nodes
\begin{scope}[layer = nodes]
\node[main] (S) {$S$};
\node[main] (A) [above right of = S] {$A$};
\node[main] (B) [below right of = S] {$B$};
\node[main] (T) [above right of = B] {$T$};
\end{scope}
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
% Edges
\draw[->]
(A) edge node[label] {$2$} (T)
(B) edge node[label] {$2$} (A)
(S) edge node[label] {$2$} (B)
(B) edge node[label] {$1$} (T)
;
\end{tikzpicture}
\end{center}
\end{minipage}
\hfill
\begin{minipage}[t]{0.48\textwidth}
Finally, we'll add \say{used} capacity as edges in the opposite direction:
\begin{center}
\begin{tikzpicture}[node distance = 20mm]
% Nodes
\begin{scope}[layer = nodes]
\node[main] (S) {$S$};
\node[main] (A) [above right of = S] {$A$};
\node[main] (B) [below right of = S] {$B$};
\node[main] (T) [above right of = B] {$T$};
\end{scope}
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
% Edges
\draw[->]
(A) edge node[label] {$1$} (S)
(T) edge [bend right] node[label] {$1$} (A)
(A) edge [bend right] node[label] {$2$} (T)
(B) edge node[label] {$2$} (A)
(S) edge node[label] {$2$} (B)
(B) edge node[label] {$1$} (T)
;
\end{tikzpicture}
\end{center}
This graph is the residual of the original flow.
\end{minipage}
\end{center}
\hrule
\vspace{3ex}
You can think of the residual graph as a \say{list of possible changes} to the original flow. \\
There are two ways we can change a flow:
\begin{itemize}
\item We can add flow along a path
\item We can remove flow along another path
\end{itemize}
\vspace{1ex}
A residual graph captures both of these actions, showing us where we can add flow (forward edges) and where we can remove it (reverse edges). Note that \say{removing} flow along an edge is equivalent to adding flow in the opposite direction.
\vfill
\pagebreak
\problem{}<FindResidual>
Construct the residual of this flow.
\begin{center}
\begin{tikzpicture}[node distance = 25mm]
% Nodes
\begin{scope}[layer = nodes]
\node[main] (S) {$S$};
\node[main] (A) [above right of = S] {$A$};
\node[main] (B) [below right of = S] {$B$};
\node[main] (T) [above right of = B] {$T$};
\end{scope}
% Edges
\draw[->]
(S) edge node[label] {$2$} (A)
(A) edge node[label] {$1$} (T)
(A) edge node[label] {$3$} (B)
(S) edge node[label] {$1$} (B)
(B) edge node[label] {$2$} (T)
;
% Flow
\draw[path]
(S)
-- node[above left, flow] {$(2)$} (A)
-- node[left, flow] {$(2)$} (B)
-- node[below right, flow] {$(2)$} (T)
;
\end{tikzpicture}
\end{center}
\begin{solution}
2022-11-13 13:03:14 -08:00
\begin{center}
\begin{tikzpicture}[node distance = 25mm]
% Nodes
\begin{scope}[layer = nodes]
\node[main] (S) {$S$};
\node[main] (A) [above right of = S] {$A$};
\node[main] (B) [below right of = S] {$B$};
\node[main] (T) [above right of = B] {$T$};
\end{scope}
% Edges
\draw[->]
2022-11-21 22:01:21 -08:00
(A) edge node[label] {$2$} (S)
2022-11-13 13:03:14 -08:00
(A) edge node[label] {$1$} (T)
2022-11-21 22:01:21 -08:00
(A) edge[out=295,in=65] node[label] {$1$} (B)
(B) edge[out=115,in=245] node[label] {$2$} (A)
2022-11-13 13:03:14 -08:00
(S) edge node[label] {$1$} (B)
2022-11-21 22:01:21 -08:00
(T) edge node[label] {$2$} (B)
2022-11-13 13:03:14 -08:00
;
\end{tikzpicture}
\end{center}
2022-11-21 22:01:21 -08:00
\end{solution}
\vfill
\problem{}
Is the flow in \ref{FindResidual} maximal? \\
If it isn't, find a maximal flow. \\
\hint{Look at the residual graph. Can we add flow along another path?}
\vfill
\pagebreak
\problem{}
Show that...
\begin{enumerate}
\item A maximal flow exists in every network with integral\footnotemark{} edge weights.
\item Every edge in this flow carries an integral amount of flow
\end{enumerate}
\footnotetext{Integral = \say{integer} as an adjective.}
2022-11-13 13:03:14 -08:00
2022-11-21 22:01:21 -08:00
\vfill
\pagebreak