2

I want to draw an image like this with TIKZ.

Image

I want to convert the Squares to rectangles, thus I am using Tikz. However, I am unable to draw those dots in TIKZ. Here is the code that I have written.

\begin{tikzpicture}[%
   ->, 
   >=stealth',
   shorten >=1pt,
   node distance=2cm,
   thick,
   every state/.style={%
   fill=white,
   draw=black,
   text=black
  }   
  ]

    \node[state] (A) {$A$};

    \node[state] (B1) [right of=A] {$B$};
    \node[state] (B2) [above of=B1] {$B$};
    \node[state] (B3) [below of=B1] {$B$};
    \node[state] (B4) [below of=B3,node distance=4cm] {$B$};
    \node[state] (B5) [above of=B1,node distance=4cm] {$B$};

    \draw[below of=B5]  node {...};

    \node[state] (C1) [right of=B1] {$C$};
    \node[state] (C2) [right of=B2] {$C$};
    \node[state] (C3) [right of=B3] {$C$};

    \node[state] (D) [right of=C1] {$D$};

    \path (A) edge node [above, xshift=-1mm,very near start] {$N$} node [above, xshift=1mm,very near end] {$1$} (B1)
          (A) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (B2)
          (A) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (B3)
          (B1) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (C1)
          (B2) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (C2)
          (B3) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (C3)
          (C1) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (D) 
          (C2) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (D) 
          (C3) edge node [above, xshift=-1mm,very near start] {$1$} node [above, xshift=1mm,very near end] {$1$} (D);

% Hard-coded the token location since i don't know about it.
 % \fill[black] (0.00,1.00) circle  (2pt);
  %\fill[black] (3.00,1.00) circle  (2pt);
  %\fill[black] (6.00,1.00) circle  (2pt);
  \end{tikzpicture}

Can anyone please show me how to make it work?

1 Answer 1

5

I figured it out with the option $\ldots$, we can draw the dots and the other option draw=none does not draw the circle for that node.

In case anyone needs, here is the code

\begin{tikzpicture}[%
   ->, 
   >=stealth',
   shorten >=1pt,
   node distance=1.75cm,
   thick,
   every state/.style={%
   fill=white,
   draw=black,
   text=black
  }   
  ]

    \node[state] (A) {$A$};

    \node[state] (B1) [right of=A,node distance=3cm] {$B$};
    \node[state] (B2) [above of=B1] {$B$};
    \node[state] (B3) [below of=B1] {$B$};

    \node[state] (B6) [above of=B2,draw=none,node distance=1cm] {$\ldots$};
    \node[state] (B5) [above of=B6,node distance=1cm] {$B$};

    \node[state] (B7) [below of=B3,draw=none,node distance=1cm] {$\ldots$};
    \node[state] (B4) [below of=B7,node distance=1cm] {$B$};


    \node[state] (C1) [right of=B1] {$C$};
    \node[state] (C2) [right of=B2] {$C$};
    \node[state] (C3) [right of=B3] {$C$};

    \node[state] (C6) [above of=C2,draw=none,node distance=1cm] {$\ldots$};
    \node[state] (C5) [above of=C6,node distance=1cm] {$C$};

    \node[state] (C7) [below of=C3,draw=none,node distance=1cm] {$\ldots$};
    \node[state] (C4) [below of=C7,node distance=1cm] {$C$};

    \node[state] (D) [right of=C1,node distance=3cm] {$D$};

    \path (A)  edge (B1)
          (A)  edge (B2)
          (A)  edge (B3)
          (A)  edge (B4)
          (A)  edge (B5)
          (B1) edge (C1)
          (B2) edge (C2)
          (B3) edge (C3)
          (B4) edge (C4)
          (B5) edge (C5)
          (C1) edge (D) 
          (C2) edge (D) 
          (C3) edge (D) 
          (C4) edge (D) 
          (C5) edge (D);
\end{tikzpicture}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .