1

Is it possible to "merge" simpler structures by one vertex? Say, in my simple code below, is there a way for me to merge the two structures by the red vertex? (The result should have 9 vertices, at least visually) If not, could you please recommend a method?

\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}

enter image description here

1 Answer 1

1

This is just a hack that moves the second graph on top of the first one:

\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}

Merged graphs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .