无需初始设置即可实现自动化,3 条线上的节点

无需初始设置即可实现自动化,3 条线上的节点

在此处输入图片描述

刚开始接触 LaTex,想重新绘制一些图表

有什么办法吗?自动机是一种可行的方法吗?如何使用自动机节点设置节点位置?以及如何绘制带有描述的这些线条?

使用 tikz pgf

\begin{tikzpicture}[thick]
    \node[circle,draw] at (2,0) (q0) {$q_0$}; 
    \node[circle,draw] at (4,0) (q1) {$s_1$}; 
\node at (0,0) (1) {$1$};
\draw (1) -- (q0);
\draw (q0) -- (q1);
\end{tikzpicture}

答案1

截屏

\documentclass[border=10mm,tikz]{standalone} 
\usetikzlibrary{automata,positioning,arrows.meta}

\begin{document}
\begin{tikzpicture}[>=Latex,shorten >=1pt,auto]
\node[state] (s_0) at(2,0) {$s_0$};
\node[state] (s_1) [above right=of s_0] {$s_1$};
\node[state] (s_2) [below right=of s_1] {$s_2$};
\node[state](s_3) [right=of s_2] {$s_3$};
\node[state] (s_4) [above right=of s_3] {$s_4$};
 %\node[] (aux) [below = of s_4] {};
\node[state,draw=none] (aux) [right = of s_3] {};
\node[state] (s_5) [below right= of aux] {$s_5$};
\node[state](s_6) [right=of s_5] {$s_6$};
\path[->] (s_1) edge node {0} (s_2)
(s_3) edge node {0} (s_5);
\path[->,dashed](s_6) edge[bend right=15] node [swap,pos=.4] {$last_3(w,1)=1$} (s_1);
\draw (0,0)node[left]{2}--(s_0)--(s_2)--(s_3)--(13,0);
\draw (0,0 |- s_1)node[left]{1}--(s_1)--(s_4)--(s_4-| 13,0);
\draw (0,0 |- s_5)node[left]{3}--(s_5)--(s_6)--(s_6-| 13,0);
\end{tikzpicture}
\end{document}

答案2

对我来说这看起来像一个矩阵。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzcd}[cells={nodes={circle,draw,fill=white}},
 column sep=1.4em,
 execute at begin matrix={\tikzset{name=mat}},
 every arrow/.append style={-stealth},
 execute at end picture={
  \begin{scope}[on background layer]
   \foreach \X in {1,...,\the\numexpr\the\pgfmatrixcurrentrow-1}
     {\draw ([xshift=1em]mat.east|-row\X) -- 
      ([xshift=-1em]mat.west|-row\X) node[left]{\X};} 
  \end{scope}}] 
 & |[alias=row1]| s_1 \arrow[dr,"0"'] & & & s_4 & &\\
 |[alias=row2]| s_0 & & s_2 & s_3 \arrow[drr,"0"'] & & &\\
  & &  &  & & |[alias=row3]| s_5 & s_6 
  \arrow[uulllll,dashed,bend right=10,"{\text{last}_3(w,1)=1}"']\\
\end{tikzcd}
\end{document}

在此处输入图片描述

相关内容