我有以下 MWE:
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows, automata}
\tikzset{
initial text=\(\ast\),
}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[>=stealth',thick, node distance=3cm]
\node[state, initial] (q0) {$q_0$};
\node[state, accepting, right of=q0] (q1) {$q_1$};
\draw (q1) edge[loop above] node{$1$} (q1);
\draw [->] (q0) edge[bend left, above] node{$0$} (q1);
\draw [->] (q1) edge[bend left, below] node{$1$} (q0);
\end{tikzpicture}
\end{figure}
\end{document}
我希望它看起来像这样:
有什麼方法可以得到它?
谢谢:D
!
答案1
一种方法是从相关节点的north east
/锚点中进行绘制。south east
如果你想让线条更紧密地靠在一起,你也可以使用角度锚点作为节点
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows, automata}
\tikzset{
initial text=\(\ast\),
}
\begin{document}
\begin{tikzpicture}[>=stealth',thick, node distance=3cm]
\node[state, initial] (q0) {$q_0$};
\node[state, accepting, right of=q0] (q1) {$q_1$};
\draw (q1) edge[loop above] node{$1$} (q1);
\draw (q0.north east) edge[->, above] node{$0$} (q1.north west);
\draw (q1.south west) edge[->, below] node{$1$} (q0.south east);
\end{tikzpicture}
\begin{tikzpicture}[>=stealth',thick, node distance=3cm]
\node[state, initial] (q0) {$q_0$};
\node[state, accepting, right of=q0] (q1) {$q_1$};
\draw (q1) edge[loop above] node{$1$} (q1);
\draw (q0.20) edge[->, above] node{$0$} (q1.160);
\draw (q1.200) edge[->, below] node{$1$} (q0.340);
\end{tikzpicture}
\end{document}
答案2
...如果您想要不对称轮班,或者更一般地说,自定义轮班,请考虑
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows, automata,calc}
\tikzset{
initial text=\(\ast\),
}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[>=stealth',thick, node distance=3cm]
\node[state, initial] (q0) {$q_0$};
\node[state, accepting, right of=q0] (q1) {$q_1$};
\draw (q1) edge[loop above] node{$1$} (q1);
\draw [->] ($(q0.east)+(0,11pt)$) -- node[above]{$0$} ($(q1.west)+(0,11pt)$);
\draw [->] ($(q1.west)+(0,-3pt)$) -- node[below]{$1$} ($(q0.east)+(0,-3pt)$);
\end{tikzpicture}
\end{figure}
\end{document}