\documentclass[10pt,a4paper]{article} \usepackage[margin=2cm]{geometry} \usepackage{multicol} \let\assignment6 \usepackage{enumitem} \setenumerate[1]{label=\assignment.\arabic*.} \setenumerate[2]{label=\textit{\alph*})} % textcomp package is not available everywhere, and we only need the Copyright symbol % taken from http://tex.stackexchange.com/a/1677/23992 \DeclareTextCommandDefault{\textregistered}{\textcircled{\check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} \usepackage{fancyhdr} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} \fancyhead{} \fancyfoot[C]{Copyright {\textcopyright} 2015 Camil Staps} \pagestyle{fancy} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amsfonts} \DeclareMathAlphabet{\pazocal}{OMS}{zplm}{m}{n} \usepackage{tikz} \usepackage{array} \usepackage{caption} \usepackage[hidelinks]{hyperref} \usepackage{url} \parindent0pt \title{Algoritmen en Datastructuren - assignment \assignment} \author{Camil Staps\\\small{s4498062}} \begin{document} \maketitle \thispagestyle{fancy} \begin{multicols}{2} \begin{enumerate} \item We start with the following residual graph: \begin{minipage}{\linewidth} \centering \begin{tikzpicture}[node distance=2cm,->,>=stealth,every node/.style={font=\scriptsize}] \node[draw,circle] (s) {s}; \node[draw,circle,above right of=s] (u) {u}; \node[draw,circle,below right of=u] (x) {x}; \node[draw,circle,below right of=s] (v) {v}; \node[draw,circle,above right of=x] (y) {y}; \node[draw,circle,below right of=x] (z) {z}; \node[draw,circle,below right of=y] (t) {t}; \draw (s) -- node[above left] {15} ++ (u); \draw (s) -- node[below left] {5} ++ (v); \draw (s) -- node[below right] {12} ++ (x); \draw (t) -- node[above right] {15} ++ (y); \draw (u) -- node[above left] {10} ++ (v); \draw (u) -- node[above right] {8} ++ (x); \draw (v) -- node[below] {8} ++ (z); \draw (x) -- node[above left] {5} ++ (y); \draw (x) -- node[below] {5} ++ (t); \draw (z) -- node[below right] {10} ++ (t); \end{tikzpicture} \end{minipage}\\ We take $(s,x,t)$. This gives the graphs: \begin{minipage}{\linewidth} \centering \begin{tikzpicture}[node distance=2cm,->,>=stealth,every node/.style={font=\scriptsize}] \node[draw,circle] (s) {s}; \node[draw,circle,above right of=s] (u) {u}; \node[draw,circle,below right of=u] (x) {x}; \node[draw,circle,below right of=s] (v) {v}; \node[draw,circle,above right of=x] (y) {y}; \node[draw,circle,below right of=x] (z) {z}; \node[draw,circle,below right of=y] (t) {t}; \draw (s) -- node[above left] {0/15} ++ (u); \draw (s) -- node[below left] {0/5} ++ (v); \draw (s) -- node[below right] {5/12} ++ (x); \draw (t) -- node[above right] {0/15} ++ (y); \draw (u) -- node[above left] {0/10} ++ (v); \draw (u) -- node[above right] {0/8} ++ (x); \draw (v) -- node[below] {0/8} ++ (z); \draw (x) -- node[above left] {0/5} ++ (y); \draw (x) -- node[below] {5/5} ++ (t); \draw (z) -- node[below right] {0/10} ++ (t); \end{tikzpicture} \end{minipage} \begin{minipage}{\linewidth} \centering \begin{tikzpicture}[node distance=2cm,->,>=stealth,every node/.style={font=\scriptsize}] \node[draw,circle] (s) {s}; \node[draw,circle,above right of=s] (u) {u}; \node[draw,circle,below right of=u] (x) {x}; \node[draw,circle,below right of=s] (v) {v}; \node[draw,circle,above right of=x] (y) {y}; \node[draw,circle,below right of=x] (z) {z}; \node[draw,circle,below right of=y] (t) {t}; \draw (s) -- node[above left] {15} ++ (u); \draw (s) -- node[below left] {5} ++ (v); \draw (s) -- node[below right] {7} ++ (x); \draw (t) -- node[above right] {15} ++ (y); \draw (t) -- node[below] {5} ++ (x); \draw (u) -- node[above left] {10} ++ (v); \draw (u) -- node[above right] {8} ++ (x); \draw (v) -- node[below] {8} ++ (z); \draw (x) -- node[above left] {5} ++ (y); \draw (x) edge[bend left] node[below right] {5} (s); \draw (z) -- node[below right] {10} ++ (t); \end{tikzpicture} \end{minipage}\\ Then we take $(s,v,z,t)$, yielding: \begin{minipage}{\linewidth} \centering \begin{tikzpicture}[node distance=2cm,->,>=stealth,every node/.style={font=\scriptsize}] \node[draw,circle] (s) {s}; \node[draw,circle,above right of=s] (u) {u}; \node[draw,circle,below right of=u] (x) {x}; \node[draw,circle,below right of=s] (v) {v}; \node[draw,circle,above right of=x] (y) {y}; \node[draw,circle,below right of=x] (z) {z}; \node[draw,circle,below right of=y] (t) {t}; \draw (s) -- node[above left] {0/15} ++ (u); \draw (s) -- node[below left] {5/5} ++ (v); \draw (s) -- node[below right] {5/12} ++ (x); \draw (t) -- node[above right] {0/15} ++ (y); \draw (u) -- node[above left] {0/10} ++ (v); \draw (u) -- node[above right] {0/8} ++ (x); \draw (v) -- node[below] {5/8} ++ (z); \draw (x) -- node[above left] {0/5} ++ (y); \draw (x) -- node[below] {5/5} ++ (t); \draw (z) -- node[below right] {5/10} ++ (t); \end{tikzpicture} \end{minipage} \begin{minipage}{\linewidth} \centering \begin{tikzpicture}[node distance=2cm,->,>=stealth,every node/.style={font=\scriptsize}] \node[draw,circle] (s) {s}; \node[draw,circle,above right of=s] (u) {u}; \node[draw,circle,below right of=u] (x) {x}; \node[draw,circle,below right of=s] (v) {v}; \node[draw,circle,above right of=x] (y) {y}; \node[draw,circle,below right of=x] (z) {z}; \node[draw,circle,below right of=y] (t) {t}; \draw (s) -- node[above left] {15} ++ (u); \draw (s) -- node[below right] {7} ++ (x); \draw (t) -- node[above right] {15} ++ (y); \draw (t) -- node[below] {5} ++ (x); \draw (t) edge[bend left] node[below right] {5} (z); \draw (u) -- node[above left] {10} ++ (v); \draw (u) -- node[above right] {8} ++ (x); \draw (v) -- node[below left] {5} ++ (s); \draw (v) -- node[below] {3} ++ (z); \draw (x) -- node[above left] {5} ++ (y); \draw (x) edge[bend left] node[below right] {5} (s); \draw (z) -- node[above left] {5} ++ (t); \draw (z) edge[bend left] node[below] {5} (v); \end{tikzpicture} \end{minipage}\\ We take $(s,u,v,z,t)$, which gives: \begin{minipage}{\linewidth} \centering \begin{tikzpicture}[node distance=2cm,->,>=stealth,every node/.style={font=\scriptsize}] \node[draw,circle] (s) {s}; \node[draw,circle,above right of=s] (u) {u}; \node[draw,circle,below right of=u] (x) {x}; \node[draw,circle,below right of=s] (v) {v}; \node[draw,circle,above right of=x] (y) {y}; \node[draw,circle,below right of=x] (z) {z}; \node[draw,circle,below right of=y] (t) {t}; \draw (s) -- node[above left] {3/15} ++ (u); \draw (s) -- node[below left] {5/5} ++ (v); \draw (s) -- node[below right] {5/12} ++ (x); \draw (t) -- node[above right] {0/15} ++ (y); \draw (u) -- node[above left] {3/10} ++ (v); \draw (u) -- node[above right] {0/8} ++ (x); \draw (v) -- node[below] {8/8} ++ (z); \draw (x) -- node[above left] {0/5} ++ (y); \draw (x) -- node[below] {5/5} ++ (t); \draw (z) -- node[below right] {8/10} ++ (t); \end{tikzpicture} \end{minipage} \begin{minipage}{\linewidth} \centering \begin{tikzpicture}[node distance=2cm,->,>=stealth,every node/.style={font=\scriptsize}] \node[draw,circle] (s) {s}; \node[draw,circle,above right of=s] (u) {u}; \node[draw,circle,below right of=u] (x) {x}; \node[draw,circle,below right of=s] (v) {v}; \node[draw,circle,above right of=x] (y) {y}; \node[draw,circle,below right of=x] (z) {z}; \node[draw,circle,below right of=y] (t) {t}; \draw (s) -- node[above] {12} ++ (u); \draw (u) edge[bend right] node[above left] {3} (s); \draw (s) -- node[below right] {7} ++ (x); \draw (t) -- node[above right] {15} ++ (y); \draw (t) -- node[below] {5} ++ (x); \draw (t) edge[bend left] node[below right] {8} (z); \draw (u) -- node[above left] {7} ++ (v); \draw (v) edge[bend left] node[above left] {3} (u); \draw (u) -- node[above right] {8} ++ (x); \draw (v) -- node[below left] {5} ++ (s); \draw (x) -- node[above left] {5} ++ (y); \draw (x) edge[bend left] node[below right] {5} (s); \draw (z) -- node[above left] {2} ++ (t); \draw (z) -- node[below] {8} ++ (v); \end{tikzpicture} \end{minipage}\\ Now it is clear that there is no augmenting path $s\leadsto t$ exists any more. $t$ is only reachable from $z$, which is only reachable from $t$. The flow we find is $3+5+5=13$. \item For every vertex $v\in V$ we create two vertices $v'_i,v'_o$, and we define $$V' = \{v'_i, v'_o \mid v\in V\}.$$ Then, define \begin{align*}E' =\;& \{(v'_o,w'_i,c) \mid (v,w,c)\in E\} \\&\cup \{(v'_i,v'_o,l(v) \mid v\in V\}.\end{align*} Informally, we split up every original vertex in an input vertex and an output vertex. The input vertex has all the incoming edges, the output vertex all the outgoing edges. The input vertex corresponding to some $v\in V$ has one outgoing edge, which is the only incoming edge of the corresponding output vertex, and has capacity $l(v)$. Intuitively we reduce the maximum flow problem in a graph with vertex capacities $(V,E)$ to the standard maximum flow problem in $(V',E')$, where we take $s'_i$ as start node and $t'_o$ as termination node. \item First, we run Ford-Fulkerson. Then, for every edge $(v,w,c)$ in the residual graph we see if adding an edge $(w,v,1)$ would allow us to continue running the algorithm (i.e., there would be a path $s\leadsto t$). If so, $(v,w)$ is a bottleneck edge, because if the capacity had been higher, Ford-Fulkerson would have continued running after the point that we stopped at. This runs in $f + \pazocal O(|E|\cdot|V|)\cdot p$, where $f$ is the running time of Ford-Fulkerson and $p$ the running time of the path finding algorithm, because we first run Ford-Fulkerson and then check for every edge if adding a reserve results in a path $s\leadsto t$. \item This reduces to the bipartite matching problem, where we match reviewers and articles, and of which we saw in the lecture that it reduces to the maximum flow problem. In addition to that, we have to give every node a limit (namely $m_A$ and $m_B$). We saw already how to reduce such a problem to the maximum flow problem in exercise 2. Therefore, this problem can be represented as a maximum flow problem. \item We first find a path $s\leadsto t$ through $(u,v)$ where for every edge $e$ we have $r(e)>0$. If there is no such path, the flow $f$ we found already is correct. This takes $\pazocal O(|V|+|E|)$. If there is such a path, we decrease the rates of all the edges by $1$, such that we have a valid flow ($f-1$) again. This takes $\pazocal O(|E|)$. Finally, we see if there is a path $s\leadsto t$ in the residual graph. We know that we can increase the flow by at most $1$, so we only have to do this once. If there is a path in the residual graph, we have flow $f$ -- if not, we have flow $f-1$. This final step takes $\pazocal O(|V|+|E|)$. In total, this takes $\pazocal O(|V|+|E|)$. \end{enumerate} \end{multicols} \end{document}