我试图在边缘添加文本标题,但无法使其工作。
\begin{tikzpicture}[shorten >=1pt,-]
\tikzstyle{vertex}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]
\foreach \name/\angle/\text in {P-0/234/0, P-1/162/1,
P-2/90/2, P-3/18/3, P-4/-54/4}
\node[vertex,xshift=6cm,yshift=.5cm] (\name) at (\angle:1.5cm) {$\text$};
\foreach \from/\to in {0/4, 4/1,1/2,2/4,0/3}
{
\draw (P-\from) -- (P-\to);
}
\end{tikzpicture}
有人能帮帮我吗?谢谢!
答案1
例如,\draw (P-\from) -- node {\from\ to \to} (P-\to);
您可以使用更多选项来更改样式:
\draw (P-\from) -- node[auto,sloped,font=\footnotesize] {\from\ to \to} (P-\to);