Browse Source

add stackexchange examples

main
parent
commit
2827c3a000
  1. 22
      .gitignore
  2. 2
      notes.md
  3. BIN
      stackexchange_2.pdf
  4. 34
      stackexchange_2.tex
  5. BIN
      stackexchange_test.pdf
  6. 44
      stackexchange_test.tex

22
.gitignore

@ -0,0 +1,22 @@
## Core latex/pdflatex auxiliary files:
*.aux
*.lof
*.log
*.lot
*.fls
*.out
*.toc
*.fmt
*.fot
*.cb
*.cb2
.*.lb
## Build tool auxiliary files:
*.fdb_latexmk
*.synctex
*.synctex(busy)
*.synctex.gz
*.synctex.gz(busy)
*.pdfsync

2
notes.md

@ -0,0 +1,2 @@

BIN
stackexchange_2.pdf

34
stackexchange_2.tex

@ -0,0 +1,34 @@
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
vertex/.style={circle,draw,minimum size=1.5em},
edge/.style={->,> = latex'}
}
\begin{document}
\begin{tikzpicture}
% vertices
\node[vertex] (1) at (0,0) {$1$};
\node[vertex] (2) at (2,0) {$2$};
\node[vertex] (3) at (0,-2) {$3$};
\node[vertex] (4) at (2,-2) {$4$};
\node[vertex] (5) at (-2,-2) {$5$};
%edges
\draw[edge] (1) -- (2) node[midway, above] {$\frac{1}{3}$};
\draw[edge] (1.260) -- (3.100);
\draw[edge] (1.325) -- (4.125) node[pos=.3, right, sloped, rotate=90] {$\frac{1}{3}$};
\draw[edge] (2) -- (3);
\draw[edge] (2) -- (4) node[midway, right] {$\frac{1}{2}$};
\draw[edge] (3.80) -- (1.280);
\draw[edge] (4) -- (3);
\draw[edge] (4.145) -- (1.305);
\draw[edge] (3.170) -- (5.10);
\draw[edge] (5.350) -- (3.190);
\end{tikzpicture}
\end{document}

BIN
stackexchange_test.pdf

44
stackexchange_test.tex

@ -0,0 +1,44 @@
% from this example https://tex.stackexchange.com/questions/305375/how-to-position-labels-at-edges-of-tikz-figures/305391
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,positioning}
\usepackage{amsmath,amssymb,amsfonts}
\begin{document}
\begin{tikzpicture}[>=stealth',
shorten > = 3pt,
node distance = 4cm and 4cm,
el/.style = {inner sep=2pt, align=left, sloped},
every label/.append style = {font=\tiny}
]
\node (data) [state, label=left:{label:10}] {Data};
\node (q1) [state,right=of data] {$s_1$};
\node (q2) [state,below=of q1,
label=right:{label:20}] {$s_2$};
\node (q3) [state,below=of data,
label=left:{label:5}] {$s_3$};
\path[->]
(data) edge [in=150,out=90,loop]
node[el,above] {Runs and re-runs} (data)
(data) edge [bend right=10] node[el,below] {$a=1$} (q1)
(q1) edge [bend right=10] node[el,above] {$a=0$} (data)
(q1) edge [bend right=10] node[el,below] {$a=2$} (q2)
(q2) edge [bend left=-10] node[el,below] {$a=1$} (q1)
(data) edge [bend right=10] node[el,below] {$a=3$} (q3)
(q3) edge [bend left=-10] node[el,below] {$a=0$} (data)
(data) edge [bend left= 10] node[el,above,pos=0.8] {$a=2$} (q2)
(q2) edge [bend left= 10] node[el,below,pos=0.8] {$a=0$} (data)
(q1) edge [bend left= 10] node[el,above,pos=0.75] {$a=3$} (q3)
(q2) edge [bend left= 10] node[el,below] {$a=3$} (q3)
(q1) edge [in=30, out=60,loop]
node[el,above,rotate=45] {$x=1$\\ $x:=x+1$} (q1)
(q3) edge [bend left=10] node[el,below,pos=0.75] {$a=1$} (q1)
(q3) edge [bend right=-10] node[el,above] {$a=2$} (q2)
(q2) edge [in=-30,out=-60, loop]
node[el,below,rotate=-45] {$a=2$ \\ $x:=x+1$} (q2)
(q3) edge [in=-150,out=-120, loop]
node[el,below,rotate=45] {$a=3$ \\ $x:=x+1$} (q3);
\end{tikzpicture}
\end{document}
Loading…
Cancel
Save