1

I am attempting to show communication between states in a Markov process, basically something like this, although the arrow angles aren't of any importance, simply having that relation between the nodes : enter image description here

I have looked into TikZ (which I've never used) and have tried finding some info on the simplest way to create nodes like this, but most sources I've found seem overcomplicated for how simple a task I'm trying to accomplish. Any ideas?

2

Unless you need to do more complex stuff, you can use tikz-cd.

Output

figure 1

Code

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{figure}[!h]
\[
\begin{tikzcd}
  &   &   & 4 \arrow[dr, rightarrow] & \\
3 \arrow[r, leftrightarrow] & 1 \arrow[r, leftrightarrow] & 0 \arrow[r, rightarrow] \arrow[ur, rightarrow] & 8 \arrow[r, leftarrow] \arrow[u, leftrightarrow] & 5
\end{tikzcd}
\]
\caption{My figure}
\end{figure}
\end{document}
  • This is exactly what I was looking for, many thanks. – HavelTheGreat Jul 20 '15 at 17:21
  • @HavelTheGreat You're welcome! – Alenanno Jul 20 '15 at 17:22
2

A wide range of examples for drawing graphs with tikz can be found here. Also the pgfmanual has examples and much more information. For adjusting the images style please refer to this resources.

Here a simple matrix-based solution for your problem.

\documentclass[tikz, border=6mm]{standalone}

\usetikzlibrary{matrix}

\begin{document}
  \begin{tikzpicture}[>=latex]
    \matrix[matrix of nodes, %
            column sep=1cm, %
            row sep=1cm] (m) {
        & & & 4 & \\
        3 & 1 & 0 & 8 & 5 \\
    };
    \draw [<->] (m-2-1) -- (m-2-2);
    \draw [<->] (m-2-2) -- (m-2-3);
    \draw [->] (m-2-3) -- (m-1-4);
    \draw [->] (m-2-3) -- (m-2-4);
    \draw [<->] (m-1-4) -- (m-2-4);
    \draw [->] (m-1-4) -- (m-2-5);
    \draw [<-] (m-2-4) -- (m-2-5);
  \end{tikzpicture}
\end{document}

renderer image

  • I really appreciate the resources, I'll definitely be saving those. – HavelTheGreat Jul 20 '15 at 17:28

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.