6

I want to reproduce the figure below with TIKZ. The node t_i depends on its neighboring nodes, so that the further away one is in the temporal axis, the weaker the dependence becomes.

enter image description here

As you can see in the figure below, I have reproduced the structure of the graph but I do not know how to make the equations over the arrows.

enter image description here

   \documentclass[margin=5mm]{standalone}
  \usepackage{tikz}
  \usetikzlibrary{fit,positioning,arrows,automata,calc}
   \tikzset{
   main/.style={circle, minimum size = 10mm, thick, draw =black!80, node 
   distance = 10mm},
    box/.style={rectangle, draw=black!100}
   }
   \begin{document}
   \begin{tikzpicture}
   % put nodes
   \node[main,draw =red!80] (t1)   {$t_i$};
   \node[main] (t2) [right= of t1] {$t_{i+1}$};
   \node[main] (t3) [right= of t2] {$t_{i+2}$};
   \node[main] (tn) [right= of t3] {$t_{n}$};
   \node[main] (t)  [left=  of t1] {$t_{i-1}$};
   \node[main] (tt) [left=  of t]  {$t_{i-2}$};
   \node[main] (t0) [left=  of tt] {$t_{0}$};

   % make path ...
   \path (t3) -- node[auto=false]{\ldots} (tn);
   \path (tt) -- node[auto=false]{\ldots} (t0);

   % draw arrows
   \draw [->] (t1) to [out=45,in=135] (tn) node [midway,below]{$P(k=0|\lambda=i)$}; 
   \draw [->] (t1) to [out=35,in=135] (t3);
   \draw [->] (t1) to (t2);
   \draw [->] (t1) to (t);
   \draw [->] (t1) to [out=135,in=35] (tt);
   \draw [->] (t1) to [out=135,in=35] (t0);
   \end{tikzpicture} 
   \end{document}

So, if you have suggestions to make this graphic even more beautiful (structure), please do not hesitate.

Thanks

EDIT 1 I modified the code as @Ignasi suggested and I get this:

enter image description here Is there a simple way to prevent equations from crossing arrows as shown in the figure for arrow t_i to t_ {i + 1}?

     \draw [->] (t1) to [out=45,in=135] node [rotate=-5,above]{\tiny 
      $P(k=n\mid\lambda=1)$} (tn);
     \draw [->] (t1) to [out=35,in=135] node [rotate=-5,above]{\tiny 
      $P(k=i+1\mid\lambda=1)$}(t3) ;

EDIT 2 As suggested by @Ignasi, i get the following picture. However, how could I add an equation between the t_iand t_ {i + 1} ( t_i and t_{i-1})? enter image description here

Below the modified code :

           \documentclass[margin=5mm]{standalone}
           \usepackage{tikz}
           \usetikzlibrary{fit,positioning,arrows,automata,calc}
           \tikzset{
            main/.style={circle, minimum size = 10mm, thick, draw                =black!80, node distance = 10mm},
            box/.style={rectangle, draw=black!100}
           }
           \begin{document}
           \begin{tikzpicture}
              % put nodes
              \node[main,draw =red!80] (t1)   {$t_i$};
              \node[main] (t2) [right= of t1] {$t_{i+1}$};
              \node[main] (t3) [right= of t2] {$t_{i+2}$};
              \node[main] (tn) [right= of t3] {$t_{n}$};
              \node[main] (t)  [left=  of t1] {$t_{i-1}$};
              \node[main] (tt) [left=  of t]  {$t_{i-2}$};
              \node[main] (t0) [left=  of tt] {$t_{0}$};

              % make path ...
              \path (t3) -- node[auto=false]{\ldots} (tn);
              \path (tt) -- node[auto=false]{\ldots} (t0);

              % draw arrows
              \draw [->] (t1) to [out=45,in=135] node [midway, above]               {$P(k=n|\lambda=i)$} (tn); 
              \draw [->] (t1) to [out=-45,in=-135] node [midway, below]               {$P(k=i+2|\lambda=i)$}(t3);
              \draw [->] (t1) to node[midway, below] {$P(k=i+1|\lambda=i)$}               (t2);
              \draw [->] (t1) to node[midway, above] {$P(k=i-1|\lambda=i)$}(t);
              \draw [->] (t1) to [out=-135,in=-45] node [midway, below]{$P(k=i-2|\lambda=i)$}(tt);
              \draw [->] (t1) to [out=135,in=35] node [midway, above]{$P(k=0|\lambda=i)$}(t0);
           \end{tikzpicture} 
           \end{document}
  • 1
    Put the node before the end of the path: \draw [->] (t1) to [out=45,in=135] node [midway,below]{$P(k=0|\lambda=i)$} (tn); – Ignasi Jan 30 '18 at 11:44
5

