6

This question already has an answer here:

I'd like to paint a directed graph G(V,A) with directed arcs. The problem is that if I paint 2 arcs, one from a to b and one from b to a, the two arcs get merged into one two-sided arrow (not sure if this is the correct word)

Here is some code:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\begin{document}
\tikzstyle{vertex}=[circle,fill=black!25,minimum size=20pt,inner sep=0pt]
\tikzstyle{edge} = [draw,thick,->]
\tikzstyle{weight} = [font=\small]
\begin{figure}
\begin{tikzpicture}[scale=1.8, auto,swap]
% draw the vertices
\foreach \pos/\name in {{(0,2)/a}, {(3,2)/b}}
    \node[vertex] (\name) at \pos {$\name$};
% Connect vertices with edges and draw weights
\foreach \source/ \dest /\weight in {a/b/1, b/a/2}
    \path[edge] (\source) -- node[weight] {$\weight$} (\dest);
\end{tikzpicture}
\end{figure}
\end{document}

And the result:

wrong

It should be two separate arcs (one from a to b, one from b to a).

marked as duplicate by Jake, mafp, Qrrbrbirlbel, Heiko Oberdiek, Xavier May 22 '13 at 22:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5

-- draws a straight line, if you use to[bend right] instead, you get two curved arrows.

enter image description here

\documentclass{beamer}
\usepackage{tikz}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\begin{document}
\tikzstyle{vertex}=[circle,fill=black!25,minimum size=20pt,inner sep=0pt]
\tikzstyle{edge} = [draw,thick,->]
\tikzstyle{weight} = [font=\small]
\begin{figure}
\begin{tikzpicture}[scale=1.8, auto,swap]
% draw the vertices
\foreach \pos/\name in {{(0,2)/a}, {(3,2)/b}}
    \node[vertex] (\name) at \pos {$\name$};
% Connect vertices with edges and draw weights
\foreach \source/ \dest /\weight in {a/b/1, b/a/2}
    \path[edge] (\source) to[bend right] node[weight] {$\weight$} (\dest);
\end{tikzpicture}
\end{figure}
\end{document}

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