[Tex/LaTex] Drawing a ring of cliques in tikz-graphs

graphicstechnical-drawingtikz-graphstikz-pgf

I'm about to draw a ring of cliques graph, with a custom number of nodes in the cliques and a custom number of cliques.

enter image description here

My first solution is to use tikz-graphs to draw the cliques, but the problem is how to tile the cliques with rotation around a center and how to add lines that connect the cliques with a path as in a)

I can draw a clique with:

\begin{tikzpicture}
\graph [nodes={draw=none, circle, fill=darkgray}, circular placement, empty nodes, n=8] { subgraph K_n [name=outer] };
\end{tikzpicture}

While, for positioning of simple nodes, something like:

\foreach \s in {22.5,112.5,202.5,292.5}
{
\node[draw, circle, rotate=\s+90,xscale=10.25,yscale=7.25] at (\s:2) {};
}

works, I don't know how to loop in this way for tikz-graphs macros.

Whi

Best Answer

Based on the last comment of the OP for n>=8, this attempt did not seek help from tikz-graph but define a macro for the cliques called single which takes 2 arguments #1= labels for different cliques in the ring, #2= number of cliques in the ring. Basically, this code uses scope environment to allocate the cliques in a circular manner and foreach loops are used extensively.

enter image description here

Code

\documentclass[]{article}  
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand\single[2]{ % #1=labels, #2= n=number of nodes
\foreach \x in {1,...,#2}{
\pgfmathsetmacro{\ang}{360/#2}
    \pgfmathparse{(\x-1)*\ang}
    \node[draw,fill=red,circle,inner sep=1pt] (#1-\x) at (\pgfmathresult:4cm) {};
  }
  \foreach \x [count=\xi from 1] in {1,...,#2}{
    \foreach \y in {\x,...,#2}{
    \path (#1-\xi) edge[-] (#1-\y);
  }
}
}

\begin{document}
\noindent
\begin{tikzpicture}
\begin{scope}[local bounding box=scope1]
\node at (0,0){$n=4$};
\end{scope}
\foreach \s[count=\si from 0] in {0,45,90,...,360}{
\begin{scope}[shift={($(scope1) +(\s:2)$)}, scale=0.1,rotate=\s+90]
\single{\si}{4};
\end{scope}
}
\foreach \i/\j in {1/2,2/3,3/4,4/5,5/6,6/7,7/8,8/1}
\draw (\i-1)--(\j-3);
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}[local bounding box=scope1]
\node at (0,0){$n=6$};
\end{scope}
\foreach \s[count=\si from 0] in {0,45,90,...,360}{
\begin{scope}[shift={($(scope1) +(\s:2)$)}, scale=0.1,rotate=\s+30]
\single{\si}{6};
\end{scope}
}
\foreach \i/\j in {1/2,2/3,3/4,4/5,5/6,6/7,7/8,8/1}
\draw (\i-2)--(\j-5);
\end{tikzpicture}

\bigskip

\noindent
\begin{tikzpicture}
\begin{scope}[local bounding box=scope1]
\node at (0,0){$n=8$};
\end{scope}
\foreach \s[count=\si from 0] in {0,45,90,...,360}{
\begin{scope}[shift={($(scope1) +(\s:2)$)}, scale=0.1,rotate=\s+90]
\single{\si}{8};
\end{scope}
}
\foreach \i/\j in {1/2,2/3,3/4,4/5,5/6,6/7,7/8,8/1}
\draw (\i-1)--(\j-5);
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}[local bounding box=scope1]
\node at (0,0){$n=10$};
\end{scope}
\foreach \s[count=\si from 0] in {0,45,90,...,360}{
\begin{scope}[shift={($(scope1) +(\s:2)$)}, scale=0.1,rotate=\s+90]
\single{\si}{10};
\end{scope}
}
\foreach \i/\j in {1/2,2/3,3/4,4/5,5/6,6/7,7/8,8/1}
\draw (\i-1)--(\j-6);
\end{tikzpicture}

\end{document}