label-correction.tex 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 Weight from node $i$ to node $j$: $g_{ij} \in \mathbb{R}_0^+$
  21. \Statex Starting node $s \in V$
  22. \Statex End node $t \in V$
  23. \Statex Lower bound to get from node $j$ to $t$: $h_j$ (default: $h_j = 0$)
  24. \Statex Upper bound to get from node $j$ to $t$: $m_j$ (default: $m_j = \infty$)
  25. \Procedure{LabelCorrection}{$G$, $s$, $t$, $h$, $m$}
  26. \State $d_s \gets 0$
  27. \State $d_i \gets \infty \quad \forall i \neq s$ \Comment{Distance of node $i$ from $s$}
  28. \State $u \gets \infty$ \Comment{Distance from $s$ to $t$}
  29. \State $K \gets \{s\}$ \Comment{Choose some datastructure here}
  30. \While{$K$ is not empty}
  31. \State $v \gets K.pop()$
  32. \For{child $c$ of $v$}
  33. \If{$d_v + g_{vc} + h_c < \min(d_c, u)$}
  34. \State $d_c \gets d_v + g_{vc}$
  35. \State $c.parent \gets v$
  36. \If{$c \neq t$ and $c \notin K$}
  37. \State $K.insert(c)$
  38. \EndIf
  39. \If{$c = t$}
  40. \State $u \gets d_v + g_{vt}$
  41. \EndIf
  42. \EndIf
  43. \State $u \gets \min (u, d_c + m_c)$
  44. \EndFor
  45. \EndWhile
  46. \Return $u, t$
  47. \EndProcedure
  48. \end{algorithmic}
  49. \caption{Label correction algorithm: Find shortest path}
  50. \label{alg:label-correction-algorithm}
  51. \end{algorithm}
  52. \end{preview}
  53. \end{document}