我正在尝试绘制下图,但在绘制曲线和虚线时遇到了困难。
有谁能够帮助我?
\begin{tikzpicture}[scale = 0.75]
\tikzset{roundnode/.style={thick, draw = black, fill = white, outer sep = 1.5, circle, minimum size = 10pt, scale = 0.75}}
\node[roundnode = black] (1) at (30, 2.01){$v_1$};
\node[roundnode = black] (2) at (31.91, 0.62){$v_2$};
\node[roundnode = black] (3) at (31.18, -1.63){$v_3$};
\node[roundnode = black] (4) at (28.82, -1.63){$v_4$};
\node[roundnode = black] (5) at (28.09, 0.62){$v_5$};
\node[roundnode = black] (6) at (30, -0.1){$v$};
\draw
(1) edge[-,thick] (6)
(2) edge[-,thick] (6)
(3) edge[-,thick] (6)
(4) edge[-,thick] (6)
(5) edge[-,thick] (6)
%(3) edge[-,thick] (4)
;
\end{tikzpicture}
答案1
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}[roundnode/.style={thick,
draw = black, fill = white, outer sep = 1.5, circle,
minimum size = 2em}]
\draw (0,0) node[roundnode,dashed](0){$v$}
foreach \x [evaluate=\x as \y using {144-72*\x}] in {1,...,5}
{(\y:2) node[roundnode,label={\y+90:{$\x$}}](\x){$v_{\x}$}
edge (0)
}
[shift={(4,0)}]
foreach \z [count=\x,evaluate=\x as \y using {180-72*\x}] in {3,1,3,1}
{(\y:2) node[roundnode,label={\y:{$\z$}}](p\x){}
\ifnum\x=1
edge[dashed] (1)
\else
edge[dashed] (p\the\numexpr\x-1)
\fi
} (p4) edge[dashed] (3);
\end{tikzpicture}
\end{document}
答案2
您可以在此处使用极坐标和范围,这将使定位节点和编写代码变得更加容易。我添加了一个标签,以防您想标记节点。您可以使用该bend
选项制作一条简单的曲线。
你想要这样的东西吗?
\documentclass[border=10pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[
scale = 0.75, roundnode/.style={thick, draw = black, fill = white, outer sep = 1.5pt, circle, minimum size = 15pt, inner sep = 1pt}]
\begin{scope}[every node/.style = {roundnode = black}]
\node (1) at (72:2) {$v_1$};
\node (2) at (144:2) {$v_2$};
\node (3) at (216:2) {$v_3$};
\node (4) at (288:2) {$v_4$};
\node (5) at (360:2) {$v_5$};
\node[dashed] (6) at (0:0) {$v$};
\end{scope}
\begin{scope}[every node/.style = {roundnode = black}, xshift=2.5cm]
\node[label={90:3}] (7) at (85:2) {};
\node (8) at (30:2) {};
\node (9) at (330:2) {};
\node (10) at (275:2) {};
\end{scope}
\draw[thick]
(1) edge (6)
(2) edge (6)
(3) edge (6)
(4) edge (6)
(5) edge (6)
%(3) edge (4)
;
\draw[thick, dashed]
(1) edge[bend left=5] (7)
(7) edge[bend left=10] (8)
(8) edge[bend left=10] (9)
(9) edge[bend left=10] (10)
(10) edge[bend left=5] (4)
;
\end{tikzpicture}
\end{document}