Goldberg-Tarjan-Push-Relabel.tex 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 to 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. \ElsIf{\Call{isRelabelOk}{v}}
  39. \State \Call{Relabel}{v}
  40. \EndIf
  41. \EndWhile
  42. \\
  43. \State \Return $f$ \Comment{Maximaler Fluss}
  44. \EndFunction
  45. \\
  46. \Function{Push}{Graph $D$, Flow $f$, Node $v$, Node $w$}
  47. \State $\Delta \gets \min\Set{e(v), r_f(v,w)}$
  48. \State $f(v,w) \gets f(v,w) + \Delta$
  49. \State $f(w,v) \gets f(w,v) - \Delta$
  50. \State $r_f(v,w) \gets r_f(v,w) - \Delta$
  51. \State $r_f(w,v) \gets r_f(w,v) + \Delta$
  52. \State $e(v) \gets e(v) - \Delta$
  53. \State $e(w) \gets e(w) + \Delta$
  54. \EndFunction
  55. \\
  56. \Function{Relabel}{Node $v$}
  57. \If{$\Set{w|r_f(v,w) > 0} == \emptyset$}
  58. \State $dist(v) \gets \infty$
  59. \Else
  60. \State $dist(v) \gets \min\Set{dist(w)+1|w \in V: r_f(v,w) > 0}$
  61. \EndIf
  62. \EndFunction
  63. \\
  64. \Function{isActive}{Node v}
  65. \State\Return $(e(v) > 0) \land (dist(v) < \infty)$
  66. \EndFunction
  67. \\
  68. \Function{isRelabelOk}{Node v}
  69. \State\Return \Call{isActive}{v} $\land (\forall w \in \Set{r_f(v,w) >0}: dist(v) \leq dist(w))$
  70. \EndFunction
  71. \\
  72. \Function{isPushOk}{Node v}
  73. \State\Return \Call{isActive}{v} $\land (r_f > 0) \land (dist(v) == dist(w)+1)$
  74. \EndFunction
  75. \end{algorithmic}
  76. \caption{Algorithm of Goldberg and Tarjan}
  77. \label{alg:seq1}
  78. \end{algorithm}
  79. \end{preview}
  80. \end{document}