答案1
\documentclass[border=10mm,tikz]{standalone}
\usetikzlibrary{automata,positioning,arrows.meta}
\begin{document}
\begin{tikzpicture}[>=Latex,shorten >=1pt,auto]
\node[state] (s_0) at(2,0) {$s_0$};
\node[state] (s_1) [above right=of s_0] {$s_1$};
\node[state] (s_2) [below right=of s_1] {$s_2$};
\node[state](s_3) [right=of s_2] {$s_3$};
\node[state] (s_4) [above right=of s_3] {$s_4$};
%\node[] (aux) [below = of s_4] {};
\node[state,draw=none] (aux) [right = of s_3] {};
\node[state] (s_5) [below right= of aux] {$s_5$};
\node[state](s_6) [right=of s_5] {$s_6$};
\path[->] (s_1) edge node {0} (s_2)
(s_3) edge node {0} (s_5);
\path[->,dashed](s_6) edge[bend right=15] node [swap,pos=.4] {$last_3(w,1)=1$} (s_1);
\draw (0,0)node[left]{2}--(s_0)--(s_2)--(s_3)--(13,0);
\draw (0,0 |- s_1)node[left]{1}--(s_1)--(s_4)--(s_4-| 13,0);
\draw (0,0 |- s_5)node[left]{3}--(s_5)--(s_6)--(s_6-| 13,0);
\end{tikzpicture}
\end{document}
答案2
对我来说这看起来像一个矩阵。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzcd}[cells={nodes={circle,draw,fill=white}},
column sep=1.4em,
execute at begin matrix={\tikzset{name=mat}},
every arrow/.append style={-stealth},
execute at end picture={
\begin{scope}[on background layer]
\foreach \X in {1,...,\the\numexpr\the\pgfmatrixcurrentrow-1}
{\draw ([xshift=1em]mat.east|-row\X) --
([xshift=-1em]mat.west|-row\X) node[left]{\X};}
\end{scope}}]
& |[alias=row1]| s_1 \arrow[dr,"0"'] & & & s_4 & &\\
|[alias=row2]| s_0 & & s_2 & s_3 \arrow[drr,"0"'] & & &\\
& & & & & |[alias=row3]| s_5 & s_6
\arrow[uulllll,dashed,bend right=10,"{\text{last}_3(w,1)=1}"']\\
\end{tikzcd}
\end{document}