How could I add dots at my graph at the end
1,395
Your diagram does a lot of repetitive stuff. Better use loops.
In the end I place the dots right of the last nodes of each row.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture}[
>=stealth,
semithick,
every state/.style={draw=blue,thick}
]
\foreach \i in {0,...,4}
{
\node[state] (n-\i) at (3*\i,0) {$\i$};
\node[state] (p-\i) at (3*\i,3) {$\i'$};
\draw[->] (n-\i) to[bend left] node[left] {$\alpha$} (p-\i);
\draw[->] (p-\i) to[bend left] node[right] {$\beta$} (n-\i);
}
\foreach \x in {n,p} {
\foreach \i[remember=\i as \last (initially 0)] in {1,...,4} {
\draw[->] (\x-\last) to[bend left] node[above] {$\lambda$} (\x-\i);
\draw[->] (\x-\i) to[bend left] node[below] {$\mu$} (\x-\last);
}
}
\node[right=.1cm of n-4] {$\dots$};
\node[right=.1cm of p-4] {$\dots$};
\end{tikzpicture}
\end{document}
If you don't want to place the nodes by hand, you could use a matrix.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{automata,matrix,positioning}
\begin{document}
\begin{tikzpicture}[
>=stealth,
semithick,
every state/.style={draw=blue,thick}
]
\matrix[matrix of nodes,nodes=state,row sep=2cm,column sep=2cm] (m) {
0' & 1' & 2' & 3' & 4' \\
0 & 1 & 2 & 3 & 4 \\
};
\foreach \c in {1,...,5} {
\draw[->] (m-2-\c) to[bend left] node[left] {$\alpha$} (m-1-\c);
\draw[->] (m-1-\c) to[bend left] node[right] {$\beta$} (m-2-\c);
}
\foreach \r in {1,2} {
\foreach \c[remember=\c as \last (initially 1)] in {2,...,5} {
\draw[->] (m-\r-\last) to[bend left] node[above] {$\lambda$} (m-\r-\c);
\draw[->] (m-\r-\c) to[bend left] node[below] {$\mu$} (m-\r-\last);
}
}
\node[right=.1cm of m-1-5] {$\dots$};
\node[right=.1cm of m-2-5] {$\dots$};
\end{tikzpicture}
\end{document}
Related videos on Youtube
Author by
dorothy
Updated on August 11, 2020Comments
-
dorothy over 3 years
I would like to add dots end of my graph which shows going to infinite. However, I try several times, and it does not works. The problem is the code with **, other parts are correct. Thanks My code is below:
\begin{figure}[htbp] \begin{center} \begin{tikzpicture}[->, >=stealth, auto, semithick, node distance=3cm] \tikzstyle{every state}=[fill=white,draw=blue,thick,text=black,scale=1] \node[state] (0') at (0,12) {$0\textprime$}; \node[state] (0) at (0,9) {$0$}; \node[state] (1') at (3,12) {$1\textprime$}; \node[state] (1) at (3,9) {$1$}; \node[state] (2') at (6,12) {$2\textprime$}; \node[state] (2) at (6,9) {$2$}; \node[state] (3') at (9,12) {$3\textprime$}; \node[state] (3) at (9,9) {$3$}; \node[state] (4') at (12,12) {$4\textprime$}; \node[state] (4) at (12,9) {$4$}; **\node[dots] (d) at (15,12) {$\dots$}; \node[dots] (d) at (15,9) {$\dots$};** \path (0') edge[bend left] node{$\lambda$} (1') edge[bend left] node{$\beta$} (0) (0) edge[bend left] node{$\alpha$} (0') edge[bend left] node{$\lambda$} (1) (1) edge[bend left] node{$\mu$} (0) edge[bend left] node{$\lambda$} (2) edge[bend left] node{$\alpha$} (1') (1') edge[bend left] node{$\mu$} (0') edge[bend left] node{$\beta$} (1) edge[bend left] node{$\lambda$} (2') (1) edge[bend left] node{$\mu$} (0) edge[bend left] node{$\alpha$} (1') edge[bend left] node{$\lambda$} (2) (2) edge[bend left] node{$\mu$} (1) edge[bend left] node{$\lambda$} (3) edge[bend left] node{$\alpha$} (2') (2') edge[bend left] node{$\beta$} (2) edge[bend left] node{$\mu$} (1') edge[bend left] node{$\lambda$} (3') (3') edge[bend left] node{$\mu$} (2') edge[bend left] node{$\lambda$} (4') edge[bend left] node{$\beta$} (3) (3) edge[bend left] node{$\mu$} (2) edge[bend left] node{$\alpha$} (3') edge[bend left] node{$\lambda$} (4) (4) edge[bend left] node{$\mu$} (3) edge[bend left] node{$\alpha$} (4') (4') edge[bend left] node{$\beta$} (4) edge[bend left] node{$\mu$} (3') ; \end{tikzpicture} \end{center} \end{figure} \clearpage
-
Admin over 7 yearsWelcome to TeX.SX!! Rather than posting code fragments it is better to give a full minimal working example. Currently we have to guess what packages etc you are using and this makes it much harder to help you. A MWE should start with a
\documentclass
command, have a minimal preamble and then\begin{document}...\end{document}
. The code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much more likely that they will!
-
-
dorothy about 7 yearsThanks, for your mention. Also, what should I do if I only need the horizontal line? only 0,1,2,3,4,....... Thanks
-
Henri Menke about 7 years@dorothy Well, you should remove the nodes and arrow of the upper line then.
-
dorothy about 7 yearsAlso, the part I did not figure is, this time I need mu1,mu2,mu3, and lambda0, lambda1,...
-
dorothy about 7 yearsI trying to remove it, but it keep to telling me error, if you do not mind, could you show me your code again? Thanks
-
Henri Menke about 7 years