我有兴趣使用 tikz 在 latex 中输出此图表:
到目前为止我得到了这个:
我的 tikz 代码是
\begin{tikzpicture}
\node[shape=circle,draw=black] (A) at (0,0) {A};
\node[shape=circle,draw=black] (B) at (0,3) {B};
\node[shape=circle,draw=black] (C) at (2.5,4) {C};
\node[shape=circle,draw=black] (D) at (2.5,1) {D};
\node[shape=circle,draw=black] (E) at (2.5,-3) {E};
\node[shape=circle,draw=black] (F) at (5,3) {F} ;
\path [->] (A) edge node[left] {$5$} (B);
\path [->](B) edge node[left] {$3$} (C);
\path [->](A) edge node[left] {$4$} (D);
\path [->](D) edge node[left] {$3$} (C);
\path [->](A) edge node[right] {$3$} (E);
\path [->](D) edge node[left] {$3$} (E);
\path [->](D) edge node[top] {$3$} (F);
\path [->](C) edge node[top] {$5$} (F);
\path [->](E) edge node[right] {$8$} (F);
\end{tikzpicture}
我想知道如何在节点 B 和 E 之间绘制圆弧,以及如何绘制长度在中心的较粗圆弧。如能提供任何帮助,我将不胜感激
答案1
scope
一个建议,借用 David Robertson 的评论。添加了几个s,以便轻松为其中的所有节点设置相同的样式。权重设置在线的中心(因此left
,above
等被删除),并填充白色,以覆盖底层线。如果您确实想要这样,该arrows.meta
库允许您将箭头尖端设置为与线条不同的颜色。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\begin{scope}[every node/.style={circle,thick,draw}]
\node (A) at (0,0) {A};
\node (B) at (0,3) {B};
\node (C) at (2.5,4) {C};
\node (D) at (2.5,1) {D};
\node (E) at (2.5,-3) {E};
\node (F) at (5,3) {F} ;
\end{scope}
\begin{scope}[>={Stealth[black]},
every node/.style={fill=white,circle},
every edge/.style={draw=red,very thick}]
\path [->] (A) edge node {$5$} (B);
\path [->] (B) edge node {$3$} (C);
\path [->] (A) edge node {$4$} (D);
\path [->] (D) edge node {$3$} (C);
\path [->] (A) edge node {$3$} (E);
\path [->] (D) edge node {$3$} (E);
\path [->] (D) edge node {$3$} (F);
\path [->] (C) edge node {$5$} (F);
\path [->] (E) edge node {$8$} (F);
\path [->] (B) edge[bend right=60] node {$1$} (E);
\end{scope}
\end{tikzpicture}
\end{document}