3

I would like to make the following figure in Tikz:

enter image description here

I have tried using the code here, but I did not succeed unfortunately.

Can anyone provide me some code to make such a picture?

Thanks in advance.

  • 2
    Which code there did you try? The answer there provides more than one method of drawing the image. And in what sense did you not succeed? Can we please see what you've got? It is a lot easier to help if we know what problem you've run into and can work from your specific starting point ;). – cfr Sep 13 '15 at 20:36

3 Answers3

6

One fairly simple-minded option:

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{positioning,arrows.meta,,bending}
\begin{document}
  \begin{tikzpicture}
    [
      >/.tip={Triangle[length=7.5pt,width=5pt,bend]},
      line width=1pt,
      my circle/.style={minimum width=10mm, circle, draw},
      my label/.style={above=10pt, anchor=mid}
    ]
    \node (1) [my circle] {$1$};
    \node (2) [my circle, right=75pt of 1] {$2$};
    \path [postaction={draw, {>[sep=5pt,reversed]}-{<[sep=5pt]}}, draw] (1) -- (2) node [very near start, my label] {$\alpha$}  node [very near end, my label] {$\beta$} ;
    \path [->, draw] (2.south east) arc (-135:135:5mm) node [near end, my label] {$1-\beta$};
    \path [->, draw] (1.south west) arc (-45:-315:5mm) node [near end, my label] {$1-\alpha$};
  \end{tikzpicture}
\end{document}

simple solution

cfr
  • 198,882
5

Maybe something like this?

enter image description here

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.text}

\begin{document}
\begin{tikzpicture}[
  node distance = 1cm and 2cm, >=latex,
  state/.style={draw, thick, circle, minimum size=8mm, inner sep=0pt},
  transitionA/.style args={#1}{very thick, ->, postaction={decorate},
    decoration={markings,
      mark=at position .8 with {\node[anchor=south,yshift=1pt] {#1};}}},
  transitionB/.style args={#1}{very thick, postaction={decorate},
    decoration={markings,
      mark=at position .26 with {\arrow{>}},
      mark=at position .2 with {\node[anchor=south,yshift=1pt] {#1};}}}
  ]

  \node[state] (1) {$1$};
  \node[state,right=of 1] (2) {$2$};

  \draw [transitionA={$1-\alpha$}] (1.south west) arc (-45:-315:4mm);
  \draw [transitionA={$1-\beta$}]  (2.south east) arc (-135:135:4mm);
  \draw [transitionB={$\alpha$}]   (1.east) -- (2.west);
  \draw [transitionB={$\beta$}]    (2.west) -- (1.east);
\end{tikzpicture}
\end{document}

Version 2 (Edit: using automata library)

enter image description here

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{arrows,automata}

\begin{document}
\begin{tikzpicture}[node distance=2cm,->,>=latex,auto,
  every edge/.append style={thick}]
  \node[state] (1) {$1$};
  \node[state] (2) [right of=1] {$2$};  
  \path (1) edge[loop left]  node{$1-\alpha$} (1)
            edge[bend left]  node{$\alpha$}   (2)
        (2) edge[loop right] node{$1-\beta$}  (2)
            edge[bend left] node{$\beta$}     (1);
\end{tikzpicture}
\end{document}
sergej
  • 6,461
  • 32
  • 62
2

Try the following:

    \documentclass[tikz]{standalone}
    \usetikzlibrary{automata,decorations.markings,positioning}

    \begin{document}
        \begin{tikzpicture}[
                >=latex,
      decoration = {markings,
                    mark=at position .3 with {\arrow {>}},
                    mark=at position .7 with {\arrowreversed {>} }
                  },
                node distance=33mm]
    \node[state]    (n1) {1};
    \node[state]    (n2) [right=of n1] {2};
    \path[->,every loop/.style={looseness=8}]
   (n1) edge [postaction={decorate}] node [pos=0.3,above] {$\alpha$}
                                     node [pos=0.7,above] {$\beta$}  (n2)
   (n1) edge [in=210,out=150,loop] node[above=11pt] {$1-\alpha$} ()
   (n2) edge [in=-30,out=30, loop] node[above=11pt] {$1-\beta$}  ();
        \end{tikzpicture}
    \end{document}

Edit: I change the loop appearance with defined in and out angle for loops, and simplify ling between state.

enter image description here

Zarko
  • 296,517