Added "applications" section
This commit is contained in:
		@ -6,59 +6,8 @@
 | 
				
			|||||||
	solutions
 | 
						solutions
 | 
				
			||||||
]{ormc_handout}
 | 
					]{ormc_handout}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\usepackage{subfiles}
 | 
					 | 
				
			||||||
\usetikzlibrary{arrows.meta}
 | 
					 | 
				
			||||||
\usetikzlibrary{shapes.geometric}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
% We put nodes in a separate layer, so we can
 | 
					\input{tikxset}
 | 
				
			||||||
% slightly overlap with paths for a perfect fit
 | 
					 | 
				
			||||||
\pgfdeclarelayer{nodes}
 | 
					 | 
				
			||||||
\pgfdeclarelayer{path}
 | 
					 | 
				
			||||||
\pgfsetlayers{main,nodes}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
% Layer settings
 | 
					 | 
				
			||||||
\tikzset{
 | 
					 | 
				
			||||||
	% Layer hack, lets us write
 | 
					 | 
				
			||||||
	% later = * in scopes.
 | 
					 | 
				
			||||||
	layer/.style = {
 | 
					 | 
				
			||||||
		execute at begin scope={\pgfonlayer{#1}},
 | 
					 | 
				
			||||||
		execute at end scope={\endpgfonlayer}
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	%
 | 
					 | 
				
			||||||
	% Arrowhead tweaks
 | 
					 | 
				
			||||||
	>={Latex[ width=2mm, length=2mm ]},
 | 
					 | 
				
			||||||
	label/.style = {
 | 
					 | 
				
			||||||
		circle,
 | 
					 | 
				
			||||||
		% For automatic red background in solutions
 | 
					 | 
				
			||||||
		fill = \ORMCbgcolor,
 | 
					 | 
				
			||||||
		draw = none
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	%
 | 
					 | 
				
			||||||
	% Nodes
 | 
					 | 
				
			||||||
	main/.style = {
 | 
					 | 
				
			||||||
		draw,
 | 
					 | 
				
			||||||
		circle,
 | 
					 | 
				
			||||||
		fill = white
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	%
 | 
					 | 
				
			||||||
	% Flow annotations
 | 
					 | 
				
			||||||
	flow/.style = {
 | 
					 | 
				
			||||||
		opacity = 1,
 | 
					 | 
				
			||||||
		thin,
 | 
					 | 
				
			||||||
		inner xsep = 2.5mm,
 | 
					 | 
				
			||||||
		inner ysep = 2.5mm
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	%
 | 
					 | 
				
			||||||
	% Paths
 | 
					 | 
				
			||||||
	path/.style = {
 | 
					 | 
				
			||||||
		line width = 4mm,
 | 
					 | 
				
			||||||
		draw = black,
 | 
					 | 
				
			||||||
		% Lengthen paths so they're
 | 
					 | 
				
			||||||
		% completely under nodes.
 | 
					 | 
				
			||||||
		line cap = rect,
 | 
					 | 
				
			||||||
		opacity = 0.3
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
\begin{document}
 | 
					\begin{document}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -69,109 +18,14 @@
 | 
				
			|||||||
		{Prepared by Mark on \today}
 | 
							{Prepared by Mark on \today}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\subfile{parts/00 review}
 | 
						\input{parts/00 review}
 | 
				
			||||||
	\subfile{parts/01 flow}
 | 
						\input{parts/01 flow}
 | 
				
			||||||
	\subfile{parts/02 residual}
 | 
						\input{parts/02 residual}
 | 
				
			||||||
	\subfile{parts/03 fulkerson}
 | 
						\input{parts/03 fulkerson}
 | 
				
			||||||
 | 
						\input{parts/04 applications}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\problem{Maximum Cardinality Matching}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	A \textit{matching} is a subset of edges in a bipartite graph. Nodes in a matching must not have more than one edge connected to them. \\
 | 
					 | 
				
			||||||
	A matching is \textit{maximal} if it has more edges than any other matching.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vspace{5mm}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\begin{minipage}[t]{0.48\textwidth}
 | 
					 | 
				
			||||||
	\begin{center}
 | 
					 | 
				
			||||||
		Initial Graph \\
 | 
					 | 
				
			||||||
		\vspace{2mm}
 | 
					 | 
				
			||||||
		\begin{tikzpicture}
 | 
					 | 
				
			||||||
			% Nodes
 | 
					 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
					 | 
				
			||||||
				\node[main] (A1) at (0mm, 24mm) {};
 | 
					 | 
				
			||||||
				\node[main] (A2) at (0mm, 18mm) {};
 | 
					 | 
				
			||||||
				\node[main] (A3) at (0mm, 12mm) {};
 | 
					 | 
				
			||||||
				\node[main] (A4) at (0mm, 6mm) {};
 | 
					 | 
				
			||||||
				\node[main] (A5) at (0mm, 0mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B1) at (20mm, 24mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B2) at (20mm, 18mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B3) at (20mm, 12mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B4) at (20mm, 6mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B5) at (20mm, 0mm) {};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Edges
 | 
					 | 
				
			||||||
			\draw
 | 
					 | 
				
			||||||
				(A1) edge (B2)
 | 
					 | 
				
			||||||
				(A1) edge (B3)
 | 
					 | 
				
			||||||
				(A2) edge (B1)
 | 
					 | 
				
			||||||
				(A2) edge (B4)
 | 
					 | 
				
			||||||
				(A4) edge (B3)
 | 
					 | 
				
			||||||
				(A2) edge (B3)
 | 
					 | 
				
			||||||
				(A5) edge (B3)
 | 
					 | 
				
			||||||
				(A5) edge (B4)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
	\hfill
 | 
					 | 
				
			||||||
	\begin{minipage}[t]{0.48\textwidth}
 | 
					 | 
				
			||||||
	\begin{center}
 | 
					 | 
				
			||||||
		Maximal Matching \\
 | 
					 | 
				
			||||||
		\vspace{2mm}
 | 
					 | 
				
			||||||
		\begin{tikzpicture}
 | 
					 | 
				
			||||||
			% Nodes
 | 
					 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
					 | 
				
			||||||
				\node[main] (A1) at (0mm, 24mm) {};
 | 
					 | 
				
			||||||
				\node[main] (A2) at (0mm, 18mm) {};
 | 
					 | 
				
			||||||
				\node[main] (A3) at (0mm, 12mm) {};
 | 
					 | 
				
			||||||
				\node[main] (A4) at (0mm, 6mm) {};
 | 
					 | 
				
			||||||
				\node[main] (A5) at (0mm, 0mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B1) at (20mm, 24mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B2) at (20mm, 18mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B3) at (20mm, 12mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B4) at (20mm, 6mm) {};
 | 
					 | 
				
			||||||
				\node[main] (B5) at (20mm, 0mm) {};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Edges
 | 
					 | 
				
			||||||
			\draw[opacity = 0.4]
 | 
					 | 
				
			||||||
				(A1) edge (B2)
 | 
					 | 
				
			||||||
				(A1) edge (B3)
 | 
					 | 
				
			||||||
				(A2) edge (B1)
 | 
					 | 
				
			||||||
				(A2) edge (B4)
 | 
					 | 
				
			||||||
				(A4) edge (B3)
 | 
					 | 
				
			||||||
				(A4) edge (B3)
 | 
					 | 
				
			||||||
				(A5) edge (B3)
 | 
					 | 
				
			||||||
				(A5) edge (B4)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
			\draw
 | 
					 | 
				
			||||||
				(A1) edge (B2)
 | 
					 | 
				
			||||||
				(A2) edge (B1)
 | 
					 | 
				
			||||||
				(A4) edge (B3)
 | 
					 | 
				
			||||||
				(A5) edge (B4)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vspace{5mm}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	Devise an algorithm to find a maximal matching in any bipartite graph. \\
 | 
					 | 
				
			||||||
	Find an upper bound for its runtime.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\begin{solution}
 | 
					 | 
				
			||||||
		Turn this into a maximum flow problem and use FF. \\
 | 
					 | 
				
			||||||
		Connect a node $S$ to all nodes in the left group and a node $T$ to all nodes in the right group. All edges have capacity 1.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		\vspace{2ex}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		Just like FF, this algorithm will take at most $\min(\# \text{ left nodes}, \# \text{ right nodes})$ iterations.
 | 
					 | 
				
			||||||
	\end{solution}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
\end{document}
 | 
					\end{document}
 | 
				
			||||||
@ -1,91 +1,84 @@
 | 
				
			|||||||
\documentclass[../main.tex]{subfiles}
 | 
					\section{Review}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\definition{}
 | 
				
			||||||
 | 
					A \textit{graph} consists of a set of \textit{nodes} $\{A, B, ...\}$ and a set of edges $\{ (A,B), (A,C), ...\}$ connecting them.
 | 
				
			||||||
 | 
					A \textit{directed graph} is a graph where edges have direction. In such a graph, $(A, B)$ and $(B, A)$ are distinct edges.
 | 
				
			||||||
 | 
					A \textit{weighted graph} is a graph that features weights on its edges. \\
 | 
				
			||||||
 | 
					A weighted directed graph is shown below.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\begin{document}
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}[node distance = 20mm]
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}
 | 
				
			||||||
 | 
								\node[main] (A) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) [below right of = A] {$B$};
 | 
				
			||||||
 | 
								\node[main] (C) [below left of = A] {$C$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\section{Review}
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(A) edge[bend right] node[label] {$4$} (B)
 | 
				
			||||||
 | 
								(B) edge node[label] {$2$} (C)
 | 
				
			||||||
 | 
								(C) edge node[label] {$2$} (A)
 | 
				
			||||||
 | 
								(B) edge[bend right] node[label] {$1$} (A)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\definition{}
 | 
					\vfill
 | 
				
			||||||
	A \textit{graph} consists of a set of \textit{nodes} $\{A, B, ...\}$ and a set of edges $\{ (A,B), (A,C), ...\}$ connecting them.
 | 
					 | 
				
			||||||
	A \textit{directed graph} is a graph where edges have direction. In such a graph, $(A, B)$ and $(B, A)$ are distinct edges.
 | 
					 | 
				
			||||||
	A \textit{weighted graph} is a graph that features weights on its edges. \\
 | 
					 | 
				
			||||||
	A weighted directed graph is shown below.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{center}
 | 
					\definition{}
 | 
				
			||||||
		\begin{tikzpicture}[node distance = 20mm]
 | 
					We say a graph is \textit{bipartite} if its nodes can be split into two groups $L$ and $R$ so that no two nodes in the same group are connected by an edge. \\
 | 
				
			||||||
			% Nodes
 | 
					The following graph is bipartite:
 | 
				
			||||||
			\begin{scope}
 | 
					 | 
				
			||||||
				\node[main] (A) {$A$};
 | 
					 | 
				
			||||||
				\node[main] (B) [below right of = A] {$B$};
 | 
					 | 
				
			||||||
				\node[main] (C) [below left of = A] {$C$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			% Edges
 | 
					\begin{center}
 | 
				
			||||||
			\draw[->]
 | 
						\begin{tikzpicture}
 | 
				
			||||||
				(A) edge[bend right] node[label] {$4$} (B)
 | 
							% Nodes
 | 
				
			||||||
				(B) edge node[label] {$2$} (C)
 | 
							\begin{scope}
 | 
				
			||||||
				(C) edge node[label] {$2$} (A)
 | 
								\node[main] (A) at (0mm, 0mm) {$A$};
 | 
				
			||||||
				(B) edge[bend right] node[label] {$1$} (A)
 | 
								\node[main] (B) at (0mm, -10mm) {$B$};
 | 
				
			||||||
			;
 | 
								\node[main] (C) at (0mm, -20mm) {$C$};
 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vfill
 | 
								\node[main] (D) at (20mm, 0mm) {$D$};
 | 
				
			||||||
 | 
								\node[main] (E) at (20mm, -10mm) {$E$};
 | 
				
			||||||
 | 
								\node[main] (F) at (20mm, -20mm) {$F$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\definition{}
 | 
							% Edges
 | 
				
			||||||
	We say a graph is \textit{bipartite} if its nodes can be split into two groups $L$ and $R$ so that no two nodes in the same group are connected by an edge. \\
 | 
							\draw
 | 
				
			||||||
	The following graph is bipartite:
 | 
								(A) edge (D)
 | 
				
			||||||
 | 
								(A) edge (E)
 | 
				
			||||||
 | 
								(B) edge (F)
 | 
				
			||||||
 | 
								(C) edge (E)
 | 
				
			||||||
 | 
								(C) edge (D)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{center}
 | 
					\vfill
 | 
				
			||||||
		\begin{tikzpicture}
 | 
					 | 
				
			||||||
			% Nodes
 | 
					 | 
				
			||||||
			\begin{scope}
 | 
					 | 
				
			||||||
				\node[main] (A) at (0mm, 0mm) {$A$};
 | 
					 | 
				
			||||||
				\node[main] (B) at (0mm, -10mm) {$B$};
 | 
					 | 
				
			||||||
				\node[main] (C) at (0mm, -20mm) {$C$};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				\node[main] (D) at (20mm, 0mm) {$D$};
 | 
					\definition{}
 | 
				
			||||||
				\node[main] (E) at (20mm, -10mm) {$E$};
 | 
					We say two nodes $A$ ane $B$ are \textit{connected} if we can reach $A$ from $B$ and $B$ from $A$ by walking along (possibly directed) edges. We say a graph is connected if all its nodes are connected to each other.\\
 | 
				
			||||||
				\node[main] (F) at (20mm, -20mm) {$F$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			% Edges
 | 
					The bipartite graph above and the directed graph below are not connected.
 | 
				
			||||||
			\draw
 | 
					 | 
				
			||||||
				(A) edge (D)
 | 
					 | 
				
			||||||
				(A) edge (E)
 | 
					 | 
				
			||||||
				(B) edge (F)
 | 
					 | 
				
			||||||
				(C) edge (E)
 | 
					 | 
				
			||||||
				(C) edge (D)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vfill
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}[node distance = 20mm]
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}
 | 
				
			||||||
 | 
								\node[main] (A) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) [below right of = A] {$B$};
 | 
				
			||||||
 | 
								\node[main] (C) [below left of = A] {$C$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\definition{}
 | 
							% Edges
 | 
				
			||||||
	We say two nodes $A$ ane $B$ are \textit{connected} if we can reach $A$ from $B$ and $B$ from $A$ by walking along (possibly directed) edges. We say a graph is connected if all its nodes are connected to each other.\\
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(A) edge[bend right] (B)
 | 
				
			||||||
 | 
								(B) edge[bend right] (A)
 | 
				
			||||||
 | 
								(B) edge (C)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	The bipartite graph above and the directed graph below are not connected.
 | 
					\vfill
 | 
				
			||||||
 | 
					\pagebreak
 | 
				
			||||||
	\begin{center}
 | 
					 | 
				
			||||||
		\begin{tikzpicture}[node distance = 20mm]
 | 
					 | 
				
			||||||
			% Nodes
 | 
					 | 
				
			||||||
			\begin{scope}
 | 
					 | 
				
			||||||
				\node[main] (A) {$A$};
 | 
					 | 
				
			||||||
				\node[main] (B) [below right of = A] {$B$};
 | 
					 | 
				
			||||||
				\node[main] (C) [below left of = A] {$C$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Edges
 | 
					 | 
				
			||||||
			\draw[->]
 | 
					 | 
				
			||||||
				(A) edge[bend right] (B)
 | 
					 | 
				
			||||||
				(B) edge[bend right] (A)
 | 
					 | 
				
			||||||
				(B) edge (C)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vfill
 | 
					 | 
				
			||||||
	\pagebreak
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
\end{document}
 | 
					 | 
				
			||||||
@ -1,363 +1,356 @@
 | 
				
			|||||||
\documentclass[../main.tex]{subfiles}
 | 
					\section{Network Flow}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\generic{Networks}
 | 
				
			||||||
 | 
					Say have a network: a sequence of pipes, a set of cities and highways, an electrical circuit, server infrastructure, etc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\begin{document}
 | 
					\vspace{1ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\section{Network Flow}
 | 
					We'll represent our network with a connected directed weighted graph. If we take a city, edges will be highways and cities will be nodes. There are a few conditions for a valid network graph:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\generic{Networks}
 | 
					\begin{itemize}
 | 
				
			||||||
	Say have a network: a sequence of pipes, a set of cities and highways, an electrical circuit, server infrastructure, etc.
 | 
						\item The weight of each edge represents its capacity, the number of lanes in the highway.
 | 
				
			||||||
 | 
						\item Edge capacities are always positive integers.\hspace{-0.5ex}\footnotemark{}
 | 
				
			||||||
 | 
						\item Node $S$ is a \textit{source}: it produces flow.
 | 
				
			||||||
 | 
						\item Node $T$ is a \textit{sink}: it consumes flow.
 | 
				
			||||||
 | 
						\item All other nodes \textit{conserve} flow. In other words, the sum of flow coming in must equal the sum of flow going out.
 | 
				
			||||||
 | 
					\end{itemize}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vspace{1ex}
 | 
					\footnotetext{An edge with capacity zero is equivalent to an edge that does not exist; An edge with negative capacity is equivalent to an edge in the opposite direction.}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	We'll represent our network with a connected directed weighted graph. If we take a city, edges will be highways and cities will be nodes. There are a few conditions for a valid network graph:
 | 
					Here is an example of a such a graph:
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
				
			||||||
 | 
								\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
				
			||||||
 | 
								\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(S) edge node[label] {$1$} (A)
 | 
				
			||||||
 | 
								(A) edge node[label] {$4$} (T)
 | 
				
			||||||
 | 
								(B) edge node[label] {$2$} (A)
 | 
				
			||||||
 | 
								(S) edge node[label] {$2$} (B)
 | 
				
			||||||
 | 
								(B) edge node[label] {$1$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\hrule{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\generic{Flow}
 | 
				
			||||||
 | 
					In our city example, cars represent \textit{flow}. Let's send one unit of cars along the topmost highway:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{minipage}{0.33\textwidth}
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
				
			||||||
 | 
								\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
				
			||||||
 | 
								\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(S) edge node[label] {$1$} (A)
 | 
				
			||||||
 | 
								(A) edge node[label] {$4$} (T)
 | 
				
			||||||
 | 
								(B) edge node[label] {$2$} (A)
 | 
				
			||||||
 | 
								(S) edge node[label] {$2$} (B)
 | 
				
			||||||
 | 
								(B) edge node[label] {$1$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Flow
 | 
				
			||||||
 | 
							\draw[path]
 | 
				
			||||||
 | 
								(S) -- node[above left, flow] {$(1)$} (A)
 | 
				
			||||||
 | 
								-- node[above right, flow] {$(1)$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					\begin{minipage}{0.65\textwidth}
 | 
				
			||||||
 | 
						There are a few things to notice here:
 | 
				
			||||||
	\begin{itemize}
 | 
						\begin{itemize}
 | 
				
			||||||
		\item The weight of each edge represents its capacity, the number of lanes in the highway.
 | 
							\item Highlighted edges carry flow.
 | 
				
			||||||
		\item Edge capacities are always positive integers.\hspace{-0.5ex}\footnotemark{}
 | 
							\item Numbers in parentheses tell us how much flow each edge carries.
 | 
				
			||||||
		\item Node $S$ is a \textit{source}: it produces flow.
 | 
							\item The flow along an edge is always positive or zero.
 | 
				
			||||||
		\item Node $T$ is a \textit{sink}: it consumes flow.
 | 
							\item Flow comes from $S$ and goes towards $T$.
 | 
				
			||||||
		\item All other nodes \textit{conserve} flow. In other words, the sum of flow coming in must equal the sum of flow going out.
 | 
							\item Flow is conserved: all flow produced by $S$ enters $T$.
 | 
				
			||||||
	\end{itemize}
 | 
						\end{itemize}
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\footnotetext{An edge with capacity zero is equivalent to an edge that does not exist; An edge with negative capacity is equivalent to an edge in the opposite direction.}
 | 
					\vspace{1ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Here is an example of a such a graph:
 | 
					The \textit{magnitude} of a flow\footnotemark{} is the number of \say{flow-units} that go from $S$ to $T$. \\
 | 
				
			||||||
	\begin{center}
 | 
					 | 
				
			||||||
		\begin{tikzpicture}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			% Nodes
 | 
					We are interested in the \textit{maximum flow} through this network: what is the greatest amount of flow we can push from $S$ to $T$?
 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
					 | 
				
			||||||
				\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
					 | 
				
			||||||
				\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
					 | 
				
			||||||
				\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
					 | 
				
			||||||
				\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			% Edges
 | 
					\footnotetext{you could also think of \say{flow} as a directed weighted graph on top of our network.}
 | 
				
			||||||
			\draw[->]
 | 
					 | 
				
			||||||
				(S) edge node[label] {$1$} (A)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$4$} (T)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$2$} (A)
 | 
					 | 
				
			||||||
				(S) edge node[label] {$2$} (B)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$1$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\hrule{}
 | 
					\problem{}
 | 
				
			||||||
 | 
					What is the magnitude of the flow above?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\generic{Flow}
 | 
					\vfill
 | 
				
			||||||
	In our city example, cars represent \textit{flow}. Let's send one unit of cars along the topmost highway:
 | 
					\pagebreak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\problem{}
 | 
				
			||||||
 | 
					Find a flow with magnitude 2 on the graph below.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
				
			||||||
 | 
								\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
				
			||||||
 | 
								\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(S) edge node[label] {$1$} (A)
 | 
				
			||||||
 | 
								(A) edge node[label] {$4$} (T)
 | 
				
			||||||
 | 
								(B) edge node[label] {$2$} (A)
 | 
				
			||||||
 | 
								(S) edge node[label] {$2$} (B)
 | 
				
			||||||
 | 
								(B) edge node[label] {$1$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vfill
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\problem{}
 | 
				
			||||||
 | 
					Find a maximal flow on the graph below. \\
 | 
				
			||||||
 | 
					\hint{The total capacity coming out of $S$ is 3, so any flow must have magnitude $\leq 3$.}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
				
			||||||
 | 
								\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
				
			||||||
 | 
								\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(S) edge node[label] {$1$} (A)
 | 
				
			||||||
 | 
								(A) edge node[label] {$4$} (T)
 | 
				
			||||||
 | 
								(B) edge node[label] {$2$} (A)
 | 
				
			||||||
 | 
								(S) edge node[label] {$2$} (B)
 | 
				
			||||||
 | 
								(B) edge node[label] {$1$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vfill
 | 
				
			||||||
 | 
					\pagebreak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\section{Combining Flows}
 | 
				
			||||||
 | 
					It is fairly easy to combine two flows on a graph. All we need to do is add the flows along each edge. For example, consider the following flows:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
				
			||||||
 | 
								\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
				
			||||||
 | 
								\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(S) edge node[label] {$1$} (A)
 | 
				
			||||||
 | 
								(A) edge node[label] {$2$} (T)
 | 
				
			||||||
 | 
								(B) edge node[label] {$2$} (A)
 | 
				
			||||||
 | 
								(S) edge node[label] {$2$} (B)
 | 
				
			||||||
 | 
								(B) edge node[label] {$1$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Flow
 | 
				
			||||||
 | 
							\draw[path]
 | 
				
			||||||
 | 
								(S) -- node[above left, flow] {$(1)$} (A)
 | 
				
			||||||
 | 
								-- node[above right, flow] {$(1)$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					\hfill
 | 
				
			||||||
 | 
					\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
				
			||||||
 | 
								\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
				
			||||||
 | 
								\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(S) edge node[label] {$1$} (A)
 | 
				
			||||||
 | 
								(A) edge node[label] {$2$} (T)
 | 
				
			||||||
 | 
								(B) edge node[label] {$2$} (A)
 | 
				
			||||||
 | 
								(S) edge node[label] {$2$} (B)
 | 
				
			||||||
 | 
								(B) edge node[label] {$1$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Flow
 | 
				
			||||||
 | 
							\draw[path]
 | 
				
			||||||
 | 
								(S)
 | 
				
			||||||
 | 
								-- node[below left, flow] {$(1)$} (B)
 | 
				
			||||||
 | 
								-- node[left, flow] {$(1)$} (A)
 | 
				
			||||||
 | 
								-- node[above right, flow] {$(1)$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{1cm}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						Combining these, we get the following:
 | 
				
			||||||
	\vspace{2ex}
 | 
						\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{minipage}{0.33\textwidth}
 | 
						\begin{tikzpicture}
 | 
				
			||||||
	\begin{center}
 | 
							% Nodes
 | 
				
			||||||
		\begin{tikzpicture}
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
				
			||||||
 | 
								\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
				
			||||||
 | 
								\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
				
			||||||
 | 
								\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			% Nodes
 | 
							% Edges
 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
							\draw[->]
 | 
				
			||||||
				\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
								(S) edge node[label] {$1$} (A)
 | 
				
			||||||
				\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
								(A) edge node[label] {$2$} (T)
 | 
				
			||||||
				\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
								(B) edge node[label] {$2$} (A)
 | 
				
			||||||
				\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
								(S) edge node[label] {$2$} (B)
 | 
				
			||||||
			\end{scope}
 | 
								(B) edge node[label] {$1$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			% Edges
 | 
							% Flow
 | 
				
			||||||
			\draw[->]
 | 
							\draw[path]
 | 
				
			||||||
				(S) edge node[label] {$1$} (A)
 | 
								(S)
 | 
				
			||||||
				(A) edge node[label] {$4$} (T)
 | 
								-- node[below left, flow] {$(1)$} (B)
 | 
				
			||||||
				(B) edge node[label] {$2$} (A)
 | 
								-- node[left, flow] {$(1)$} (A)
 | 
				
			||||||
				(S) edge node[label] {$2$} (B)
 | 
								-- node[above right, flow] {$(2) = (1) + (1)$} (T)
 | 
				
			||||||
				(B) edge node[label] {$1$} (T)
 | 
								(S)
 | 
				
			||||||
			;
 | 
								-- node[above left, flow] {$(1)$} (A)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
			% Flow
 | 
						\end{tikzpicture}
 | 
				
			||||||
			\draw[path]
 | 
					\end{center}
 | 
				
			||||||
				(S) -- node[above left, flow] {$(1)$} (A)
 | 
					\end{minipage}
 | 
				
			||||||
				-- node[above right, flow] {$(1)$} (T)
 | 
					\hfill
 | 
				
			||||||
			;
 | 
					\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
		\end{tikzpicture}
 | 
						\raggedright
 | 
				
			||||||
	\end{center}
 | 
						When adding flows, we must respect edge capacities.
 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
	\begin{minipage}{0.65\textwidth}
 | 
					 | 
				
			||||||
		There are a few things to notice here:
 | 
					 | 
				
			||||||
		\begin{itemize}
 | 
					 | 
				
			||||||
			\item Highlighted edges carry flow.
 | 
					 | 
				
			||||||
			\item Numbers in parentheses tell us how much flow each edge carries.
 | 
					 | 
				
			||||||
			\item The flow along an edge is always positive or zero.
 | 
					 | 
				
			||||||
			\item Flow comes from $S$ and goes towards $T$.
 | 
					 | 
				
			||||||
			\item Flow is conserved: all flow produced by $S$ enters $T$.
 | 
					 | 
				
			||||||
		\end{itemize}
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vspace{1ex}
 | 
						\vspace{1ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	The \textit{magnitude} of a flow\footnotemark{} is the number of \say{flow-units} that go from $S$ to $T$. \\
 | 
						For example, we could not add these graphs if the magnitude of flow in the right graph above was 2.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	We are interested in the \textit{maximum flow} through this network: what is the greatest amount of flow we can push from $S$ to $T$?
 | 
						\vspace{1ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\footnotetext{you could also think of \say{flow} as a directed weighted graph on top of our network.}
 | 
						This is because the capacity of the top-right edge is 2, and $2 + 1 > 2$.
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\problem{}
 | 
					\vspace{2ex}
 | 
				
			||||||
	What is the magnitude of the flow above?
 | 
					\hrule
 | 
				
			||||||
 | 
					\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vfill
 | 
					\problem{}
 | 
				
			||||||
	\pagebreak
 | 
					Combine the following flows and ensure that the flow along all edges remains within capacity.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\problem{}
 | 
					\vspace{2ex}
 | 
				
			||||||
	Find a flow with magnitude 2 on the graph below.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{center}
 | 
					\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
		\begin{tikzpicture}
 | 
					\begin{center}
 | 
				
			||||||
			% Nodes
 | 
						\begin{tikzpicture}[node distance = 20mm]
 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
							% Nodes
 | 
				
			||||||
				\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
				\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
								\node[main] (S) {$S$};
 | 
				
			||||||
				\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
								\node[main] (A) [above right of = S] {$A$};
 | 
				
			||||||
				\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
								\node[main] (B) [below right of = S] {$B$};
 | 
				
			||||||
			\end{scope}
 | 
								\node[main] (C) [right of = A] {$C$};
 | 
				
			||||||
 | 
								\node[main] (D) [right of = B] {$D$};
 | 
				
			||||||
 | 
								\node[main] (T) [above right of = D] {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			% Edges
 | 
							% Edges
 | 
				
			||||||
			\draw[->]
 | 
							\draw[->]
 | 
				
			||||||
				(S) edge node[label] {$1$} (A)
 | 
								(S) edge node[label] {$5$} (A)
 | 
				
			||||||
				(A) edge node[label] {$4$} (T)
 | 
								(A) edge node[label] {$3$} (C)
 | 
				
			||||||
				(B) edge node[label] {$2$} (A)
 | 
								(C) edge node[label] {$2$} (T)
 | 
				
			||||||
				(S) edge node[label] {$2$} (B)
 | 
								(A) edge node[label] {$4$} (D)
 | 
				
			||||||
				(B) edge node[label] {$1$} (T)
 | 
								(S) edge node[label] {$4$} (B)
 | 
				
			||||||
			;
 | 
								(B) edge node[label] {$1$} (D)
 | 
				
			||||||
		\end{tikzpicture}
 | 
								(D) edge node[label] {$2$} (T)
 | 
				
			||||||
	\end{center}
 | 
							;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vfill
 | 
							% Flow
 | 
				
			||||||
 | 
							\draw[path]
 | 
				
			||||||
 | 
								(S)
 | 
				
			||||||
 | 
								-- node[above left, flow] {$(2)$} (A)
 | 
				
			||||||
 | 
								-- node[above, flow] {$(2)$} (C)
 | 
				
			||||||
 | 
								-- node[above right, flow] {$(2)$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					\hfill
 | 
				
			||||||
 | 
					\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
 | 
					\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] (C) [right of = A] {$C$};
 | 
				
			||||||
 | 
								\node[main] (D) [right of = B] {$D$};
 | 
				
			||||||
 | 
								\node[main] (T) [above right of = D] {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\problem{}
 | 
							% Edges
 | 
				
			||||||
	Find a maximal flow on the graph below. \\
 | 
							\draw[->]
 | 
				
			||||||
	\hint{The total capacity coming out of $S$ is 3, so any flow must have magnitude $\leq 3$.}
 | 
								(S) edge node[label] {$5$} (A)
 | 
				
			||||||
 | 
								(A) edge node[label] {$3$} (C)
 | 
				
			||||||
 | 
								(C) edge node[label] {$2$} (T)
 | 
				
			||||||
 | 
								(A) edge node[label] {$4$} (D)
 | 
				
			||||||
 | 
								(S) edge node[label] {$4$} (B)
 | 
				
			||||||
 | 
								(B) edge node[label] {$1$} (D)
 | 
				
			||||||
 | 
								(D) edge node[label] {$2$} (T)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{center}
 | 
							% Flow
 | 
				
			||||||
		\begin{tikzpicture}
 | 
							\draw[path]
 | 
				
			||||||
			% Nodes
 | 
								(S)
 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
								-- node[above left, flow] {$(2)$} (A)
 | 
				
			||||||
				\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
								-- node[above right, flow] {$(2)$} (D)
 | 
				
			||||||
				\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
								-- node[below right, flow] {$(2)$} (T)
 | 
				
			||||||
				\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
							;
 | 
				
			||||||
				\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
						\end{tikzpicture}
 | 
				
			||||||
			\end{scope}
 | 
					\end{center}
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			% Edges
 | 
					\vfill
 | 
				
			||||||
			\draw[->]
 | 
					\pagebreak
 | 
				
			||||||
				(S) edge node[label] {$1$} (A)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$4$} (T)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$2$} (A)
 | 
					 | 
				
			||||||
				(S) edge node[label] {$2$} (B)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$1$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vfill
 | 
					 | 
				
			||||||
	\pagebreak
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\section{Combining Flows}
 | 
					 | 
				
			||||||
	It is fairly easy to combine two flows on a graph. All we need to do is add the flows along each edge. For example, consider the following flows:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vspace{2ex}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\begin{minipage}[t]{0.48\textwidth}
 | 
					 | 
				
			||||||
	\begin{center}
 | 
					 | 
				
			||||||
		\begin{tikzpicture}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Nodes
 | 
					 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
					 | 
				
			||||||
				\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
					 | 
				
			||||||
				\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
					 | 
				
			||||||
				\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
					 | 
				
			||||||
				\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Edges
 | 
					 | 
				
			||||||
			\draw[->]
 | 
					 | 
				
			||||||
				(S) edge node[label] {$1$} (A)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$2$} (T)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$2$} (A)
 | 
					 | 
				
			||||||
				(S) edge node[label] {$2$} (B)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$1$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Flow
 | 
					 | 
				
			||||||
			\draw[path]
 | 
					 | 
				
			||||||
				(S) -- node[above left, flow] {$(1)$} (A)
 | 
					 | 
				
			||||||
				-- node[above right, flow] {$(1)$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
	\hfill
 | 
					 | 
				
			||||||
	\begin{minipage}[t]{0.48\textwidth}
 | 
					 | 
				
			||||||
	\begin{center}
 | 
					 | 
				
			||||||
		\begin{tikzpicture}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Nodes
 | 
					 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
					 | 
				
			||||||
				\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
					 | 
				
			||||||
				\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
					 | 
				
			||||||
				\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
					 | 
				
			||||||
				\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Edges
 | 
					 | 
				
			||||||
			\draw[->]
 | 
					 | 
				
			||||||
				(S) edge node[label] {$1$} (A)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$2$} (T)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$2$} (A)
 | 
					 | 
				
			||||||
				(S) edge node[label] {$2$} (B)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$1$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Flow
 | 
					 | 
				
			||||||
			\draw[path]
 | 
					 | 
				
			||||||
				(S)
 | 
					 | 
				
			||||||
				-- node[below left, flow] {$(1)$} (B)
 | 
					 | 
				
			||||||
				-- node[left, flow] {$(1)$} (A)
 | 
					 | 
				
			||||||
				-- node[above right, flow] {$(1)$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vspace{1cm}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\begin{minipage}[t]{0.48\textwidth}
 | 
					 | 
				
			||||||
	\begin{center}
 | 
					 | 
				
			||||||
		Combining these, we get the following:
 | 
					 | 
				
			||||||
		\vspace{2ex}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		\begin{tikzpicture}
 | 
					 | 
				
			||||||
			% Nodes
 | 
					 | 
				
			||||||
			\begin{scope}[layer = nodes]
 | 
					 | 
				
			||||||
				\node[main] (S) at (+00mm, +00mm) {$S$};
 | 
					 | 
				
			||||||
				\node[main] (A) at (+15mm, +15mm) {$A$};
 | 
					 | 
				
			||||||
				\node[main] (B) at (+15mm, -15mm) {$B$};
 | 
					 | 
				
			||||||
				\node[main] (T) at (+30mm, +00mm) {$T$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Edges
 | 
					 | 
				
			||||||
			\draw[->]
 | 
					 | 
				
			||||||
				(S) edge node[label] {$1$} (A)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$2$} (T)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$2$} (A)
 | 
					 | 
				
			||||||
				(S) edge node[label] {$2$} (B)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$1$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Flow
 | 
					 | 
				
			||||||
			\draw[path]
 | 
					 | 
				
			||||||
				(S)
 | 
					 | 
				
			||||||
				-- node[below left, flow] {$(1)$} (B)
 | 
					 | 
				
			||||||
				-- node[left, flow] {$(1)$} (A)
 | 
					 | 
				
			||||||
				-- node[above right, flow] {$(2) = (1) + (1)$} (T)
 | 
					 | 
				
			||||||
				(S)
 | 
					 | 
				
			||||||
				-- node[above left, flow] {$(1)$} (A)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
	\hfill
 | 
					 | 
				
			||||||
	\begin{minipage}[t]{0.48\textwidth}
 | 
					 | 
				
			||||||
		\raggedright
 | 
					 | 
				
			||||||
		When adding flows, we must respect edge capacities.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		\vspace{1ex}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		For example, we could not add these graphs if the magnitude of flow in the right graph above was 2.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		\vspace{1ex}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		This is because the capacity of the top-right edge is 2, and $2 + 1 > 2$.
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vspace{2ex}
 | 
					 | 
				
			||||||
	\hrule
 | 
					 | 
				
			||||||
	\vspace{2ex}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\problem{}
 | 
					 | 
				
			||||||
	Combine the following flows and ensure that the flow along all edges remains within capacity.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vspace{2ex}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\begin{minipage}[t]{0.48\textwidth}
 | 
					 | 
				
			||||||
	\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] (C) [right of = A] {$C$};
 | 
					 | 
				
			||||||
				\node[main] (D) [right of = B] {$D$};
 | 
					 | 
				
			||||||
				\node[main] (T) [above right of = D] {$T$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Edges
 | 
					 | 
				
			||||||
			\draw[->]
 | 
					 | 
				
			||||||
				(S) edge node[label] {$5$} (A)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$3$} (C)
 | 
					 | 
				
			||||||
				(C) edge node[label] {$2$} (T)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$4$} (D)
 | 
					 | 
				
			||||||
				(S) edge node[label] {$4$} (B)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$1$} (D)
 | 
					 | 
				
			||||||
				(D) edge node[label] {$2$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Flow
 | 
					 | 
				
			||||||
			\draw[path]
 | 
					 | 
				
			||||||
				(S)
 | 
					 | 
				
			||||||
				-- node[above left, flow] {$(2)$} (A)
 | 
					 | 
				
			||||||
				-- node[above, flow] {$(2)$} (C)
 | 
					 | 
				
			||||||
				-- node[above right, flow] {$(2)$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
	\hfill
 | 
					 | 
				
			||||||
	\begin{minipage}[t]{0.48\textwidth}
 | 
					 | 
				
			||||||
	\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] (C) [right of = A] {$C$};
 | 
					 | 
				
			||||||
				\node[main] (D) [right of = B] {$D$};
 | 
					 | 
				
			||||||
				\node[main] (T) [above right of = D] {$T$};
 | 
					 | 
				
			||||||
			\end{scope}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Edges
 | 
					 | 
				
			||||||
			\draw[->]
 | 
					 | 
				
			||||||
				(S) edge node[label] {$5$} (A)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$3$} (C)
 | 
					 | 
				
			||||||
				(C) edge node[label] {$2$} (T)
 | 
					 | 
				
			||||||
				(A) edge node[label] {$4$} (D)
 | 
					 | 
				
			||||||
				(S) edge node[label] {$4$} (B)
 | 
					 | 
				
			||||||
				(B) edge node[label] {$1$} (D)
 | 
					 | 
				
			||||||
				(D) edge node[label] {$2$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Flow
 | 
					 | 
				
			||||||
			\draw[path]
 | 
					 | 
				
			||||||
				(S)
 | 
					 | 
				
			||||||
				-- node[above left, flow] {$(2)$} (A)
 | 
					 | 
				
			||||||
				-- node[above right, flow] {$(2)$} (D)
 | 
					 | 
				
			||||||
				-- node[below right, flow] {$(2)$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
		\end{tikzpicture}
 | 
					 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
	\end{minipage}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vfill
 | 
					 | 
				
			||||||
	\pagebreak
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
\end{document}
 | 
					 | 
				
			||||||
@ -1,147 +1,172 @@
 | 
				
			|||||||
\documentclass[../main.tex]{subfiles}
 | 
					\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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{1ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\begin{document}
 | 
					The first thing we'll need to construct such an algorithm is a \textit{residual graph}.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\section{Residual Graphs}
 | 
					\vspace{2ex}
 | 
				
			||||||
	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.
 | 
					\hrule
 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vspace{1ex}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	The first thing we'll need to construct such an algorithm is a \textit{residual graph}.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vspace{2ex}
 | 
					 | 
				
			||||||
	\hrule
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
 | 
						We'll start with the following network and flow:
 | 
				
			||||||
	\begin{center}
 | 
						\begin{center}
 | 
				
			||||||
		\begin{minipage}[t]{0.48\textwidth}
 | 
							\begin{tikzpicture}[node distance = 20mm]
 | 
				
			||||||
		We'll start with the following network and flow:
 | 
								% Nodes
 | 
				
			||||||
		\begin{center}
 | 
								\begin{scope}[layer = nodes]
 | 
				
			||||||
			\begin{tikzpicture}[node distance = 20mm]
 | 
									\node[main] (S) {$S$};
 | 
				
			||||||
				% Nodes
 | 
									\node[main] (A) [above right of = S] {$A$};
 | 
				
			||||||
				\begin{scope}[layer = nodes]
 | 
									\node[main] (B) [below right of = S] {$B$};
 | 
				
			||||||
					\node[main] (S) {$S$};
 | 
									\node[main] (T) [above right of = B] {$T$};
 | 
				
			||||||
					\node[main] (A) [above right of = S] {$A$};
 | 
								\end{scope}
 | 
				
			||||||
					\node[main] (B) [below right of = S] {$B$};
 | 
					 | 
				
			||||||
					\node[main] (T) [above right of = B] {$T$};
 | 
					 | 
				
			||||||
				\end{scope}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				% Edges
 | 
								% Edges
 | 
				
			||||||
				\draw[->]
 | 
								\draw[->]
 | 
				
			||||||
					(S) edge node[label] {$1$} (A)
 | 
									(S) edge node[label] {$1$} (A)
 | 
				
			||||||
					(A) edge node[label] {$3$} (T)
 | 
									(A) edge node[label] {$3$} (T)
 | 
				
			||||||
					(B) edge node[label] {$2$} (A)
 | 
									(B) edge node[label] {$2$} (A)
 | 
				
			||||||
					(S) edge node[label] {$2$} (B)
 | 
									(S) edge node[label] {$2$} (B)
 | 
				
			||||||
					(B) edge node[label] {$1$} (T)
 | 
									(B) edge node[label] {$1$} (T)
 | 
				
			||||||
				;
 | 
								;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				% Flow
 | 
								% Flow
 | 
				
			||||||
				\draw[path]
 | 
								\draw[path]
 | 
				
			||||||
					(S) -- node[above left, flow] {$(1)$} (A)
 | 
									(S) -- node[above left, flow] {$(1)$} (A)
 | 
				
			||||||
					-- node[above right, flow] {$(1)$} (T)
 | 
									-- node[above right, flow] {$(1)$} (T)
 | 
				
			||||||
				;
 | 
								;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			\end{tikzpicture}
 | 
							\end{tikzpicture}
 | 
				
			||||||
		\end{center}
 | 
					 | 
				
			||||||
		\end{minipage}
 | 
					 | 
				
			||||||
		\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}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				% 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}
 | 
						\end{center}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	\hrule
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\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}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				% 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}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				% 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{minipage}
 | 
				
			||||||
 | 
						\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}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								% 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{center}
 | 
				
			||||||
 | 
						\end{minipage}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\hrule
 | 
					\hrule
 | 
				
			||||||
	\vspace{3ex}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	You can think of the residual graph as a \say{list of possible changes} to the original flow. \\
 | 
					\begin{center}
 | 
				
			||||||
	There are two ways we can change a flow:
 | 
						\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
	\begin{itemize}
 | 
						Then, we'll add the unused capacity of \say{used} edges: (Note that $3 - 1 = 2$)
 | 
				
			||||||
		\item We can add flow along a path
 | 
						\begin{center}
 | 
				
			||||||
		\item We can remove flow along another path
 | 
							\begin{tikzpicture}[node distance = 20mm]
 | 
				
			||||||
	\end{itemize}
 | 
								% 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}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vspace{1ex}
 | 
								% 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}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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.
 | 
								% 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
 | 
					\vfill
 | 
				
			||||||
	\pagebreak
 | 
					\pagebreak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\problem{}<FindResidual>
 | 
					\problem{}<FindResidual>
 | 
				
			||||||
	Construct the residual of this flow.
 | 
					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}
 | 
				
			||||||
	\begin{center}
 | 
						\begin{center}
 | 
				
			||||||
		\begin{tikzpicture}[node distance = 25mm]
 | 
							\begin{tikzpicture}[node distance = 25mm]
 | 
				
			||||||
			% Nodes
 | 
								% Nodes
 | 
				
			||||||
@ -154,66 +179,34 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			% Edges
 | 
								% Edges
 | 
				
			||||||
			\draw[->]
 | 
								\draw[->]
 | 
				
			||||||
				(S) edge node[label] {$2$} (A)
 | 
									(A) edge node[label] {$2$} (S)
 | 
				
			||||||
				(A) edge node[label] {$1$} (T)
 | 
									(A) edge node[label] {$1$} (T)
 | 
				
			||||||
				(A) edge node[label] {$3$} (B)
 | 
									(A) edge[out=295,in=65] node[label] {$1$} (B)
 | 
				
			||||||
 | 
									(B) edge[out=115,in=245] node[label] {$2$} (A)
 | 
				
			||||||
				(S) edge node[label] {$1$} (B)
 | 
									(S) edge node[label] {$1$} (B)
 | 
				
			||||||
				(B) edge node[label] {$2$} (T)
 | 
									(T) edge node[label] {$2$} (B)
 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			% Flow
 | 
					 | 
				
			||||||
			\draw[path]
 | 
					 | 
				
			||||||
				(S)
 | 
					 | 
				
			||||||
				-- node[above left, flow] {$(2)$} (A)
 | 
					 | 
				
			||||||
				-- node[left, flow] {$(2)$} (B)
 | 
					 | 
				
			||||||
				-- node[below right, flow] {$(2)$} (T)
 | 
					 | 
				
			||||||
			;
 | 
								;
 | 
				
			||||||
		\end{tikzpicture}
 | 
							\end{tikzpicture}
 | 
				
			||||||
	\end{center}
 | 
						\end{center}
 | 
				
			||||||
 | 
					\end{solution}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{solution}
 | 
					\vfill
 | 
				
			||||||
		\begin{center}
 | 
					\problem{}
 | 
				
			||||||
			\begin{tikzpicture}[node distance = 25mm]
 | 
					Is the flow in \ref{FindResidual} maximal? \\
 | 
				
			||||||
				% Nodes
 | 
					If it isn't, find a maximal flow. \\
 | 
				
			||||||
				\begin{scope}[layer = nodes]
 | 
					\hint{Look at the residual graph. Can we add flow along another path?}
 | 
				
			||||||
					\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
 | 
					\vfill
 | 
				
			||||||
				\draw[->]
 | 
					\pagebreak
 | 
				
			||||||
					(A) edge node[label] {$2$} (S)
 | 
					 | 
				
			||||||
					(A) edge node[label] {$1$} (T)
 | 
					 | 
				
			||||||
					(A) edge[out=295,in=65] node[label] {$1$} (B)
 | 
					 | 
				
			||||||
					(B) edge[out=115,in=245] node[label] {$2$} (A)
 | 
					 | 
				
			||||||
					(S) edge node[label] {$1$} (B)
 | 
					 | 
				
			||||||
					(T) edge node[label] {$2$} (B)
 | 
					 | 
				
			||||||
				;
 | 
					 | 
				
			||||||
			\end{tikzpicture}
 | 
					 | 
				
			||||||
		\end{center}
 | 
					 | 
				
			||||||
	\end{solution}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vfill
 | 
					\problem{}
 | 
				
			||||||
	\problem{}
 | 
					Show that...
 | 
				
			||||||
	Is the flow in \ref{FindResidual} maximal? \\
 | 
					\begin{enumerate}
 | 
				
			||||||
	If it isn't, find a maximal flow. \\
 | 
						\item A maximal flow exists in every network with integral\footnotemark{} edge weights.
 | 
				
			||||||
	\hint{Look at the residual graph. Can we add flow along another path?}
 | 
						\item Every edge in this flow carries an integral amount of flow
 | 
				
			||||||
 | 
					\end{enumerate}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vfill
 | 
					\footnotetext{Integral = \say{integer} as an adjective.}
 | 
				
			||||||
	\pagebreak
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\problem{}
 | 
					\vfill
 | 
				
			||||||
	Show that...
 | 
					\pagebreak
 | 
				
			||||||
	\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.}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vfill
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
\end{document}
 | 
					 | 
				
			||||||
@ -1,128 +1,123 @@
 | 
				
			|||||||
\documentclass[../main.tex]{subfiles}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\section{The Ford-Fulkerson Algorithm}
 | 
				
			||||||
 | 
					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}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\begin{document}
 | 
					\problem{}
 | 
				
			||||||
 | 
					Run the Ford-Fulkerson algorithm on the following graph. \\
 | 
				
			||||||
 | 
					There is extra space on the next page.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\section{The Ford-Fulkerson Algorithm}
 | 
					\begin{center}
 | 
				
			||||||
	We now have all the tools we need to construct an algorithm that finds a maximal flow. \\
 | 
						\begin{tikzpicture}
 | 
				
			||||||
	It works as follows:
 | 
							% Nodes
 | 
				
			||||||
	\begin{enumerate}
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
		\item[\texttt{00}] Take a weighted directed graph $G$.
 | 
								\node[main] (S) at (-5mm, 0mm) {$S$};
 | 
				
			||||||
		\item[\texttt{01}] Find any flow $F$ in $G$
 | 
								\node[main] (A) at (20mm, 20mm) {$A$};
 | 
				
			||||||
		\item[\texttt{02}] Calculate $R$, the residual of $F$.
 | 
								\node[main] (B) at (20mm, 0mm) {$B$};
 | 
				
			||||||
		\item[\texttt{03}] ~~~~If $S$ and $T$ are not connected in $R$, $F$ is a maximal flow. \texttt{HALT}.
 | 
								\node[main] (C) at (20mm, -20mm) {$C$};
 | 
				
			||||||
		\item[\texttt{04}] Otherwise, find another flow $F_0$ in $R$.
 | 
								\node[main] (D) at (50mm, 20mm) {$D$};
 | 
				
			||||||
		\item[\texttt{05}] Add $F_0$ to $F$
 | 
								\node[main] (E) at (50mm, 0mm) {$E$};
 | 
				
			||||||
		\item[\texttt{06}] \texttt{GOTO 02}
 | 
								\node[main] (F) at (50mm, -20mm) {$F$};
 | 
				
			||||||
	\end{enumerate}
 | 
								\node[main] (T) at (75mm, 0mm) {$T$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\problem{}
 | 
							% Edges
 | 
				
			||||||
	Run the Ford-Fulkerson algorithm on the following graph. \\
 | 
							\draw[->]
 | 
				
			||||||
	There is extra space on the next page.
 | 
								(S) edge node[label] {$8$} (A)
 | 
				
			||||||
 | 
								(S) edge node[label] {$7$} (B)
 | 
				
			||||||
 | 
								(S) edge node[label] {$4$} (C)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{center}
 | 
								(A) edge node[label] {$2$} (B)
 | 
				
			||||||
		\begin{tikzpicture}
 | 
								(B) edge node[label] {$5$} (C)
 | 
				
			||||||
			% 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
 | 
								(A) edge node[label] {$3$} (D)
 | 
				
			||||||
			\draw[->]
 | 
								(A) edge node[label] {$9$} (E)
 | 
				
			||||||
				(S) edge node[label] {$8$} (A)
 | 
								(B) edge node[label] {$6$} (E)
 | 
				
			||||||
				(S) edge node[label] {$7$} (B)
 | 
								(C) edge node[label] {$7$} (E)
 | 
				
			||||||
				(S) edge node[label] {$4$} (C)
 | 
								(C) edge node[label] {$2$} (F)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				(A) edge node[label] {$2$} (B)
 | 
								(E) edge node[label] {$3$} (D)
 | 
				
			||||||
				(B) edge node[label] {$5$} (C)
 | 
								(E) edge node[label] {$4$} (F)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				(A) edge node[label] {$3$} (D)
 | 
								(D) edge node[label] {$9$} (T)
 | 
				
			||||||
				(A) edge node[label] {$9$} (E)
 | 
								(E) edge node[label] {$5$} (T)
 | 
				
			||||||
				(B) edge node[label] {$6$} (E)
 | 
								(F) edge node[label] {$8$} (T)
 | 
				
			||||||
				(C) edge node[label] {$7$} (E)
 | 
							;
 | 
				
			||||||
				(C) edge node[label] {$2$} (F)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				(E) edge node[label] {$3$} (D)
 | 
						\end{tikzpicture}
 | 
				
			||||||
				(E) edge node[label] {$4$} (F)
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				(D) edge node[label] {$9$} (T)
 | 
					\begin{solution}
 | 
				
			||||||
				(E) edge node[label] {$5$} (T)
 | 
						The maximum flow is $17$.
 | 
				
			||||||
				(F) edge node[label] {$8$} (T)
 | 
					\end{solution}
 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		\end{tikzpicture}
 | 
					\vspace{5mm}
 | 
				
			||||||
	\end{center}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{solution}
 | 
					\pagebreak
 | 
				
			||||||
		The maximum flow is $17$.
 | 
					 | 
				
			||||||
	\end{solution}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vspace{5mm}
 | 
					\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}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\pagebreak
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(S) edge node[label] {$8$} (A)
 | 
				
			||||||
 | 
								(S) edge node[label] {$7$} (B)
 | 
				
			||||||
 | 
								(S) edge node[label] {$4$} (C)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\begin{center}
 | 
								(A) edge node[label] {$2$} (B)
 | 
				
			||||||
		\begin{tikzpicture}
 | 
								(B) edge node[label] {$5$} (C)
 | 
				
			||||||
			% 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
 | 
								(A) edge node[label] {$3$} (D)
 | 
				
			||||||
			\draw[->]
 | 
								(A) edge node[label] {$9$} (E)
 | 
				
			||||||
				(S) edge node[label] {$8$} (A)
 | 
								(B) edge node[label] {$6$} (E)
 | 
				
			||||||
				(S) edge node[label] {$7$} (B)
 | 
								(C) edge node[label] {$7$} (E)
 | 
				
			||||||
				(S) edge node[label] {$4$} (C)
 | 
								(C) edge node[label] {$2$} (F)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				(A) edge node[label] {$2$} (B)
 | 
								(E) edge node[label] {$3$} (D)
 | 
				
			||||||
				(B) edge node[label] {$5$} (C)
 | 
								(E) edge node[label] {$4$} (F)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				(A) edge node[label] {$3$} (D)
 | 
								(D) edge node[label] {$9$} (T)
 | 
				
			||||||
				(A) edge node[label] {$9$} (E)
 | 
								(E) edge node[label] {$5$} (T)
 | 
				
			||||||
				(B) edge node[label] {$6$} (E)
 | 
								(F) edge node[label] {$8$} (T)
 | 
				
			||||||
				(C) edge node[label] {$7$} (E)
 | 
							;
 | 
				
			||||||
				(C) edge node[label] {$2$} (F)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				(E) edge node[label] {$3$} (D)
 | 
						\end{tikzpicture}
 | 
				
			||||||
				(E) edge node[label] {$4$} (F)
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				(D) edge node[label] {$9$} (T)
 | 
					\vfill
 | 
				
			||||||
				(E) edge node[label] {$5$} (T)
 | 
					\pagebreak
 | 
				
			||||||
				(F) edge node[label] {$8$} (T)
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		\end{tikzpicture}
 | 
					\problem{}
 | 
				
			||||||
	\end{center}
 | 
					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?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\vfill
 | 
					\begin{solution}
 | 
				
			||||||
	\pagebreak
 | 
						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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	\problem{}
 | 
						\vspace{2ex}
 | 
				
			||||||
	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}
 | 
						A simpler answer could only count the flow on $S$.
 | 
				
			||||||
		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}
 | 
					\end{solution}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		A simpler answer could only count the flow on $S$.
 | 
					\vfill
 | 
				
			||||||
 | 
					\pagebreak
 | 
				
			||||||
	\end{solution}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	\vfill
 | 
					 | 
				
			||||||
	\pagebreak
 | 
					 | 
				
			||||||
\end{document}
 | 
					 | 
				
			||||||
							
								
								
									
										187
									
								
								Advanced/Graph Algorithms/parts/04 applications.tex
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										187
									
								
								Advanced/Graph Algorithms/parts/04 applications.tex
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,187 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					\section{Applications}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\problem{Maximum Cardinality Matching}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					A \textit{matching} is a subset of edges in a bipartite graph. Nodes in a matching must not have more than one edge connected to them. \\
 | 
				
			||||||
 | 
					A matching is \textit{maximal} if it has more edges than any other matching.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{5mm}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						Initial Graph \\
 | 
				
			||||||
 | 
						\vspace{2mm}
 | 
				
			||||||
 | 
						\begin{tikzpicture}
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (A1) at (0mm, 24mm) {};
 | 
				
			||||||
 | 
								\node[main] (A2) at (0mm, 18mm) {};
 | 
				
			||||||
 | 
								\node[main] (A3) at (0mm, 12mm) {};
 | 
				
			||||||
 | 
								\node[main] (A4) at (0mm, 6mm) {};
 | 
				
			||||||
 | 
								\node[main] (A5) at (0mm, 0mm) {};
 | 
				
			||||||
 | 
								\node[main] (B1) at (20mm, 24mm) {};
 | 
				
			||||||
 | 
								\node[main] (B2) at (20mm, 18mm) {};
 | 
				
			||||||
 | 
								\node[main] (B3) at (20mm, 12mm) {};
 | 
				
			||||||
 | 
								\node[main] (B4) at (20mm, 6mm) {};
 | 
				
			||||||
 | 
								\node[main] (B5) at (20mm, 0mm) {};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw
 | 
				
			||||||
 | 
								(A1) edge (B2)
 | 
				
			||||||
 | 
								(A1) edge (B3)
 | 
				
			||||||
 | 
								(A2) edge (B1)
 | 
				
			||||||
 | 
								(A2) edge (B4)
 | 
				
			||||||
 | 
								(A4) edge (B3)
 | 
				
			||||||
 | 
								(A2) edge (B3)
 | 
				
			||||||
 | 
								(A5) edge (B3)
 | 
				
			||||||
 | 
								(A5) edge (B4)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					\hfill
 | 
				
			||||||
 | 
					\begin{minipage}[t]{0.48\textwidth}
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						Maximal Matching \\
 | 
				
			||||||
 | 
						\vspace{2mm}
 | 
				
			||||||
 | 
						\begin{tikzpicture}
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (A1) at (0mm, 24mm) {};
 | 
				
			||||||
 | 
								\node[main] (A2) at (0mm, 18mm) {};
 | 
				
			||||||
 | 
								\node[main] (A3) at (0mm, 12mm) {};
 | 
				
			||||||
 | 
								\node[main] (A4) at (0mm, 6mm) {};
 | 
				
			||||||
 | 
								\node[main] (A5) at (0mm, 0mm) {};
 | 
				
			||||||
 | 
								\node[main] (B1) at (20mm, 24mm) {};
 | 
				
			||||||
 | 
								\node[main] (B2) at (20mm, 18mm) {};
 | 
				
			||||||
 | 
								\node[main] (B3) at (20mm, 12mm) {};
 | 
				
			||||||
 | 
								\node[main] (B4) at (20mm, 6mm) {};
 | 
				
			||||||
 | 
								\node[main] (B5) at (20mm, 0mm) {};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[opacity = 0.4]
 | 
				
			||||||
 | 
								(A1) edge (B2)
 | 
				
			||||||
 | 
								(A1) edge (B3)
 | 
				
			||||||
 | 
								(A2) edge (B1)
 | 
				
			||||||
 | 
								(A2) edge (B4)
 | 
				
			||||||
 | 
								(A4) edge (B3)
 | 
				
			||||||
 | 
								(A4) edge (B3)
 | 
				
			||||||
 | 
								(A5) edge (B3)
 | 
				
			||||||
 | 
								(A5) edge (B4)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
							\draw
 | 
				
			||||||
 | 
								(A1) edge (B2)
 | 
				
			||||||
 | 
								(A2) edge (B1)
 | 
				
			||||||
 | 
								(A4) edge (B3)
 | 
				
			||||||
 | 
								(A5) edge (B4)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					\end{minipage}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{5mm}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Devise an algorithm to find a maximal matching in any bipartite graph. \\
 | 
				
			||||||
 | 
					Find an upper bound for its runtime.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{solution}
 | 
				
			||||||
 | 
						Turn this into a maximum flow problem and use FF. \\
 | 
				
			||||||
 | 
						Connect a node $S$ to all nodes in the left group and a node $T$ to all nodes in the right group. All edges have capacity 1.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Just like FF, this algorithm will take at most $\min(\# \text{ left nodes}, \# \text{ right nodes})$ iterations.
 | 
				
			||||||
 | 
					\end{solution}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vfill
 | 
				
			||||||
 | 
					\pagebreak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\problem{Circulations with Demand}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Say we have a network of cities and power stations. Stations produce power; cities consume it.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Each station produces a limited amount of power, and each city has limited demand.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					We can represent this power grid as a graph, with cities and stations as nodes and transmission lines as edges.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					A simple example is below. There are two cities ($2$ and $4$) and two stations (both $-3$).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					We'll represent station capacity with a negative number, since they \textit{consume} a negative amount of energy.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{center}
 | 
				
			||||||
 | 
						\begin{tikzpicture}[
 | 
				
			||||||
 | 
							node distance = 25mm,
 | 
				
			||||||
 | 
							main/.style = {
 | 
				
			||||||
 | 
								draw,
 | 
				
			||||||
 | 
								circle,
 | 
				
			||||||
 | 
								fill = white,
 | 
				
			||||||
 | 
								minimum size = 8mm
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
							% Nodes
 | 
				
			||||||
 | 
							\begin{scope}[layer = nodes]
 | 
				
			||||||
 | 
								\node[main] (S1) {$-3$};
 | 
				
			||||||
 | 
								\node[main] (S2) [below left of = S1] {$-3$};
 | 
				
			||||||
 | 
								\node[main] (C1) [below right of = S1] {$2$};
 | 
				
			||||||
 | 
								\node[main] (C2) [below right of = S2] {$4$};
 | 
				
			||||||
 | 
							\end{scope}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							% Edges
 | 
				
			||||||
 | 
							\draw[->]
 | 
				
			||||||
 | 
								(S1) edge node[label] {$3$} (S2)
 | 
				
			||||||
 | 
								(S1) edge node[label] {$3$} (C1)
 | 
				
			||||||
 | 
								(S2) edge node[label] {$2$} (C1)
 | 
				
			||||||
 | 
								(S2) edge node[label] {$2$} (C2)
 | 
				
			||||||
 | 
								(C1) edge node[label] {$2$} (C2)
 | 
				
			||||||
 | 
							;
 | 
				
			||||||
 | 
						\end{tikzpicture}
 | 
				
			||||||
 | 
					\end{center}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					We'd like to know if there exists a \textit{feasible circulation} in this network---that is, can we supply our cities with the energy they need without exceeding the capacity of power plants or transmission lines?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\textbf{Your job:} Devise an algorithm that solve this problem.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\note{\textbf{Bonus:} Say certain edges have a lower bound on their capacity, meaning that we must send \textit{at least} that much flow down the edge. Modify your algorithm to account for these additional constraints.}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\begin{solution}
 | 
				
			||||||
 | 
						Create a source node $S$, and connect it to each station with an edge. Set the capacity of that edge to the capacity of the station. \\
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Create a sink node $T$ and do the same for cities.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						This is now a maximum-flow problem with one source and one sink. Apply FF.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						\linehack{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						To solve the bonus problem, we'll modify the network before running the algorithm above.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						\vspace{2ex}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Say an edge from $A$ to $B$ has minimum capacity $l$ and maximum capacity $u \geq l$. Apply the following transformations:
 | 
				
			||||||
 | 
						\begin{itemize}
 | 
				
			||||||
 | 
							\item Add $l$ to the capacity of $A$
 | 
				
			||||||
 | 
							\item Subtract $l$ from the capacity of $B$
 | 
				
			||||||
 | 
							\item Subtract $l$ from the total capacity of the edge.
 | 
				
			||||||
 | 
						\end{itemize}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Do this for every edge that has a lower bound then apply the algorithm above.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\end{solution}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\vfill
 | 
				
			||||||
 | 
					\pagebreak
 | 
				
			||||||
							
								
								
									
										52
									
								
								Advanced/Graph Algorithms/tikxset.tex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								Advanced/Graph Algorithms/tikxset.tex
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					\usetikzlibrary{arrows.meta}
 | 
				
			||||||
 | 
					\usetikzlibrary{shapes.geometric}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					% We put nodes in a separate layer, so we can
 | 
				
			||||||
 | 
					% slightly overlap with paths for a perfect fit
 | 
				
			||||||
 | 
					\pgfdeclarelayer{nodes}
 | 
				
			||||||
 | 
					\pgfdeclarelayer{path}
 | 
				
			||||||
 | 
					\pgfsetlayers{main,nodes}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					% Layer settings
 | 
				
			||||||
 | 
					\tikzset{
 | 
				
			||||||
 | 
						% Layer hack, lets us write
 | 
				
			||||||
 | 
						% later = * in scopes.
 | 
				
			||||||
 | 
						layer/.style = {
 | 
				
			||||||
 | 
							execute at begin scope={\pgfonlayer{#1}},
 | 
				
			||||||
 | 
							execute at end scope={\endpgfonlayer}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						%
 | 
				
			||||||
 | 
						% Arrowhead tweaks
 | 
				
			||||||
 | 
						>={Latex[ width=2mm, length=2mm ]},
 | 
				
			||||||
 | 
						label/.style = {
 | 
				
			||||||
 | 
							circle,
 | 
				
			||||||
 | 
							% For automatic red background in solutions
 | 
				
			||||||
 | 
							fill = \ORMCbgcolor,
 | 
				
			||||||
 | 
							draw = none
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						%
 | 
				
			||||||
 | 
						% Nodes
 | 
				
			||||||
 | 
						main/.style = {
 | 
				
			||||||
 | 
							draw,
 | 
				
			||||||
 | 
							circle,
 | 
				
			||||||
 | 
							fill = white
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						%
 | 
				
			||||||
 | 
						% Flow annotations
 | 
				
			||||||
 | 
						flow/.style = {
 | 
				
			||||||
 | 
							opacity = 1,
 | 
				
			||||||
 | 
							thin,
 | 
				
			||||||
 | 
							inner xsep = 2.5mm,
 | 
				
			||||||
 | 
							inner ysep = 2.5mm
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						%
 | 
				
			||||||
 | 
						% Paths
 | 
				
			||||||
 | 
						path/.style = {
 | 
				
			||||||
 | 
							line width = 4mm,
 | 
				
			||||||
 | 
							draw = black,
 | 
				
			||||||
 | 
							% Lengthen paths so they're
 | 
				
			||||||
 | 
							% completely under nodes.
 | 
				
			||||||
 | 
							line cap = rect,
 | 
				
			||||||
 | 
							opacity = 0.3
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user