It's possible to distribute links to avoid overlapping equations.

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,arrows,automata,calc}
\tikzset{
   main/.style={circle, minimum size = 10mm, thick, 
        draw =black!80, node distance = 10mm},
   box/.style={rectangle, draw=black!100}
}
\begin{document}
\begin{tikzpicture}
   % put nodes
   \node[main,draw =red!80] (t1)   {$t_i$};
   \node[main] (t2) [right= of t1] {$t_{i+1}$};
   \node[main] (t3) [right= of t2] {$t_{i+2}$};
   \node[main] (tn) [right= of t3] {$t_{n}$};
   \node[main] (t)  [left=  of t1] {$t_{i-1}$};
   \node[main] (tt) [left=  of t]  {$t_{i-2}$};
   \node[main] (t0) [left=  of tt] {$t_{0}$};

   % make path ...
   \path (t3) -- node[auto=false]{\ldots} (tn);
   \path (tt) -- node[auto=false]{\ldots} (t0);

   % draw arrows
   \draw [->] (t1) to [out=45,in=135] node [midway, above]{$P(k=n|\lambda=i)$} (tn); 
   \draw [->] (t1) to [out=-45,in=-135] node [midway, below]{$P(k=i+2|\lambda=i)$}(t3);
   \draw [->] (t1) to (t2);
   \draw [->] (t1) to (t);
   \draw [->] (t1) to [out=-135,in=-45] node [midway, below]{$P(k=i-2|\lambda=i)$}(tt);
   \draw [->] (t1) to [out=135,in=35] node [midway, above]{$P(k=0|\lambda=i)$}(t0);
\end{tikzpicture} 
\end{document}

enter image description here

Answer to EDIT 2:

Increase distance between t and side states:

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,arrows,automata,calc}
\tikzset{
   main/.style={circle, minimum size = 10mm, thick, 
        draw =black!80, node distance = 10mm},
   box/.style={rectangle, draw=black!100}
}
\begin{document}
\begin{tikzpicture}
   % put nodes
   \node[main,draw =red!80] (t1)   {$t_i$};
   \node[main] (t2) [right= 3cm of t1] {$t_{i+1}$};
   \node[main] (t3) [right= of t2] {$t_{i+2}$};
   \node[main] (tn) [right= of t3] {$t_{n}$};
   \node[main] (t)  [left= 3cm of t1] {$t_{i-1}$};
   \node[main] (tt) [left=  of t]  {$t_{i-2}$};
   \node[main] (t0) [left=  of tt] {$t_{0}$};

   % make path ...
   \path (t3) -- node[auto=false]{\ldots} (tn);
   \path (tt) -- node[auto=false]{\ldots} (t0);

   % draw arrows
   \draw [->] (t1) to [out=45,in=135] node [midway, above]{$P(k=n|\lambda=i)$} (tn); 
   \draw [->] (t1) to [out=-45,in=-135] node [midway, below]{$P(k=i+2|\lambda=i)$}(t3);
   \draw [->] (t1) to  node [midway, above] {$P(k=i+1|\lambda=i)$}(t2);
   \draw [->] (t1) to  node [midway, above] {$P(k=i-1|\lambda=i)$} (t);
   \draw [->] (t1) to [out=-135,in=-45] node [midway, below]{$P(k=i-2|\lambda=i)$}(tt);
   \draw [->] (t1) to [out=135,in=35] node [midway, above]{$P(k=0|\lambda=i)$}(t0);
\end{tikzpicture} 
\end{document}

enter image description here

  • Thanks, in fact the structure of your graph is beautiful. Please look at my second EDIT about putting equation between t_i and t_{i+1} or t_{i-1}. – FiesAtoS Jan 30 '18 at 16:26
3
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,arrows,automata,calc}
\tikzset{
  main/.style={circle, minimum size = 10mm, thick, draw =black!80, node 
    distance = 10mm},
  box/.style={rectangle, draw=black!100}
}
\begin{document}
\begin{tikzpicture}
  % put nodes
  \node[main,draw =red!80] (t1)   {$t_i$};
  \node[main] (t2) [right= of t1] {$t_{i+1}$};
  \node[main] (t3) [right= of t2] {$t_{i+2}$};
  \node[main] (tn) [right= of t3] {$t_{n}$};
  \node[main] (t)  [left=  of t1] {$t_{i-1}$};
  \node[main] (tt) [left=  of t]  {$t_{i-2}$};
  \node[main] (t0) [left=  of tt] {$t_{0}$};

  % make path ...
  \path (t3) -- node[auto=false]{\ldots} (tn);
  \path (tt) -- node[auto=false]{\ldots} (t0);

  % draw arrows
  \draw [->] (t1) to [out=75,in=135]  node [midway,above]{$P(k=n|\lambda=i)$} (tn); 
  \draw [->] (t1) to [out=35,in=135] node [midway,above]{$P(k=i + 2|\lambda=i)$}  (t3);
  \draw [->] (t1) to (t2);
  \draw [->] (t1) to (t);
  \draw [->] (t1) to [out=145,in=45] node [midway,above]{$P(k= i- 2|\lambda=i)$} (tt);
  \draw [->] (t1) to [out=105,in=45] node [midway,above]{$P(k=0|\lambda=i)$}  (t0);
\end{tikzpicture} 
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.