2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00

Weitere Aufgaben hinzugefügt

This commit is contained in:
Martin Thoma 2013-06-12 22:55:14 +02:00
parent d9a06acf14
commit 0e0896033f
9 changed files with 221 additions and 48 deletions

View file

@ -1,19 +1,27 @@
% A complete graph
% Author: Quintin Jean-Noël
% <http://moais.imag.fr/membres/jean-noel.quintin/>
\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage[nomessages]{fp}% http://ctan.org/pkg/fp
\usepackage{ifthen}
\usepackage{tikz}
\usetikzlibrary[topaths]
\usetikzlibrary{calc}
\begin{document}
\newcommand\n{5}
\begin{tikzpicture}
\node[vertex] (N1) at (0,0) {};
\node[vertex] (N2) at (2,0) {};
\node[vertex] (N3) at (1,1) {};
\tikzstyle{vertex}=[draw,red,fill=red,circle,
minimum size=10pt,inner sep=0pt]
\tikzstyle{edge}=[red, very thick]
\begin{tikzpicture}
\newcommand{\n}{1}
\foreach \y in {0, ..., \n}{
\pgfmathsetmacro{\loopend}{{2*\n-\y}}
\pgfmathsetmacro{\second}{{\y+2}}
\foreach \x in {\y, \second,..., \loopend}{
\ifthenelse{\n=\y}{\breakforeach}{}
\node (n-\x\y)[vertex] at (\x,\y) {};
\draw (N1) -- (N3) -- (N2) -- (N1);
\end{tikzpicture}
\ifthenelse{\y=0}{}{\draw[edge] (\x,\y) -- (\x+1,\y-1);}
\pgfmathtruncatemacro\X{\x}
\ifthenelse{\X<\loopend}{\draw[edge] (\x,\y) -- (\x+2,\y);}{}
\ifthenelse{\X=\loopend}{}{\draw[edge] (\x,\y) -- (\x+1,\y+1);}
}
}
\end{tikzpicture}
\end{document}