TikZ:在子图之间绘制边

TikZ:在子图之间绘制边

我有这个:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{graphs, graphs.standard}

\begin{document}

\tikz
\graph [simple, nodes={draw, circle, minimum size = .5cm}, clockwise] {
  subgraph C_n [name=inner, radius = 1.5cm, n=3];
  subgraph C_n [name=outer, radius = 3cm, n=4];
};

\end{document}

在此处输入图片描述

现在我想从 的节点inner到 的节点绘制单边outer。我该怎么做?

答案1

使用名称innerouter作为节点编号的前缀:

\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs, graphs.standard}

\begin{document}

\begin{tikzpicture}
\graph [simple, nodes={draw, circle, minimum size = .5cm}, clockwise] 
{
  subgraph C_n [name=inner, radius = 1.5cm, n=3];
  subgraph C_n [name=outer, radius = 3cm, n=4];
};
\draw
 (inner 1) -- (outer 2)
 (inner 3) -- (outer 4)
 (inner 2) -- (outer 4)
 (inner 3) -- (outer 1)
 (inner 2) -- (outer 3);
\end{tikzpicture}

\end{document}

结果:

在此处输入图片描述

当然也可以使用路径edge

\path
 (inner 1) edge (outer 2)
 (inner 3) edge (outer 4)
 (inner 2) edge (outer 4)
 (inner 3) edge (outer 1)
 (inner 2) edge (outer 3);

相关内容