通过一个顶点合并简单图

通过一个顶点合并简单图

是否可以通过一个顶点“合并”更简单的结构?比如说,在下面的简单代码中,有没有办法通过红色顶点合并两个结构?(结果应该有 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}

合并图表

相关内容