aboutsummaryrefslogtreecommitdiff
path: root/assignment6.tex
blob: b60e7798869c65c81b9bc8a7f08df05e40658527 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
\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}