123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- \documentclass{article}
- \usepackage[pdftex,active,tightpage]{preview}
- \setlength\PreviewBorder{2mm}
- \usepackage[utf8]{inputenc} % this is needed for umlauts
- \usepackage[ngerman]{babel} % this is needed for umlauts
- \usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
- \usepackage{amssymb,amsmath,amsfonts} % nice math rendering
- \usepackage{braket} % needed for \Set
- \usepackage{caption}
- \usepackage{algorithm}
- \usepackage[noend]{algpseudocode}
- \DeclareCaptionFormat{myformat}{#3}
- \captionsetup[algorithm]{format=myformat}
- \begin{document}
- \begin{preview}
- \begin{algorithm}[H]
- \begin{algorithmic}
- \Require
- \Statex Graph $G = (V, E)$
- \Statex Weight from node $i$ to node $j$: $g_{ij} \in \mathbb{R}_0^+$
- \Statex Starting node $s \in V$
- \Statex End node $t \in V$
- \Statex Lower bound to get from node $j$ to $t$: $h_j$ (default: $h_j = 0$)
- \Statex Upper bound to get from node $j$ to $t$: $m_j$ (default: $m_j = \infty$)
- \Procedure{LabelCorrection}{$G$, $s$, $t$, $h$, $m$}
- \State $d_s \gets 0$
- \State $d_i \gets \infty \quad \forall i \neq s$ \Comment{Distance of node $i$ from $s$}
- \State $u \gets \infty$ \Comment{Distance from $s$ to $t$}
- \State $K \gets \{s\}$ \Comment{Choose some datastructure here}
- \While{$K$ is not empty}
- \State $v \gets K.pop()$
- \For{child $c$ of $v$}
- \If{$d_v + g_{vc} + h_c < \min(d_c, u)$}
- \State $d_c \gets d_v + g_{vc}$
- \State $c.parent \gets v$
- \If{$c \neq t$ and $c \notin K$}
- \State $K.insert(c)$
- \EndIf
- \If{$c = t$}
- \State $u \gets d_v + g_{vt}$
- \EndIf
- \EndIf
- \State $u \gets \min (u, d_c + m_c)$
- \EndFor
- \EndWhile
- \Return $u, t$
- \EndProcedure
- \end{algorithmic}
- \caption{Label correction algorithm: Find shortest path}
- \label{alg:label-correction-algorithm}
- \end{algorithm}
- \end{preview}
- \end{document}
|