尝试扩展 NFA 图中循环

尝试扩展 NFA 图中循环

我需要做从 9 到 2 的箭头以及从 12 到 2 的箭头,但我需要帮助来拉伸其他节点。

\documentclass{article}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}
\tikzset{
  ->, % makes the edges directed
%>=stealth', % makes the arrow heads bold
node distance=3cm, % specifies the minimum distance between two nodes. Change       if necessary.
every state/.style={thick, fill=gray!10}, % sets the properties for each   'state' node
initial text=$ $, % sets the text that appears on the start arrow
}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[node distance=2em]

    \node[state, initial, accepting](1){};
    \node[state, right=of 1](2){};
    \node[state, above right=of 2](3){};
    \node[state, right=of 3](4){};
    \node[state,right=of 4](5){};
    \node[state,right=of 5](6){};
    \node[state,right=of 6](7){};
    \node[state,right=of 7](8){};
    \node[state,accepting,right=of 8](9){};
    \node[state, below right =of 2](10){};
    \node[state, right =of 10](11){};
    \node[state, accepting, right=of 11](12){};
\end{tikzpicture}
\end{figure}
\end{document}

答案1

\documentclass{article}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}
\tikzset{
  ->, % makes the edges directed
>=stealth', % makes the arrow heads bold
node distance=3cm, % specifies the minimum distance between two nodes. Change       if necessary.
every state/.style={thick, fill=gray!10}, % sets the properties for each   'state' node
initial text=$ $, % sets the text that appears on the start arrow
}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[node distance=2em]

    \node[state, initial, accepting](1){};
    \node[state, right=of 1](2){};
    \node[state, above right=of 2](3){};
    \node[state, right=of 3](4){};
    \node[state,right=of 4](5){};
    \node[state,right=of 5](6){};
    \node[state,right=of 6](7){};
    \node[state,right=of 7](8){};
    \node[state,accepting,right=of 8](9){};
    \node[state, below right =of 2](10){};
    \node[state, right =of 10](11){};
    \node[state, accepting, right=of 11](12){};
    \draw (9) to[out=-135,in=5,looseness=0.6] (2);
    \draw (12) to[out=135,in=-5,looseness=0.6] (2);
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

相关内容