連接點時如何製作波浪線?

連接點時如何製作波浪線?

我的教授用LaTeX寫了一個關於Prim演算法的證明,並用圖表來說明如何進行切割等。

https://www.uncg.edu/cmp/faculty/srtate/330.f16/primsproof.pdf

誰能解釋這是如何完成的?我想在論文中重現它。謝謝!

答案1

歡迎!繪製平滑曲線的方法有很多種。您可以使用帶有smoothor 的繪圖smooth cycle,或使用inandout等。

\documentclass[tikz,border=3mm]{standalone}

\begin{document}
\begin{tikzpicture}[bullet/.style={circle,fill,inner sep=1.4pt}]
  \draw[semithick]  plot[smooth cycle,looseness=1.3] coordinates 
  {(0,1) (0.5,0.7) (1.2,0.9) (2,1.3) (2.5,1.2) (3.6,1.1) (3.7,2.2)
  (3,3.2) (1.6,2.9) (0.3,2.5)  };
 \draw[semithick] 
  (1,1.7) node{$W$}
  (2.8,2.6) node[bullet,label=above left:$a$](a){}
  (a) +(20:1.2)   node[bullet,label=above right:$b$](b){}
  (2.8,1.5) node[bullet,label=left:$x$](x){}
  (x) +(-10:1.2)   node[bullet,label=below right:$y$](y){}
  (x) to[out=60,in=-60] (3,1.9) to[out=120,in=-120] (a) 
  -- (b) to[out=-80,in=90] (3.4,1.9)
  to[out=-90,in=100] (y) -- (x);
\end{tikzpicture}
\end{document}

在此輸入影像描述

要繪製波浪線,您可以使用coil裝飾。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,fill,inner sep=1.4pt,outer sep=0pt}]
  \draw[semithick]  plot[smooth cycle,looseness=1.3] coordinates 
  {(0,1) (0.5,0.7) (1.2,0.9) (2,1.3) (2.5,1.2) (3.6,1.1) (3.7,2.2)
  (3,3.2) (1.6,2.9) (0.3,2.5)  };
 \draw[semithick] 
  (1,1.7) node{$W$}
  (2.8,2.6) node[bullet,label=above left:$a$](a){}
  (a) +(20:1.2)   node[bullet,label=above right:$b$](b){}
  (2.8,1.5) node[bullet,label=left:$x$](x){}
  (x) +(-10:1.2)   node[bullet,label=below right:$y$](y){}
   (a) 
  -- (b) to[out=-80,in=90] (3.4,1.9)
  to[out=-90,in=100] (y) -- (x);
  \draw[thick,blue,decorate,decoration={coil,aspect=0,segment length=5.9mm}] (x) -- (a);
\end{tikzpicture}
\end{document}

在此輸入影像描述

可以找到更好的波浪線這裡

相關內容