我需要在圆形路径上定位自动机的某些状态,使用右、上、左、左上和其他典型的相对替换选项来定位既不容易也不精确。
有没有办法引入一条任意路径来定位状态,而不是典型的网格状结构?...
以下是一个示例:
\documentclass[letter, 11pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata, positioning}
\begin{document}
\begin{center}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting, initial where=above] (s_00) {$s_{00}$};
\node[state] (s_23) [above = of s_00] {$s_{23}$};
\node[state,accepting] (s_03) [left = of s_23] {$s_{03}$};
\node[state,accepting] (s_02) [above = of s_03] {$s_{02}$};
\node[state] (s_10) [right = of s_00] {$s_{10}$};
\node[state] (s_22) [left = of s_00] {$s_{22}$};
\node[state] (s_13) [left of = s_22] {$s_{13}$};
\node[state,accepting] (s_01) [left of = s_13] {$s_{01}$};
\node[state] (s_14) [below of = s_01] {$s_{14}$};
\node[state,accepting] (s_04) [below of = s_14] {$s_{04}$};
\node[state,accepting] (s_11) [below of = s_04] {$s_{11}$};
\node[state] (s_20) [below = of s_22] {$s_{20}$};
\node[state,accepting] (s_21) [below of = s_20] {$s_{21}$};
\node[state] (s_12) [below of = s_21] {$s_{12}$};
\node[state] (s_24) [below of = s_13] {$s_{24}$};
\path[->]
(s_00) edge [out=340, in=270] node {$a$} (s_11)
edge node {$b$} (s_22)
(s_01) edge node {$a$} (s_14)
edge node {$b$} (s_24)
(s_02) edge [in=180, out=180, swap] node {$a$} (s_14)
edge node {$b$} (s_23)
(s_03) edge [out=180, in=180, swap] node {$a$} (s_11)
edge node {$b$} (s_22)
(s_04) edge node {$a$} (s_14)
edge node {$b$} (s_24)
(s_10) edge node {$a$} (s_21)
edge [bend right, swap] node {$b$} (s_02)
(s_11) edge node {$a$} (s_24)
edge node {$b$} (s_04)
(s_12) edge node {$a$} (s_24)
edge [out=0, in=90] node {$b$} (s_03)
(s_13) edge [out=0, in=0] node {$a$} (s_21)
edge node {$b$} (s_01)
(s_14) edge node {$a$} (s_24)
edge node {$b$} (s_04)
(s_20) edge node {$a$} (s_24)
edge node {$b$} (s_22)
(s_21) edge node {$a, b$} (s_24)
(s_22) edge node {$a$} (s_24)
edge node {$b$} (s_23)
(s_23) edge [in=70, out=0] node {$a$} (s_21)
edge node {$b$} (s_22)
(s_24) edge [loop above] node {$a, b$} ();
\end{tikzpicture}
\end{center}
\end{document}
我将把 s_24 放在中间,并在它周围排列一些其他状态(例如 s_11、s_04、s_14、s_01、s_22、s_20、s_21、s_12),形成一个圆形(或通常是任意形状)。
答案1
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{automata, positioning, calc}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting, initial where=above] (s_00) {$s_{00}$};
\foreach \i [count=\ni] in {0,30,60,...,330}
\node[state] (s_\ni) [above right = {2*sin(\i)} and {2*(cos(\i)} of s_00] {$s_{\ni}$};
\end{tikzpicture}
\end{document}