以下是我目前所拥有的:
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3.5cm,
semithick, bend angle=35]
\tikzstyle{every state}=[fill=none,draw=black,text=black,shape=circle]
\node[state] (s0) {$s_0$};
\node[state] (s1) [above left of =s0] {$s_1$};
\node[state] (s2) [below left of =s0] {$s_2$};
\path (s0) edge [bend left] node {$a$} (s1)
(s0) edge [bend right] node {$b$} (s2);
\end{tikzpicture}
我想知道是否可以在两个箭头之间添加圆弧:
任何帮助都将不胜感激,谢谢!
答案1
一个解决方案是使用intersections
库:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata}
\usetikzlibrary{arrows}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,
node distance=3.5cm,semithick, bend angle=35]
\tikzstyle{every state}=[fill=none,draw=black,text=black,shape=circle]
\node[state] (s0) {$s_0$};
\node[state] (s1) [above left of =s0] {$s_1$};
\node[state] (s2) [below left of =s0] {$s_2$};
\draw[name path=e1] (s0) to [bend left] node {$a$} (s1);
\draw[name path=e2] (s0) to [bend right] node {$b$} (s2);
\path[name path=c] (s0) circle (1);
\draw[name intersections={of=e1 and c, by=i1},
name intersections={of=e2 and c, by=i2},
-,shorten >=0pt]
(i1) to[bend right] (i2); % well, it isn't an arc
\end{tikzpicture}
\end{document}
答案2
您还可以使用该选项沿弯曲边缘创建节点pos
。因此修改代码
\begin{tikzpicture}[->,>=stealth,shorten >=1pt,auto,node distance=3.5cm,semithick, bend angle=35]
\tikzstyle{every state}=[fill=none,draw=black,text=black,shape=circle]
\node[state] (s0) {$s_0$};
\node[state] (s1) [above left of =s0] {$s_1$};
\node[state] (s2) [below left of =s0] {$s_2$};
\path (s0) edge [bend left] node[inner sep=0mm,pos=0.2] (a1) {} node {$a$} (s1);
\path (s0) edge [bend right] node[inner sep=0mm,pos=0.2] (b1) {} node {$b$} (s2);
\path[-,shorten <=-1.5pt,shorten >=0mm] (a1) edge [bend right] (b1) ;
\end{tikzpicture}
通过连接附加a1
和b1
节点可以得到类似的结果。
shorten
添加位不会改变您的一般样式设置。