mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
misc
This commit is contained in:
parent
3cfc9d9969
commit
86ab5dfa97
16 changed files with 212 additions and 136 deletions
36
source-code/Pseudocode/Vertex-coloring/Makefile
Normal file
36
source-code/Pseudocode/Vertex-coloring/Makefile
Normal file
|
@ -0,0 +1,36 @@
|
|||
SOURCE = Vertex-coloring-brute-force
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 512
|
||||
|
||||
make:
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
|
||||
|
||||
gif:
|
||||
pdfcrop $(SOURCE).pdf
|
||||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
|
||||
make clean
|
||||
|
||||
png:
|
||||
make
|
||||
make svg
|
||||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
|
||||
|
||||
transparentGif:
|
||||
convert $(SOURCE).pdf -transparent white result.gif
|
||||
make clean
|
||||
|
||||
svg:
|
||||
make
|
||||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
|
||||
pdf2svg $(SOURCE).pdf $(SOURCE).svg
|
||||
# Necessary, as pdf2svg does not always create valid svgs:
|
||||
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
|
||||
rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg
|
||||
inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg
|
||||
rm $(SOURCE)2.svg
|
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
|
@ -0,0 +1,38 @@
|
|||
\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{algorithm,algpseudocode}
|
||||
\renewcommand{\thealgorithm}{3} %disable numbers for algorithm
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{algorithm}[H]
|
||||
\begin{algorithmic}
|
||||
\Require $G = (V, E)$ an undirected graph
|
||||
\State $n \gets |V|$
|
||||
\State Give all vertices an index $1 \leq i \leq n$ that defines an order
|
||||
\For{$i \in 1, \dots, n$}
|
||||
\State $v_i$.color $\gets 0$
|
||||
\EndFor
|
||||
\\
|
||||
\If{$n==1$}
|
||||
\State \Return
|
||||
\Else
|
||||
\For{$maxColors \in 2, \dots, n$}
|
||||
\While{$G$ is not properly colored and not all vertices have color $(maxColors-1)$}
|
||||
\State $(v_1 v_2 \dots v_n) \gets (v_1 v_2 \dots v_n) + 1$ \Comment{count up in base $maxColor$}
|
||||
\EndWhile
|
||||
\EndFor
|
||||
\EndIf
|
||||
\end{algorithmic}
|
||||
\caption{Find a vertex coloring for $G$ with brute force}
|
||||
\label{alg:vertexColoring}
|
||||
\end{algorithm}
|
||||
\end{preview}
|
||||
\end{document}
|
|
@ -0,0 +1,36 @@
|
|||
\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{algorithm,algpseudocode}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{algorithm}[H]
|
||||
\begin{algorithmic}
|
||||
\Require $G = (V, E)$ an undirected graph
|
||||
\State $n \gets |V|$
|
||||
\State Give all vertices an index $1 \leq i \leq n$ that defines an order
|
||||
|
||||
\For{$i \in 1, \dots, n$}
|
||||
\State $v_i$.color $\gets 1$
|
||||
\EndFor
|
||||
\\
|
||||
\For{$i \in 1, \dots, n$}
|
||||
\For{$j \in i+1, \dots, n$}
|
||||
\If{$\Set{v_i, v_j} \in E \land v_i.\text{color} = v_j.\text{color}$}
|
||||
\State $v_j.color \gets v_j.color + 1$
|
||||
\EndIf
|
||||
\EndFor
|
||||
\EndFor
|
||||
\end{algorithmic}
|
||||
\caption{Find a vertex coloring for $G$}
|
||||
\label{alg:vertexColoring}
|
||||
\end{algorithm}
|
||||
\end{preview}
|
||||
\end{document}
|
|
@ -0,0 +1,39 @@
|
|||
\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{algorithm,algpseudocode}
|
||||
\renewcommand{\thealgorithm}{2} %disable numbers for algorithm
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{algorithm}[H]
|
||||
\begin{algorithmic}
|
||||
\Require $G = (V, E)$ an undirected graph
|
||||
\State $n \gets |V|$
|
||||
\State Give all vertices an index $1 \leq i \leq n$ that defines an order
|
||||
|
||||
\For{$i \in 1, \dots, n$}
|
||||
\State $v_i$.color $\gets 1$
|
||||
\EndFor
|
||||
\\
|
||||
\For{$i \in 1, \dots, n$}
|
||||
\State $possible \gets \Set{1, \dots, n}$
|
||||
\For{$j \in i+1, \dots, n$}
|
||||
\If{$\Set{v_i, v_j} \in E$}
|
||||
\State $possible \gets possible \setminus \Set{v_j.\text{color}}$
|
||||
\EndIf
|
||||
\EndFor
|
||||
\State $v_i$.color $\gets \min(possible)$
|
||||
\EndFor
|
||||
\end{algorithmic}
|
||||
\caption{Find a vertex coloring for $G$}
|
||||
\label{alg:vertexColoring}
|
||||
\end{algorithm}
|
||||
\end{preview}
|
||||
\end{document}
|
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
Loading…
Add table
Add a link
Reference in a new issue