答案1
这是通过 TikZ 实现的。foreach
-loop 简化了代码。基本上,对于n
{1,...,9} 中的每个元素,我们都运行命令\filldraw (vn) circle (1pt);
。
\documentclass{article}
\usepackage{tikz
\begin{tikzpicture}
\coordinate (v1) at (0,2);
\coordinate (v2) at (1,2);
\coordinate (v3) at (2,2);
\coordinate (v4) at (0,1);
\coordinate (v5) at (1,1);
\coordinate (v6) at (2,1);
\coordinate (v7) at (0,0);
\coordinate (v8) at (1,0);
\coordinate (v9) at (2,0);
\foreach\n in {1,2,3,4,5,6,7,8,9}{\filldraw (v\n) circle (1pt);}
\draw[thick] (v7) -- (v1) -- (v3) -- (v9);
\draw[thick] (v2) -- (v5);
\draw[thick] (v6) -- (v8);
\draw (v4) -- (v5) -- (v3);
\draw (v8) -- (v9);
\draw (v1) node[anchor=south east] {$v_1$};
\draw (v2) node[anchor=south] {$v_2$};
\draw (v3) node[anchor=south west] {$v_3$};
\draw (v4) node[anchor=east] {$v_4$};
\draw (v5) node[anchor=north west] {$v_5$};
\draw (v6) node[anchor=west] {$v_6$};
\draw (v7) node[anchor=north east] {$v_7$};
\draw (v8) node[anchor=north] {$v_8$};
\draw (v9) node[anchor=north west] {$v_9$};
\draw (-1,1) node[anchor=east] {$G=$};
\end{tikzpicture}
\end{document}