答案1
如上所述在评论中您可以automata
在此处使用该库。您可能希望使用foreach
循环来避免重复。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,automata,positioning,quotes}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,>={Stealth[round]},
every state/.style={draw},blue!60,text=black]
\path node[state,double] (S_0) {$S_0$}
foreach \X [count=\Y] in {0,1}
{node[state,right=of S_\X] (S_\Y) {$S_\Y$}};
\path foreach \X [count=\Y] in {0,1}
{(S_\X) edge[bend right,->,"\the\numexpr1-\X"'] (S_\Y)
(S_\X) edge[bend left,<-,"\the\numexpr1-\X"] (S_\Y)}
(S_2) edge [loop right,"1"] ()
(S_0) edge [loop above,"0",rotate=45] ()
(S_0) edge [<-] ++ (-1,0);
\end{tikzpicture}
\end{document}