mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
112 lines
4.1 KiB
TeX
112 lines
4.1 KiB
TeX
\documentclass{beamer}
|
|
\usepackage{tikz}
|
|
\usepackage{verbatim}
|
|
\usetikzlibrary{arrows,shapes}
|
|
|
|
\begin{document}
|
|
\pgfdeclarelayer{background}
|
|
\pgfsetlayers{background,main}
|
|
|
|
\tikzset{
|
|
vertex/.style={
|
|
circle,
|
|
fill=black!25,
|
|
minimum size=20pt,
|
|
inner sep=0pt,
|
|
text height=1ex,
|
|
text depth=1ex,
|
|
label={[weight label]center:\weight},
|
|
label={[pred label]center:\pred}
|
|
},
|
|
pred label/.style={
|
|
font=\tiny,
|
|
xshift=0.3em,
|
|
yshift=-0.8ex,
|
|
text height=1ex,
|
|
text depth=0pt
|
|
},
|
|
weight label/.style={
|
|
font=\tiny,
|
|
xshift=-0.3em,
|
|
yshift=-0.8ex,
|
|
text height=1ex,
|
|
text depth=0pt
|
|
}
|
|
}
|
|
|
|
\tikzstyle{vertexOnly}=[circle,fill=black!25,minimum size=20pt,inner sep=0pt]
|
|
\tikzstyle{selected vertex} = [vertex, fill=red!24]
|
|
\tikzstyle{edge} = [->,draw,thick]
|
|
\tikzstyle{weight} = [font=\small]
|
|
\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]
|
|
\tikzstyle{ignored edge} = [draw,line width=5pt,-,black!20]
|
|
|
|
\begin{frame}
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% Given Graph %
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\begin{figure}
|
|
\begin{tikzpicture}[scale=2.5, auto,swap]
|
|
% First we draw the vertices
|
|
\foreach \pos/\name in {{(0,2)/a}, {(1,2)/b}, {(2,2)/c},
|
|
{(0,1)/d}, {(1,1)/e}, {(2,1)/f},
|
|
{(0,0)/g}, {(1,0)/h}, {(2,0)/i}}
|
|
\node[vertexOnly] (\name) at \pos {$\name$};
|
|
% Connect vertices with edges and draw weights
|
|
\foreach \source/ \dest /\weight/\style in {a/b/0/, b/c/1/, a/d/2/, e/d/5/,
|
|
b/e/3/bend right, e/b/-1/bend right, b/f/4/above, f/i/3/,
|
|
i/e/1/, g/h/1/}
|
|
\path (\source) edge[->,\style, thick] node {$\weight$} (\dest);
|
|
\end{tikzpicture}
|
|
\end{figure}
|
|
\end{frame}
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% Initialisation %
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\begin{frame}
|
|
\begin{figure}
|
|
\begin{tikzpicture}[scale=2.5, auto,swap]
|
|
% First we draw the vertices
|
|
\foreach \pos/\name/\weight/\pred in {
|
|
{(0,2)/a/$0$/-},{(1,2)/b/$\infty$/-}, {(2,2)/c/$\infty$/-},
|
|
{(0,1)/d/$\infty$/-}, {(1,1)/e/$\infty$/-}, {(2,1)/f/$\infty$/-},
|
|
{(0,0)/g/$\infty$/-}, {(1,0)/h/$\infty$/-}, {(2,0)/i/$\infty$/-}}
|
|
\node[vertex] (\name) at \pos {$\name$};
|
|
|
|
% Connect vertices with edges and draw weights
|
|
\foreach \source/ \dest /\weight/\style in {
|
|
a/b/0/, b/c/1/, a/d/2/, e/d/5/, b/e/3/bend right,
|
|
e/b/-1/bend right, b/f/4/above, f/i/3/, i/e/1/,
|
|
g/h/1/}
|
|
\path (\source) edge[->,\style, thick] node {$\weight$} (\dest);
|
|
\end{tikzpicture}
|
|
\end{figure}
|
|
\end{frame}
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% first iteraton %
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\begin{frame}
|
|
\begin{figure}
|
|
\begin{tikzpicture}[scale=2.5, auto,swap]
|
|
% First we draw the vertices
|
|
\foreach \pos/\name/\weight/\pred in {
|
|
{(1,2)/b/$\infty$/-}, {(2,2)/c/$\infty$/-},
|
|
{(0,1)/d/$\infty$/-}, {(1,1)/e/$\infty$/-}, {(2,1)/f/$\infty$/-},
|
|
{(0,0)/g/$\infty$/-}, {(1,0)/h/$\infty$/-}, {(2,0)/i/$\infty$/-}}
|
|
\node[vertex] (\name) at \pos {$\name$};
|
|
|
|
% Connect vertices with edges and draw weights
|
|
\foreach \source/ \dest /\weight/\style in {
|
|
a/b/0/, b/c/1/, a/d/2/, e/d/5/, b/e/3/bend right,
|
|
e/b/-1/bend right, b/f/4/above, f/i/3/, i/e/1/,
|
|
g/h/1/}
|
|
\path (\source) edge[->,\style, thick] node {$\weight$} (\dest);
|
|
\end{tikzpicture}
|
|
\end{figure}
|
|
\end{frame}
|
|
|
|
\end{document}
|