label-correction.tex 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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{caption}
  10. \usepackage{algorithm}
  11. \usepackage[noend]{algpseudocode}
  12. \DeclareCaptionFormat{myformat}{#3}
  13. \captionsetup[algorithm]{format=myformat}
  14. \begin{document}
  15. \begin{preview}
  16. \begin{algorithm}[H]
  17. \begin{algorithmic}
  18. \Require
  19. \Statex Graph $G = (V, E)$
  20. \Statex Starting node $s \in V$
  21. \Statex End node $t \in V$
  22. \Procedure{LabelCorrection}{$G$, $s$, $t$}
  23. \State $d_s \gets 0$
  24. \State $d_i \gets \infty \quad \forall i \neq s$
  25. \State $u \gets \infty$
  26. \State $K \gets \{s\}$ \Comment{Choose some datastructure here}
  27. \While{$K$ is not empty}
  28. \State $v \gets K.pop()$
  29. \For{child $c$ of $v$}
  30. \If{$d_v + g_{vc} < \min(d_c, u)$}
  31. \State $d_v \gets d_v + g_{vc}$
  32. \State $c.parent \gets v$
  33. \If{$c \neq t$ and $c \notin K$}
  34. \State $K.insert(c)$
  35. \EndIf
  36. \If{$c = t$}
  37. \State $u \gets d_v + g_{vt}$
  38. \EndIf
  39. \EndIf
  40. \EndFor
  41. \EndWhile
  42. \EndProcedure
  43. \end{algorithmic}
  44. \caption{Label correction algorithm}
  45. \label{alg:label-correction-algorithm}
  46. \end{algorithm}
  47. \end{preview}
  48. \end{document}