0

I'd like to draw the Cayley graph of F_2 (the free group on two generators), with a special consideration. Namely, that the index 2 subgroups (the vertices reached with an even number of movements and vertices reached with an even number of vertical/horizontal movements) are to be coloured differently. I found this wonderful post Cayley Graph of Free Group in TikZ about creating the graph, though none seemed easily amenable to what I wanted to do. Could someone please help?

  • Welcome. Please, add a drawing to what you wanted to do, exactly. – Sebastiano Jan 11 '17 at 8:41
2

This code is built from an example showcasing tikzmath

The result

enter image description here

The code

\documentclass[tikz,border=10pt]{standalone} %built from http://latex-community.org/know-how/513-tikz-math
\usetikzlibrary{math,backgrounds}
\begin{document}

% -------------------
% styles of the beads
% -------------------
\tikzset
{
  coloredBeadRoot/.style=
  {
    circle,
  },
  coloredBead/.style=
  {
    coloredBeadRoot,
    fill=\color,
    scale=\beadsize*\scale,
  }
}

\begin{tikzpicture}[scale=.3pt]
  \tikzmath{
    % --------------------------
    % the parameters of the tree
    % --------------------------
    \power=2.3; % the scale base factor
    \deviation=90; % the angle between the 3 child edges
    \numsteps=4; % number of levels
    let \startcolor=black; % the start color
    let \endcolor=black; % the end color
    let \oddcolor=red; % the odd bead color
    let \evencolor=blue; % the even bead color
    \beadsize=.2; % the scale of colored beads
    % -------------------------------------------------------------------------
    % the function that draw one edge and call itself to draw the 3 child edges
    % -------------------------------------------------------------------------
    function Branch(\x,\y,\rotate,\step){
      \step=\step-1; % stops drawing if step < 0
      if (\step >= 0) then %
      {
        \mix = int(100*\step/(\numsteps-1)); % the color mix parameter is in [0,100]
        \scale = \power^\step; % the scale factor
        { % "print" the tikz command that draw the edge
          \scoped[on background layer]
          \draw
          [
            shift={(\x pt,\y pt)},
            rotate=\rotate,
            scale=\scale,
            color=\startcolor!\mix!\endcolor,
            line width=\scale*.1 pt,
            line cap=round,
          ]
            (0,0)--(1,0) coordinate(newbase) ;
        };
        % -----------------------
        % place the colored beads
        % -----------------------
        if (isodd(\step)) then %
        {
          let \color=\oddcolor;
        }
        else
        {
          let \color=\evencolor;
        };
        {
          \node [coloredBead] at (newbase) {} ;
        };
        % --------------
        % recursive call
        % --------------
        coordinate \b;
        \b1 = (newbase); % the new base point
        for \a in {-\deviation,0,\deviation}%
        {
          Branch(\bx1,\by1,mod(\rotate+\a,360),\step); % draw one child edge
        };
      };
    };
    % --------------
    % draw root bead
    % --------------
    {
      \node 
      [
        coloredBeadRoot,
        fill=\evencolor,
        scale=\beadsize*\power^\numsteps,
      ] 
      at (0,0) {};
    };
    % ----------------------
    % draw the four branches
    % ----------------------
    for \angle in {0,90,180,-90}{
      Branch(0,0,\angle,\numsteps);
    };
  }
\end{tikzpicture}
\end{document}

Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.