在图论中,存在多个弧。但是,下图给出的是融合弧而不是多个弧。请问我该如何分离下面 tex 文件中的弧?请参阅下图以获取线索
\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}
答案1
使用锚点:
\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}
答案2
您需要使用bend
指令中的参数(带有方向和角度)edge-node
来定义所需的弧
\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}