Stoer-Wagner.tex 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage[utf8]{inputenc} % this is needed for umlauts
  5. \usepackage[ngerman]{babel} % this is needed for umlauts
  6. \usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
  7. \usepackage{amssymb,amsmath,amsfonts} % nice math rendering
  8. \usepackage{braket} % needed for \Set
  9. \usepackage{algorithm,algpseudocode}
  10. \begin{document}
  11. \begin{preview}
  12. Sei $S \subseteq V$ und $c:E\rightarrow\mathbb{R}_0^+$ die
  13. Kantengewichtsfunktion.
  14. Für $v \in V \setminus S$ sei:
  15. \begin{align*}
  16. c &:\mathcal{P}(V) \times V \rightarrow \mathbb{R}_0^+\\
  17. c(S,v) &:= \sum_{\substack{\Set{u,v} \in E\\ u \in S}} c(\Set{u,v})
  18. \end{align*}
  19. Sei nun $d: \mathcal{P}(V) \rightarrow V$ die Funktion, die den
  20. Knoten liefert, der am stärksten mit $S \in \mathcal{P}(V)$
  21. verbunden ist:
  22. \[d(S) := v \in V \setminus S: c(S, v) = \max(\Set{c(S,v) | v \in V \setminus S})\]
  23. \begin{algorithm}[H]
  24. \begin{algorithmic}
  25. \Function{StoerWagner}{Network $N(D, s, t, c)$}
  26. \State Graph $G_0 = D$
  27. \State Knoten $a,b,v$
  28. \State Phasenergebnisse $P$ \Comment{Speichert Schnitt und Gewicht}
  29. \For{($i=1$; $\;i<|V|$; $\;i$++)}
  30. \State Knotenmenge $S_i \gets \Set{}$
  31. \State $S_i$.add($S_i \in G_i$) \Comment{Wähle einen beliebigen Startknoten}
  32. \While{$S_i \neq V_{i-1}$}
  33. \State $v \gets$ \Call{d}{$S_i$}
  34. \State $S_i$.add($v$)
  35. \EndWhile
  36. \State $a \gets v$
  37. \State $b \gets$ \Call{d}{$\Set{a}$}
  38. \State $V_i \gets$ \Call{Verschmelzen}{$V_{i-1}$, $a$, $b$}
  39. \State $E_i \gets$ \Call{Verschmelzen}{$E_{i-1}$, $a$, $b$}
  40. \State $G_i = (V_i, E_i)$
  41. \State $P$.add($(a, V \setminus a)$, $c(a, V \setminus a)$)
  42. \EndFor
  43. \State \Return $P$.getMinimalCut()
  44. \EndFunction
  45. \Function{Verschmelzen}{Knotenmenge $V$, Knoten $a$, Knoten $b$}
  46. \State $V$.remove($a$)
  47. \State $V$.remove($b$)
  48. \State \Comment{TODO: was, wenn a und b schon Mengen sind?}
  49. \State $V$.add($\Set{a, b}$)
  50. \EndFunction
  51. \Function{Verschmelzen}{Kantenmenge $E$, Knoten $a$, Knoten $b$}
  52. \State \Comment{TODO: Kantengewichtsfunktion muss auch angepasst werden}
  53. \ForAll{Kante $e:=(x,y) \in E$}
  54. \If{$x == a \lor x == b$}
  55. \State $E$.remove($e$)
  56. \State $E$.add($(\Set{a, b},y)$)
  57. \ElsIf{$y == a \lor y == b$}
  58. \State $E$.remove($e$)
  59. \State $E$.add($(x, \Set{a, b})$)
  60. \EndIf
  61. \EndFor
  62. \EndFunction
  63. \end{algorithmic}
  64. \caption{Algorithmus von Stoer und Wanger}
  65. \label{alg:seq1}
  66. \end{algorithm}
  67. \end{preview}
  68. \end{document}