TikZ - 自动机 - 调整一些重叠边缘的弯曲

TikZ - 自动机 - 调整一些重叠边缘的弯曲

我想调整以下输出中的一些弯曲边缘。最好的方法是什么?

在此处输入图片描述

这是我使用的代码。

\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}

\tikzset{
    ->,
    >=stealth', 
    node distance=3cm,
    every state/.style={thick}, 
    initial text =,
}

\newenvironment{tikzautomata}{
    \begin{center}
    \begin{tikzpicture}[shorten >=1pt, on grid, auto]
}{
    \end{tikzpicture}
    \end{center}
}

\begin{document}

\section*{Exercice 3.3 -- Une solution (correcte ?)}


\begin{tikzautomata}
    \node[state] 
        (0) {$0$};
    \node[state, right of=0] 
        (1) {$1$};
    \node[state, right of=1]
        (2) {$2$};

    \draw 
        (0) edge[bend left, above] node{\texttt{inc}} (1)
        (1) edge[bend left, above] node{\texttt{inc}} (2)
        (2) edge[bend left, below] node{\texttt{inc}} (0)
        (0) edge[bend left, above] node{\texttt{dec}} (2)
        (2) edge[bend left, below] node{\texttt{dec}} (1)
        (1) edge[bend left, below] node{\texttt{dec}} (0);
\end{tikzautomata}

\end{document}

答案1

您忘记写出要如何调整它。以下是猜测:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows.meta}
\tikzset{
    ->,
    >=Stealth, 
    node distance=3cm,
    every state/.style={thick}, 
    initial text =,
}
\newenvironment{tikzautomata}{
    \begin{center}
    \begin{tikzpicture}[shorten >=1pt, on grid, auto]
}{
    \end{tikzpicture}
    \end{center}
}
\begin{document}
\section*{Exercice 3.3 -- Une solution (correcte ?)}
\begin{tikzautomata}
    \node[state] 
        (0) {$0$};
    \node[state, right of=0] 
        (1) {$1$};
    \node[state, right of=1]
        (2) {$2$};
    \draw 
        (0) edge[bend left, above] node{\texttt{inc}} (1)
        (1) edge[bend left, above] node{\texttt{inc}} (2)
        (2) edge[bend left=2cm, below] node{\texttt{inc}} (0)
        (0) edge[bend left=2cm, above] node{\texttt{dec}} (2)
        (2) edge[bend left, below] node{\texttt{dec}} (1)
        (1) edge[bend left, below] node{\texttt{dec}} (0);
\end{tikzautomata}
\end{document}

带箭头的自动机图

答案2

\ncarc使用命令来做很简单pst-node:您只需选择 arcangle参数的值,即圆弧和节点线之间的角度:

\documentclass[border=6pt, svgnames]{standalone}
\usepackage{pst-node}

\begin{document}

\begin{pspicture}(-1,-2.25)(9,2.25)
\psset{unit=4cm, arrowinset=0.15, radius=0.2} 
\Cnodeput(0,0){A}{\Large 0}
\Cnodeput(1,0){B}{\Large 1}
\Cnodeput(2,0){C}{\Large 2 }
\psset{arcangle=30, arrows=->, labelsep=2pt}
\everypsbox{\ttfamily}
\ncarc{A}{B}\nbput{inc} \ncarc{B}{C}\nbput{inc}
\ncarc{B}{A}\nbput{dec} \ncarc{C}{B}\nbput{dec}
\psset{arcangle=45}
\ncarc{A}{C}\naput{dec} \ncarc{C}{A}\naput{inc}
\end{pspicture}

\end{document} 

在此处输入图片描述

相关内容