我需要一些 tikz 示例

我需要一些 tikz 示例

tikz以前从未使用过该包。现在我需要绘制以下图形的命令: 在此处输入图片描述

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}% for specifications like "left=of ..."
\usetikzlibrary{automata}% automata related stuff
\usetikzlibrary{calc}% for calculating coordinates, like ($...$)
\usetikzlibrary{arrows.meta}% arrow head Stealth[round]

% define settings common to several automata
\tikzset{FAstyle/.style={
    shorten >=1pt,% leave a thin space between arrow head and target node
    node distance=3cm,% grid size
    on grid,% arrange nodes on a grid
    auto,% automatic placements of labels
    every state/.style={% define appearance of nodes
      draw=blue!50,
      very thick,
      top color=white,
      bottom color=blue!20,
      minimum size=0pt
    },
    >=Stealth[round],
    thick,
    draw=black!50
  }
}
\begin{document}

\begin{tikzpicture}[FAstyle]
  \node[state,initial,initial text=] (S) {S};
  \node[state,right=of S] (A) {A};
  \node[state,below=of S] (B) {B};
  \node[state,accepting,right=of B] (C) {C};
  \path[->] (S) edge[bend right=20] node{a} (A)
                edge[bend right=20] node[swap]{$\lambda$} (B)
            (A) edge[bend right=20] node[swap]{a,b} (S)
                edge node[swap]{b} (B)
                edge node{$\lambda$} (C)
            (B) edge[bend right=20] node[swap]{a} (S)
                edge[bend left=20] node{b,$\lambda$} (C)
            (C) edge[bend left=20] node{a,b} (B)
  ;
  \draw ($(B)+(-1,-1)$) rectangle ($(C)+(1,1)$);
\end{tikzpicture}

\end{document}

答案2

看看下面的例子:

相关内容