Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
\documentclass{article}
2
\usepackage[pdftex,active,tightpage]{preview}
3
\setlength\PreviewBorder{2mm}
4
5
\usepackage[utf8]{inputenc} % this is needed for umlauts
6
\usepackage[ngerman]{babel} % this is needed for umlauts
7
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
8
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
9
\usepackage{braket} % needed for \Set
10
\usepackage{algorithm,algpseudocode}
11
\renewcommand{\thealgorithm}{3} %disable numbers for algorithm
12
13
\begin{document}
14
\begin{preview}
15
\begin{algorithm}[H]
16
\begin{algorithmic}
17
\Require $G = (V, E)$ an undirected graph
18
\State $n \gets |V|$
19
\State Give all vertices an index $1 \leq i \leq n$ that defines an order
20
\For{$i \in 1, \dots, n$}
21
\State $v_i$.color $\gets 0$
22
\EndFor
23
\\
24
\If{$n==1$}
25
\State \Return
26
\Else
27
\For{$maxColors \in 2, \dots, n$}
28
\While{$G$ is not properly colored and not all vertices have color $(maxColors-1)$}
29
\State $(v_1 v_2 \dots v_n) \gets (v_1 v_2 \dots v_n) + 1$ \Comment{count up in base $maxColor$}
30
\EndWhile
31
\EndFor
32
\EndIf
33
\end{algorithmic}
34
\caption{Find a vertex coloring for $G$ with brute force}
35
\label{alg:vertexColoring}
36
\end{algorithm}
37
\end{preview}
38
\end{document}
39
40