Vertex-coloring-first-wrong.tex 1.2 KB

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