# How can I create a queuing node using tikz?

I am a newbie trying to recreate an M/M/1 queue in tikz and would really appreciate any help.

A basic approach:

\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}


Another option using a chain for automatic positioning and a rectangular multipart node:

\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}


• Thank you very much for the insight, do you know how I can make the queue into a node and use it to create a directional graph of queues, so essentially make the structure above into a node. Thanks! Jun 19, 2013 at 13:30
• @JamalKhan hmmm... that's something that requires a different approach. I think it would be better if you open a new question with this new requirement. Jun 19, 2013 at 14:08