如何使用 tikz 创建排队节点?

如何使用 tikz 创建排队节点?

我是一名新手,正在尝试在 tikz 中重新创建 M/M/1 队列,非常感谢任何帮助。在此处输入图片描述

答案1

基本方法:

\documentclass{article}
\usepackage{tikz}

\begin{document}    

\begin{tikzpicture}[>=latex]
% the rectangle with vertical rules
\draw (0,0) -- ++(2cm,0) -- ++(0,-1.5cm) -- ++(-2cm,0);
\foreach \i in {1,...,4}
  \draw (2cm-\i*10pt,0) -- +(0,-1.5cm);

% the circle
\draw (2.75,-0.75cm) circle [radius=0.75cm];

% the arrows and labels
\draw[->] (3.5,-0.75) -- +(20pt,0);
\draw[<-] (0,-0.75) -- +(-20pt,0) node[left] {$\lambda$};
\node at (2.75,-0.75cm) {$\mu$};
\node[align=center] at (1cm,-2cm) {Waiting \\ Area};
\node[align=center] at (3cm,-2cm) {Service \\ Node};
\end{tikzpicture}

\end{document}

在此处输入图片描述

另一种选择是使用chain自动定位和矩形多部分节点:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains,shapes.multipart}

\begin{document}    

\begin{tikzpicture}[start chain=going right,>=latex,node distance=0pt]
% the rectangular shape with vertical lines
\node[rectangle split, rectangle split parts=6,
draw, rectangle split horizontal,text height=1cm,text depth=0.5cm,on chain,inner ysep=0pt] (wa) {};
\fill[white] ([xshift=-\pgflinewidth,yshift=-\pgflinewidth]wa.north west) rectangle ([xshift=-15pt,yshift=\pgflinewidth]wa.south);

% the circle
\node[draw,circle,on chain,minimum size=1.5cm] (se) {$\mu$};

% the arrows and labels
\draw[->] (se.east) -- +(20pt,0);
\draw[<-] (wa.west) -- +(-20pt,0) node[left] {$\lambda$};
\node[align=center,below] at (wa.south) {Waiting \\ Area};
\node[align=center,below] at (se.south) {Service \\ Node};
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容