# Grouping / Components in TikZ

I am creating pictures in TikZ.

Now, I have a certain C component, which consists of 4 nodes ( (a), (b), (c), (d) ).

I want to create 5 copies of this component, call them (A, B, C, D, E).

Then, I want to be able to draw lines between nodes of components. I.e.:

draw (A.a) (B.c); etc ...

My question: how do I create a "component" or a "grouping" in Tikz?

-
Can you give us a compilable code of one component with nodes so that we can play around with it and don't work on something that you might not interested in? – percusse May 4 '12 at 8:52

I think you can achieve what you want by just naming the nodes accordingly, although you can't use a dot in a node's name. Could you settle for A_b, e.g an underscore instead of a dot, at least internally? If yes, then you could do something like this:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}
\foreach \nodegroup/\x in {A/1,B/2,C/3,D/4}
{   \foreach \groupelement/\y in {a/1,b/2,c/3,d/4}
{ \pgfmathsetmacro{\positionhelper}{(\x*4+\y)*22.5}
\node[draw,circle] (\nodegroup_\groupelement) at (\positionhelper:5) {\nodegroup.\groupelement};
}
}
\draw[bend left=30,-latex] (A_a) edge (B_b);
\draw[bend left=30,-latex] (A_d) edge (C_a);
\draw[bend left=30,-latex] (C_c) edge (D_d);
\draw[bend right=90,latex-] (C_c) edge (D_d);
\end{tikzpicture}

\end{document}


-
Haha, this is too cool. – user13546 May 4 '12 at 18:45