资料源自: http://www.texample.net/tikz/examples/tag/graphs/ http://altermundus.fr/pages/pdflatex/graphtheory.html http://www.texample.net/tikz/examples/tkz-berge/ http://www.altermundus.com/pages/graphtheory.html 宏包下载: http://www.altermundus.com/pages/download.html 选自 texample.net% The seven bridges of K?nigsberg
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage{fourier}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\begin{comment}
:Title: The seven bridges of K?nigsberg
:Slug: bridges-of-konigsberg
The Seven Bridges of K?nigsberg is a famous historical problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and presaged the idea of topology.
\end{comment}
\usetikzlibrary{arrows,%
shapes,positioning}
\thispagestyle{empty}
\begin{document}
The Seven Bridges of K?nigsberg is a famous historical problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and presaged the idea of topology.
Abstract graph corresponding to bridges of K?nigsberg
\begin{center}
\begin{tikzpicture}[node distance= 4 cm]
\useasboundingbox (-1,-1) rectangle (11,11);
\tikzset{VertexStyle/.style = {shape= circle,
ball color= orange,
text= black,
inner sep= 2pt,
outer sep= 0pt,
minimum size= 24 pt}}
\tikzset{EdgeStyle/.style= {thick,
double= orange,
double distance = 1pt}}
\tikzset{LabelStyle/.style ={draw,
fill= yellow,
text= red}}
\node[VertexStyle](A){A};
\node[VertexStyle,right=of A](B){B};
\node[VertexStyle,right=of B](C){C};
\node[VertexStyle,above= 8 cm of B](D){D};
\draw[EdgeStyle](B) to node[LabelStyle]{1} (D) ;
\tikzset{EdgeStyle/.append style = {bend left}}
\draw[EdgeStyle](A) to node[LabelStyle]{2} (B);
\draw[EdgeStyle](B) to node[LabelStyle]{3} (A);
\draw[EdgeStyle](B) to node[LabelStyle]{4} (C);
\draw[EdgeStyle](C) to node[LabelStyle]{5} (B);
\draw[EdgeStyle](A) to node[LabelStyle]{6} (D);
\draw[EdgeStyle](D) to node[LabelStyle]{7} (C);
\end{tikzpicture}
\end{center}
\end{document}% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}
\def\xcolorversion{2.00}
\def\xkeyvalversion{1.8}
\usepackage[version=0.96]{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri}
\usepackage[latin1]{inputenc}
\usepackage{verbatim}
\begin{document}
\begin{comment}
:Title: A Petri-net for Hagen
:Slug: nodetutorial
:Tags: Manual, Petri net, Graphs
This example is from the tutorial: A Petri-net for Hagen.
| Author: Till Tantau
| Source: The PGF/TikZ manual
\end{comment}
\begin{tikzpicture}[node distance=1.3cm,>=stealth',bend angle=45,auto]
\tikzstyle{place}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=6mm]
\tikzstyle{red place}=[place,draw=red!75,fill=red!20]
\tikzstyle{transition}=[rectangle,thick,draw=black!75,
fill=black!20,minimum size=4mm]
\tikzstyle{every label}=[red]
\begin{scope}
% First net
\node [place,tokens=1] (w1){};
\node [place] (c1) [below of=w1]{};
\node [place] (s)[below of=c1,label=above:$s\le 3$] {};
\node [place] (c2) [below of=s]{};
\node [place,tokens=1] (w2) [below of=c2]{};
\node [transition] (e1) [left of=c1] {}
edge [pre,bend left](w1)
edge [post,bend right](s)
edge [post](c1);
\node [transition] (e2) [left of=c2] {}
edge [pre,bend right](w2)
edge [post,bend left](s)
edge [post](c2);
\node [transition] (l1) [right of=c1] {}
edge [pre](c1)
edge [pre,bend left](s)
edge [post,bend right] node[swap] {2} (w1);
\node [transition] (l2) [right of=c2] {}
edge [pre](c2)
edge [pre,bend right](s)
edge [post,bend left]node {2}(w2);
\end{scope}
\begin{scope}[xshift=6cm]
% Second net
\node [place,tokens=1]
(w1'){};
\node [place](c1') [below of=w1']{};
\node [red place] (s1') [below of=c1',xshift=-5mm,label=left:$s$]{};
\node [red place,tokens=3]
(s2') [below of=c1',xshift=5mm,label=right:$\bar s$] {};
\node [place](c2') [below of=s1',xshift=5mm]{};
\node [place,tokens=1]
(w2') [below of=c2']{};
\node [transition] (e1') [left of=c1'] {}
edge [pre,bend left](w1')
edge [post](s1')
edge [pre](s2')
edge [post](c1');
\node [transition] (e2') [left of=c2'] {}
edge [pre,bend right](w2')
edge [post](s1')
edge [pre](s2')
edge [post](c2');
\node [transition] (l1') [right of=c1'] {}
edge [pre](c1')
edge [pre](s1')
edge [post](s2')
edge [post,bend right] node[swap] {2} (w1');
\node [transition] (l2') [right of=c2'] {}
edge [pre](c2')
edge [pre](s1')
edge [post](s2')
edge [post,bend left]node {2}(w2');
\end{scope}
\draw [-to,thick,snake=snake,segment amplitude=.4mm,
segment length=2mm,line after snake=1mm]
([xshift=5mm]s -| l1) -- ([xshift=-5mm]s1' -| e1')
node [above=1mm,midway,text width=3cm,text centered]
{replacement of the \textcolor{red}{capacity} by
\textcolor{red}{two places}};
\begin{pgfonlayer}{background}
\filldraw [line width=4mm,join=round,black!10]
(w1.north-| l1.east)rectangle (w2.south-| e1.west)
(w1'.north -| l1'.east) rectangle (w2'.south -| e1'.west);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}
\usepackage{tikz}
\usepackage{verbatim}
\begin{document}
\pagestyle{empty}
\begin{comment}
:Title: Automata
:Tags: Manual, Automata, Foreach, Graphs
This example is from the System layertitle page of the TikZ and PGF manual.
| Author: Till Tantau
| Source: The PGF/TikZ manual
\end{comment}
\begin{tikzpicture}[shorten >=1pt,->]
\tikzstyle{vertex}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\foreach \name/\x in {s/1, 2/2, 3/3, 4/4, 15/11,
16/12, 17/13, 18/14, 19/15, t/16}
\node[vertex] (G-\name) at (\x,0) {$\name$};
\foreach \name/\angle/\text in {P-1/234/5, P-2/162/6,
P-3/90/7, P-4/18/8, P-5/-54/9}
\node[vertex,xshift=6cm,yshift=.5cm] (\name) at (\angle:1cm) {$\text$};
\foreach \name/\angle/\text in {Q-1/234/10, Q-2/162/11,
Q-3/90/12, Q-4/18/13, Q-5/-54/14}
\node[vertex,xshift=9cm,yshift=.5cm] (\name) at (\angle:1cm) {$\text$};
\foreach \from/\to in {s/2,2/3,3/4,3/4,15/16,16/17,17/18,18/19,19/t}
\draw (G-\from) -- (G-\to);
\foreach \from/\to in {1/2,2/3,3/4,4/5,5/1,1/3,2/4,3/5,4/1,5/2}
{ \draw (P-\from) -- (P-\to); \draw (Q-\from) -- (Q-\to); }
\draw (G-3) .. controls +(-30:2cm) and +(-150:1cm) .. (Q-1);
\draw (Q-5) -- (G-15);
\end{tikzpicture}
\end{document}
发表评论 取消回复