LaTeX TIKZ画markov转移图(有限状态机FSM图)

作业要画markov转移图,找了半天TIKZ怎么画FSM,代码记录一下

\documentclass[a4paper,UTF8]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,chains}
\begin{document}
%这里放下面的代码
\end{document}
\begin{figure}
		\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2cm,
			thick,base node/.style={circle,draw,minimum size=16pt}, real node/.style={double,circle,draw,minimum size=35pt}]
			
			
			\node[shape=circle,draw=black](0){0};
			\node[shape=circle,draw=black](1)[right of=0 ]{1};
			\node[shape=circle,draw=black](2)[right of=1 ]{2};
			\node[shape=circle,draw=black](3)[right of=2 ]{3};
			
			\path[]
			(0) edge [loop above]node {0.75} (0)
			(1) edge [loop above]node {0.75} (1)
			(2) edge [loop above]node {0.75} (2)
			
			(0) edge node {0.25} (1)
			(1) edge node {0.25} (2)
			(2) edge node {0.25} (3);%注意path只有一个分号
			
		\end{tikzpicture}
\end{figure}

在这里插入图片描述
更复杂一点的

\begin{figure}
		\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2cm,
			thick,base node/.style={circle,draw,minimum size=16pt}, real node/.style={double,circle,draw,minimum size=35pt}]
			
			
			
			\node[shape=circle,draw=black](0){0};
			\node[shape=circle,draw=black](1)[right of=0 ]{1};
			\node[shape=circle,draw=black](2)[right of=1 ]{2};
			\node[shape=circle,draw=black](3)[right of=2 ]{3};
			\node[shape=circle,draw=black](4)[right of=3 ]{4};
			\node[shape=circle,draw=black](5)[right of=4 ]{5};
			
			\path[]
			(0) edge [loop above]node {0.25} (0)
			(0) edge [bend right=100]node {0.25} (1)
			(0) edge [bend right=100]node {0.25} (2)
			(0) edge [bend right=100]node {0.25} (3)
			
			(1) edge [loop above]node {0.25} (1)
			(1) edge [bend left=100]node {0.25} (2)
			(1) edge [bend left=100]node {0.25} (3)
			(1) edge [bend left=100]node {0.25} (4)
			
			(2) edge [bend right=20]node {0.25} (1)
			(2) edge [loop above]node {0.25} (2)
			(2) edge [bend right=50]node {0.25} (3)
			(2) edge [bend right=50]node {0.25} (4)
			
			(3) edge [bend left=40]node {0.25} (1)
			(3) edge [bend right=40]node {0.25} (2)
			(3) edge [loop above]node {0.25} (3)
			(3) edge [bend left=40]node {0.25} (4)
			
			(4) edge [loop above]node {0.75} (4)
			(4) edge node {0.25} (5);
			
			
			
		\end{tikzpicture}
		
	\end{figure}

LaTeX TIKZ画markov转移图(有限状态机FSM图)_第1张图片

你可能感兴趣的:(LaTeX,latex)