22

I am not a regular user of TikZ, and I was wondering if there was a quick way of drawing trees that look like

this ?

(the picture seems to have been taken from page 71 of J. P. Serre's book on trees).

Here is some motivation for my quiry: I am using some elementary rank-one Bruhat--Tits theory in a project that I'm currently writing up, and I feel it would be nicer with some pictures (the main reason I'm using trees rather than matrix computations is to make things more understandable).

  • 1
    You should be able to do this with TikZ and a Lindenmayer system. See Chapter 33 of the TikZ/pgf manual (version 2). – user10274 Sep 30 '13 at 12:32
  • 1
    The second proper name brought me here... – jub0bs Sep 30 '13 at 15:45
26

The trees library provides a grow cyclic key/growth function.

A few styles for the levels and a few child foreach path operators give you the following.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[
  grow cyclic,
  level distance=1cm,
  level/.style={
    level distance/.expanded=\ifnum#1>1 \tikzleveldistance/1.5\else\tikzleveldistance\fi,
    nodes/.expanded={\ifodd#1 fill\else fill=none\fi}
  },
  level 1/.style={sibling angle=120},
  level 2/.style={sibling angle=90},
  level 3/.style={sibling angle=90},
  level 4/.style={sibling angle=45},
  nodes={circle,draw,inner sep=+0pt, minimum size=2pt},
  ]
\path[rotate=30]
  node {}
  child foreach \cntI in {1,...,3} {
    node {}
    child foreach \cntII in {1,...,2} { 
      node {}
      child foreach \cntIII in {1,...,2} {
        node {}
        child foreach \cntIV in {1,...,2} {
          node {}
          child foreach \cntV in {1,...,2} {}
        }
      }
    }
  };
\end{tikzpicture}
\end{document}

Output

enter image description here

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.