0

In graph theory, multiple arcs exist. However, the graph below gives a fused arc instead of the multiple arcs. Please, how do I separate the arcs of the tex file below? See the diagram below for clue

\begin{figure}[H]
\centering
\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=4.5cm,
   thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries}]

\node[main node] (a)  {$v_1$};
\node[main node] (b)  [below of=a]{$v_2$};

\path
(a)      [->] edge node [pos=.5,above]  [left]{14} (b) 
(b)      [->]edge node [pos=.5,below][right] {30} (a);

\end{tikzpicture}
 \end{figure}

enter image description here

Arzigoglu
  • 1,348
dupsy
  • 87
  • Unrelated: Why do you use two sets of [] in the options to the edge nodes? I mean, it works, but it only adds clutter to the code. Also, left/right overwrites below/above, and pos=0.5 is actually the default, so you might as well do \path [->] (a) edge node [left] {14} (b) (b) edge node [right] {30} (a);. (With the addition of the anchors, as in CarLaTeX's answer.) – Torbjørn T. Nov 16 '17 at 09:11
  • 1
  • 1
    @Cragfelt This is not a duplicate of the post. The OP wanted straight lines, as you can see he/she accepted my answer. – CarLaTeX Nov 16 '17 at 17:41
  • @CarLaTeX That is why it says "posible duplicate". In another hand, the post and title describes "arcs" instead of "straight lines", that only has been suggested by the image. – Cragfelt Nov 16 '17 at 17:49
  • @Cragfelt I think "arc" is a technical term from graph theory, it's not intended in a geometrical sense. – CarLaTeX Nov 16 '17 at 17:52
  • @CarLaTeX In this case, the most accurate term should be "edge", that could be interpreted as a line or arc, since it is only the connection between 2 nodes or vertices. You interpreted it as a "straight line" and I did it as an arc. No case here. – Cragfelt Nov 16 '17 at 18:19
  • 1
    @Cragfelt See here: https://math.stackexchange.com/q/31207/351554 – CarLaTeX Nov 17 '17 at 06:15
  • @CarLaTeX I have to tell you, I am more confused now than earlier. But thank you for the follow up information. Being honest, your answer was better than mine. ;) Upvote – Cragfelt Nov 17 '17 at 06:30
  • 1
    @Cragfelt People think that mathematics is an exact science, but nomenclature it's a matter of opinion :):):) Thank you for upvoting! – CarLaTeX Nov 17 '17 at 06:48

2 Answers2

2

Use anchors:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}

\begin{center}
    \begin{tikzpicture}[>=Stealth, shorten >=1pt, auto,node distance=4.5cm,
    thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries}]

    \node[main node] (a)  {$v_1$};
    \node[main node] (b)  [below of=a]{$v_2$};

    \path (a.-70) [<-] edge node [right]{30} (b.70) 
    (b.110) [<-] edge node [left] {14} (a.-110);

    \end{tikzpicture}
\end{center}
\end{document}

enter image description here

CarLaTeX
  • 62,716
0

You need to use parameter bend (with direction and an angle) within instruction edge-node to define the desired arc

\documentclass{article}
\usepackage{pgfplots}
    \usetikzlibrary{arrows}
    \pgfplotsset{compat=1.15}

\begin{document}

\begin{figure}[h]
\centering
\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=4.5cm,
  thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries}]

\node[main node] (a)  {$v_1$};
\node[main node] (b)  [below of=a]{$v_2$};

\path
(a)[->] edge [bend right=45] node [pos=.5,above] [left]{14} (b) 
(b)[->] edge [bend right=45] node [pos=.5,below] [right]{30} (a);
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

Cragfelt
  • 4,005