Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created January 21, 2016 22:53
Show Gist options
  • Save wchargin/4e3fa5a9e616c8c92a44 to your computer and use it in GitHub Desktop.
Save wchargin/4e3fa5a9e616c8c92a44 to your computer and use it in GitHub Desktop.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\newcommand{\mtsym}{\sqcup}
\pagestyle{empty}
\begin{document}
\begin{center}
\begin{tikzpicture}[auto,node distance=5mm and 5mm]
\node [state, initial above] (q0) {$q_0$};
\node [state, accepting, left=2cm of q0] (q+) {$q_\top$};
\node [state, right=2cm of q0] (q-) {$q_\bot$};
\coordinate [below=2cm of q0] (cbranch1);
\node [state, left=of cbranch1] (ql) {$q_L$};
\node [state, right=of cbranch1] (qr) {$q_R$};
\node [state, left=3cm of ql] (qdone?) {$q_\mathrm{done?}$};
\node [state, right=3cm of qr] (qend) {$q_\mathrm{end}$};
\draw [->]
(q0) edge [swap] node {$\mtsym$} (q+)
(q0) edge node {$1, \; \#$} (q-)
(q0) edge node [near end] {$0 \mapsto \#, R$} (qr)
(ql) edge node [near start] {$\# \mapsto R$} (q0)
(ql) edge [loop below] node {$0, 1 \mapsto L$} ()
(qr) edge [loop below] node {$0, 1 \mapsto R$} ()
(qr) edge node {$\mtsym, \# \mapsto L$} (qend)
(qdone?) edge node {$\#$} (q+)
(qdone?) edge node {$0, 1 \mapsto L$} (ql)
(qend) edge [swap] node {$0, \#$} (q-)
(qend) edge [bend left=45] node {$1 \mapsto \#, L$} (qdone?)
;
\end{tikzpicture}
\end{center}
\end{document}
@wchargin
Copy link
Author

Output:
Output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment