答案1
使用 tikz 的矩阵库作为杰维说出来:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes, nodes={shape=circle, draw=black}, row sep=1cm, column sep=1cm] (m)
{
Y & P & P & P \\
R & B & G & Y \\
P & Y & R & R \\
};
\foreach \n in {1,...,4}
{
\draw (m-1-\n) -- (m-2-\n);
\draw (m-2-\n) -- (m-3-\n);
}
\foreach \y/\z in {1/2,2/3,3/4}
{
\draw (m-2-\y) -- (m-2-\z);
}
\end{tikzpicture}
\end{document}
答案2
更加丰富多彩...
\documentclass[tikz]{standalone}
\usetikzlibrary[backgrounds,chains,positioning]
\begin{document}
\begin{tikzpicture}[
node distance = 12mm and 13mm,
start chain = going right,
vrtx/.style = {circle, draw=#1, fill=#1!50, outer sep=0pt,
on chain}
]
\foreach \i/\j [count=\k from 1] in {yellow/Y, purple/P, purple/P, purple/P}
\node (v1\k) [vrtx=\i] {\j};
\foreach \i/\j [count=\k from 1] in {red/R, blue/B, green/G, yellow/Y}
\node (v2\k) [vrtx=\i,below=of v1\k] {\j};
\foreach \i/\j [count=\k from 1] in {purple/P, yellow/Y, red/R, red/R}
\node (v3\k) [vrtx=\i,below=of v2\k] {\j};
\scoped[on background layer]
\draw (v11) -- (v31) (v12) -- (v32)
(v13) -- (v33) (v14) -- (v34)
(v21) -- (v24);
\end{tikzpicture}
\end{document}