![通过一个顶点合并简单图](https://linux22.com/image/437882/%E9%80%9A%E8%BF%87%E4%B8%80%E4%B8%AA%E9%A1%B6%E7%82%B9%E5%90%88%E5%B9%B6%E7%AE%80%E5%8D%95%E5%9B%BE.png)
是否可以通过一个顶点“合并”更简单的结构?比如说,在下面的简单代码中,有没有办法通过红色顶点合并两个结构?(结果应该有 9 个顶点,至少在视觉上是这样)如果没有,您能推荐一种方法吗?
\documentclass [border = 2mm] {standalone}
\usepackage{tikz}
\usetikzlibrary{ graphs, graphs.standard }
\tikzset{
myVrtxStyle/.style = { circle, minimum size= 4mm, fill = #1 },
myVrtxStyle/.default = blue
}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\graph[ nodes = {myVrtxStyle}, empty nodes ]{
subgraph C_n [n = 6, clockwise, radius = 2cm, name = left];
};
\end{scope}
\begin{scope}[xshift = 6cm]
\graph[ nodes = {myVrtxStyle = teal}, empty nodes ]{
subgraph C_n [n = 4, clockwise, radius = 2cm, name = right];
};
\end{scope}
\node [myVrtxStyle = red] at (left 3) {};
\node [myVrtxStyle = red] at (right 1) {};
\end{tikzpicture}
\end{document}
答案1
这只是一个将第二张图移动到第一张图之上的技巧:
\documentclass [border = 2mm] {standalone}
\usepackage{tikz}
\usetikzlibrary{graphs, graphs.standard, calc}
\tikzset{
myVrtxStyle/.style = { circle, minimum size= 4mm, fill = #1 },
myVrtxStyle/.default = blue
}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\graph[ nodes = {myVrtxStyle}, empty nodes]{
subgraph C_n [n = 6, clockwise, radius = 2cm, name = left];
};
\end{scope}
\begin{scope}[shift = {($(left 3)+(0,-2cm)$)}]
\graph[ nodes = {myVrtxStyle = teal}, empty nodes, ]{
subgraph C_n [n = 4, clockwise, radius = 2cm, name = right];
};
\end{scope}
\node [myVrtxStyle = red] at (left 3) {};
\node [myVrtxStyle = red] at (right 1) {};
\end{tikzpicture}
\end{document}