Vertex-coloring-second-wrong.tex 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. \renewcommand{\thealgorithm}{2} %disable numbers for algorithm
  11. \begin{document}
  12. \begin{preview}
  13. \begin{algorithm}[H]
  14. \begin{algorithmic}
  15. \Require $G = (V, E)$ an undirected graph
  16. \State $n \gets |V|$
  17. \State Give all vertices an index $1 \leq i \leq n$ that defines an order
  18. \For{$i \in 1, \dots, n$}
  19. \State $v_i$.color $\gets 1$
  20. \EndFor
  21. \\
  22. \For{$i \in 1, \dots, n$}
  23. \State $possible \gets \Set{1, \dots, n}$
  24. \For{$j \in i+1, \dots, n$}
  25. \If{$\Set{v_i, v_j} \in E$}
  26. \State $possible \gets possible \setminus \Set{v_j.\text{color}}$
  27. \EndIf
  28. \EndFor
  29. \State $v_i$.color $\gets \min(possible)$
  30. \EndFor
  31. \end{algorithmic}
  32. \caption{Find a vertex coloring for $G$}
  33. \label{alg:vertexColoring}
  34. \end{algorithm}
  35. \end{preview}
  36. \end{document}