答案1
始终发布可编译的代码,这样其他人就不必猜测您如何制作节点、弯曲等,并帮助其他人帮助您。
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node[draw, circle](q2){q2};
\draw (0,-2) node[draw, circle](q3){q3};
\draw[->] (q2) edge[bend left] node[midway, color=red, fill=white]{1} (q3);
\end{tikzpicture}
\end{document}
答案2
通过使用quotes
图书馆:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}[
C/.style = {circle, draw},
every edge quotes/.style = {fill=white, font=\footnotesize, inner sep=2pt, anchor=center}
]
\node (q2) [C] {q2};
\node (q3) [C] at (0,-2) {q2};
\draw[->] (q2) to[color=red, bend left, "1"] (q3);
\end{tikzpicture}
\end{document}