I am drawing a simple graph with tikz. This works OK but when I have two edges going in opposite directions between a pair of nodes I get one arrow with two heads (for example between nodes B and D below). How can I get two arrows? Here is a MWE:
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning}
\usepackage{tkz-graph}
\usepackage{graphicx}
\begin{document}
\section{}
\begin{center}
\begin{tikzpicture}[auto,node distance=2cm,thick,main node/.style={circle,fill=blue!20,draw,font=\sffamily\Large\bfseries}, scale=2]
\node[main node, label=$0$] (A) at (0,5) {A};
\node[main node, label=$\infty$] (B) at (2,6.5) {B};
\node[main node, label=$\infty$] (E) at (4,5) {E};
\node[main node, label=$\infty$] (C) at (1,3) {C};
\node[main node, label=$\infty$] (D) at (3,3) {D};
\path [->] (A) edge node {$-1$} (B);
\path [->] (B) edge node {$2$} (E);
\path [->] (A) edge node {$4$} (C);
\path [->] (B) edge node {$3$} (C);
\path [->] (B) edge node {$2$} (D);
\path [->] (D) edge node {$1$} (B);
\path [->] (D) edge node {$5$} (C);
\path [->] (E) edge node {$-3$} (D);
\end{tikzpicture}
\end{center}
\end{document}
Best Answer
Here is a proposal using the
calc
library to shift the paths by some amount away from the center. Of course, if you do that very often, you may write a macro for that. Or you just bend the paths, as illustrated in the arrows between the B and D nodes.Off-topic but I just saw AndréC's answer and even though I generally agree with him, I'd not use a graph for that. A very simple loop is easier IMHO and shorter.