
Mein Professor hat einen Beweis für Prims Algorithmus in LaTeX geschrieben und anhand eines Diagramms veranschaulicht, wie Schnitte gemacht werden usw. Was mich interessiert, ist, wie er die Wellenlinien gemacht hat, die aus dem Kreis in der Mitte herauskommen.
https://www.uncg.edu/cmp/faculty/srtate/330.f16/primsproof.pdf
Kann mir jemand erklären, wie das gemacht wurde? Ich würde es gerne in einem Artikel reproduzieren. Danke!
Antwort1
Willkommen! Es gibt viele Möglichkeiten, eine glatte Kurve zu zeichnen. Sie können ein Diagramm mit smooth
oder verwenden smooth cycle
, oder in
und verwenden out
usw.
\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}
Zum Zeichnen der Wellenlinie können Sie einfach coil
Dekoration verwenden.
\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}
Schönere Wellenlinien finden SieHier.