Code for binomial tree does not work after one year

You just have change all

\node[hn]{};

to

|[hn]|

and similar for sn nodes. When \node is used at the start of the cell, it is not named automatically, but you can add options to a cell using |[...]| instead.

That said, there are probably much better, more convenient ways of drawing a tree like that. I'm no tree-expert though, so I'll leave that to others.

A couple of other comments:

  • \draw[-] (tree-6-1)--(tree-5-2){};: Both [-] and the {} at the end are not needed.
  • It is generally recommended to use \tikzset{stylename/.style={...}} instead of tikzstyle. For this case though, where you're defining the styles inside the tikzpicture, I'd just do

    \begin{tikzpicture}[>=stealth,sloped,
       hn/.style={circle,draw,inner sep=0.01},
       sn/.style={circle,draw,inner sep=0.01,fill=black}]
    

Here's is one of the more convenient ways of drawing the graph mentioned by Torbjørn T.. The diagram is not technically a tree. Hence, my attempts to typeset it as a tree met with only partial success. However, using the modular Sugiyama layout algorithm, as implemented by TikZ, produced satisfactory results.

Because this uses automated algorithms to layout the tree, it requires LuaTeX. If you get errors because you do not have luatex85.sty, simply remove the line \RequirePackage{luatex85} as this is only required for quite recent versions of the engine. You probably don't need to load the package anyway if you use a standard class rather than standalone.

\RequirePackage{luatex85}
\documentclass[multi,tikz,border=10pt]{standalone}
\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
\begin{document}
\begin{tikzpicture}
  \graph [layered layout, grow=0, sibling distance=10mm, nodes={circle, draw, as= }]
  {
    0  -- { 11 -- { 21 -- { 31 -- { 41[fill] -- { 51[fill], 52[fill] }, 42 -- { 52, 53[fill] } } , 32 -- { 42, 43 -- { 53, 54[fill] } } } , 22  -- { 32 , 33 -- { 43, 44[fill] -- { 54, 55[fill] } } } } , 12 -- { 22 , 23[fill] -- { 33, 34[fill] -- { 44, 45[fill] -- { 55, 56[fill] } } } } }
  }
  ;
\end{tikzpicture}
\end{document}

layered graph

Tags:

Tikz Trees