Goldberg-Tarjan-Push-Relabel.tex 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage{amssymb,amsmath,amsfonts} % nice math rendering
  5. \usepackage{braket} % needed for \Set
  6. \usepackage{algorithm,algpseudocode}
  7. \begin{document}
  8. \begin{preview}
  9. \begin{itemize}
  10. \item $c:E \rightarrow \mathbb{R}_0^+$: capacity of an edge
  11. \item $e: V \rightarrow \mathbb{R}_0^+$: excess (too much flow in one node)
  12. \item $r_f: V \times V \rightarrow \mathbb{R}, \; r_f(u,v) := c(u,v) - f(u,v) $: remaining capacity
  13. \item $dist: V \rightarrow \mathbb{N}$: the label (imagine this as height)
  14. \end{itemize}
  15. \begin{algorithm}[H]
  16. \begin{algorithmic}
  17. \Function{PushRelabel}{Network $N(D, s, t, c)$}
  18. \ForAll{$(v,w) \in (V \times V \setminus E)$} \Comment{If an edge is not in $D=(V,E)$,}
  19. \State $c(v,w) \gets 0$ \Comment{then its capacity is 0}
  20. \EndFor
  21. \\
  22. \ForAll{$(v,w) \in V \times V$} \Comment{At the beginning, every edge}
  23. \State $f(v,w) \gets 0$ \Comment{has flow=0}
  24. \State $r_f(v,w) \gets c(v,w)$ \Comment{flow=max in the residualgraph}
  25. \EndFor
  26. \\
  27. \State $dist(s) \gets |V|$
  28. \ForAll{$v \in V \setminus \Set{s}$}
  29. \State $f(s,v) \gets c(s,v)$ \Comment{Push maximum flow out at the beginning}
  30. \State $r(v,s) \gets c(v,s) - f(v,s)$
  31. \State $dist(v) \gets 0$
  32. \State $e(v) \gets c(s,v)$ \Comment{$v$ has too much flow}
  33. \EndFor
  34. \\
  35. \While{$\exists v \in V:$ \Call{isActive}{$v$}}
  36. \If{\Call{isPushOk}{$v$}}
  37. \State \Call{Push}{$v$}
  38. \EndIf
  39. \If{\Call{isRelabelOk}{$v$}}
  40. \State \Call{Relabel}{$v$}
  41. \EndIf
  42. \EndWhile
  43. \\
  44. \State \Return $f$ \Comment{Maximaler Fluss}
  45. \EndFunction
  46. \\
  47. \Function{Push}{Node $v$, Node $w$}
  48. \State $\Delta \gets \min\Set{e(v), r_f(v,w)}$
  49. \State $f(v,w) \gets f(v,w) + \Delta$
  50. \State $f(w,v) \gets f(w,v) - \Delta$
  51. \State $r_f(v,w) \gets r_f(v,w) - \Delta$
  52. \State $r_f(w,v) \gets r_f(w,v) + \Delta$
  53. \State $e(v) \gets e(v) - \Delta$
  54. \State $e(w) \gets e(w) + \Delta$
  55. \EndFunction
  56. \\
  57. \Function{Relabel}{Node $v$}
  58. \If{$\Set{w \in V |r_f(v,w) > 0} == \emptyset$}
  59. \State $dist(v) \gets \infty$
  60. \Else
  61. \State $dist(v) \gets \min\Set{dist(w)+1|w \in V: r_f(v,w) > 0}$
  62. \EndIf
  63. \EndFunction
  64. \\
  65. \Function{isActive}{Node $v$}
  66. \State\Return $(e(v) > 0) \land (dist(v) < \infty)$
  67. \EndFunction
  68. \\
  69. \Function{isRelabelOk}{Node $v$}
  70. \State\Return \Call{isActive}{$v$} $\displaystyle \bigwedge_{w \in \Set{w \in V | r_f(v,w) >0}}(dist(v) \leq dist(w))$
  71. \EndFunction
  72. \\
  73. \Function{isPushOk}{Node $v$}
  74. \State\Return \Call{isActive}{$v$} $\land (e(v) > 0) \land (dist(v) == dist(w)+1)$
  75. \EndFunction
  76. \end{algorithmic}
  77. \caption{Algorithm of Goldberg and Tarjan}
  78. \label{alg:seq1}
  79. \end{algorithm}
  80. \end{preview}
  81. \end{document}