Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to acheive something of this sort, (without the bounding boxes):

Binomial tree diagram

Here, the first child has a straight line from the parent, and the following ones are diagonal.

What tikzset settings will allow that, or how would I go about acheiving this, and where can I learn more about it for the future?

currently I have:

\tikzset{every tree node/.style={minimum width=2em,draw,circle},
         blank/.style={draw=none},
         edge from parent/.style=
         {draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}},
         level distance=1.5cm}

which I got from a post on tex.sx without knowing too much about how it works.

share|improve this question
1  
If you're willing to use a different tree-package, you could take a look at forest. There is a similar example on page 6 of the manual. –  Torbjørn T. Apr 7 at 10:27
    
@TorbjørnT. Would be open to try. –  NightRa Apr 7 at 10:32
    
@TorbjørnT. forest looks way better for my use case. Alot of thanks for mentioning it! –  NightRa Apr 7 at 10:35

2 Answers 2

up vote 3 down vote accepted

Using the forest package, you can define a style, which we will call here B, and then apply it to every tree:

\documentclass[a4paper]{article}
\usepackage{forest}

\forestset{
    B/.style={for tree={calign=last, circle,draw}}
}

\begin{document}
\begin{forest}
B
[9 
  [6
    [4
      [3]
    ]
    [2]
  ]
  [5
    [1]
  ]
  [7]
]
\end{forest}
\end{document}

Result:

Rendered binomal tree

share|improve this answer

Another alternative via tikz tree. Here an event style is defined for each node to have a circle shape.

enter image description here

Code

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}

\begin{document}

\begin{tikzpicture}
 [event/.style={circle,thick,draw,text width=0.6cm, text centered,font=\sffamily,anchor=north},
 edge from parent/.style={very thick,draw=black!70},
 ]
 \node (g) [event] {} 
       child {node[event,below= 1cm of g] (e3) {}}
       child {node[event,left=1cm of e3] (e2) {} 
                child {node[event, below=1cm of e2] (e21) {}    
                      }
             }           
       child {node[event,left=1cm of e2] (e1){}
                child {node[event,below= 1cm of e1] (e11) {} 
                      }
                child {node[event,left=1cm of e11]  (e12) {}
                          child[event]{node[event]{}}
                      }
             };  
\end{tikzpicture}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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