嘗試擴展 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}

在此輸入影像描述

相關內容