# Parallel edges between states in Tikz

I have a Markov Chain and I want to draw two parallel edges between two states. I can do it if I bend left/bend right the edges but I want them to be straight and parallel. All solutions that I see on the site either concern bend or have too complicated code (for something seemingly too simple). I have many transitions, so I need something that is simple and works. Thanks in advance.

Below a mwe with the edges overlapping:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata,arrows,positioning}

\begin{document}
\begin{tikzpicture}
\node[state](a) {$a$};
\node[state,right=of a] (b) {$b$};
\draw[every loop]
(a) edge[auto=right] node {$\lambda$} (b)
(b) edge[auto=right] node {$\mu$} (a);
\end{tikzpicture}
\end{document}


A few possibilities. Manual or with new (?) styles.

\documentclass{article}
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{automata,arrows,positioning,calc}

\begin{document}
\begin{multicols}{2}
\begin{tikzpicture}
\node[state](a) {$a$};
\node[state,right=of a] (b) {$b$};
\draw
(a.-10) edge[auto=right,->] node {$\lambda$} (b.190)
(b.170) edge[auto=right,->] node {$\mu$} (a.10);
\end{tikzpicture}

\subsection*{Bend}
\begin{tikzpicture}
\node[state](a) {$a$};
\node[state,right=of a] (b) {$b$};
\draw
(a) edge[bend right=10,auto=right,->] node {$\lambda$} (b)
(b) edge[bend right=10,auto=right,->] node {$\mu$} (a);
\end{tikzpicture}

\vfill\null\columnbreak
\section*{Automatic options}
\subsection*{Auto rotate}
\tikzset{auto rotate/.style={auto=right,->,
to path={let \p1=(\tikztostart),\p2=(\tikztotarget),
\n1={atan2(\y2-\y1,\x2-\x1)},\n2={\n1-10},\n3={\n1+190}
in (\tikztostart.\n2) -- (\tikztotarget.\n3) \tikztonodes}}}
\begin{tikzpicture}
\node[state](a) {$a$};
\node[state,right=of a] (b) {$b$};
\node[state,above=of b] (c) {$c$};
\draw
(a) edge[auto rotate] node {$\lambda$} (b)
(b) edge[auto rotate] node {$\mu$} (a);
\draw
(b) edge[auto rotate] node {$\lambda$} (c)
(c) edge[auto rotate] node {$\mu$} (b);
\end{tikzpicture}

\subsection*{Auto shift}
\tikzset{auto shift/.style={auto=right,->,
to path={ let \p1=(\tikztostart),\p2=(\tikztotarget),
\n1={atan2(\y2-\y1,\x2-\x1)},\n2={\n1+180}
in ($(\tikztostart.{\n1})!1mm!270:(\tikztotarget.{\n2})$) --
($(\tikztotarget.{\n2})!1mm!90:(\tikztostart.{\n1})$) \tikztonodes}}}
\begin{tikzpicture}
\node[state](a) {$a$};
\node[state,right=of a] (b) {$b$};
\node[state,above=of b] (c) {$c$};
\draw
(a) edge[auto shift] node {$\lambda$} (b)
(b) edge[auto shift] node {$\mu$} (a);
\draw
(b) edge[auto shift] node {$\lambda$} (c)
(c) edge[auto shift] node {$\mu$} (b);
\end{tikzpicture}
\end{multicols}
\end{document}


• Thank you. Do you know why the first solution produces an arrow on the circle around state b? – Jimmy R. Aug 31 '18 at 13:55
• @JimmyR. Yes, because I was not careful enough to erase [every loop]. Will fix it ASAP. – user121799 Aug 31 '18 at 14:00
• @JimmyR. I fixed it and added more automatic solutions. – user121799 Aug 31 '18 at 14:20
• Thanks a lot +1 for the nice answer! If I implement it in my .tex file and it works fine, then I will accept too! Thanks again! – Jimmy R. Sep 1 '18 at 15:41

Markov chains can be simply draw by use of the tikz-cd package. for example:

\documentclass[border=3mm]{standalone}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[cells={nodes={circle, draw=gray,
minimum size=3ex, inner sep=1pt, anchor=center}}
]
a   \ar[r, bend left, "\lambda"]
&
b   \ar[l, bend left, "\mu"]
\end{tikzcd}

\begin{tikzcd}[cells={nodes={circle, draw=gray,
minimum size=3ex, inner sep=1pt, anchor=center}}
]
a   \ar[r, shift left, "\lambda"]
&
b   \ar[l, shift left, "\mu"]
\end{tikzcd}
\end{document}