7

Please could you tell me if the Probability tree posted on 2006-12-14 by Kjell Magne Fauske can be done with three branches instead of just two.

2
  • 4
    Welcome to TeX.sx! Do you mean this tree texample.net/tikz/examples/probability-tree? Exactly where do you want to add branches? You may want to add some example code to your question.
    – N.N.
    Dec 24, 2011 at 21:47
  • Yes, I do, that is the exact example. Instead of two branches coming off the first node (Bag 1) I want three.
    – XYZ
    Dec 24, 2011 at 21:56

1 Answer 1

7
  • To add another "Bag 2" branch, add another node[bag] structure.
  • To add another end branch, add another child { node[end] {}} to a node[bag] structure.

You can merely copy and paste the right parts to achieve it.

Here is a simplified example of http://www.texample.net/tikz/examples/probability-tree/ where another of each sorts of branches has been added:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}

% Set the overall layout of the tree
\tikzstyle{level 1}=[level distance=3.5cm, sibling distance=3.5cm]
\tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm]

% Define styles for bags and leafs
\tikzstyle{bag} = [text width=4em, text centered]
\tikzstyle{end} = [circle, minimum width=3pt,fill, inner sep=0pt]

\begin{tikzpicture}[grow=right, sloped]
\node[bag] {Bag 1}
    child {
        node[bag] {Bag 2}% This is the first of three "Bag 2"
        child {
                node[end] {}
            }
            child {
                node[end] {}
            }
    }
    child {
        node[bag] {Bag 2}
            child {
                node[end] {}
            }
            child {
                node[end] {}
            }
    }
    child {
        node[bag] {Bag 2}
            child {% Here are three children, hence three end branches
                node[end] {}
            }
            child {
                node[end] {}
            }
            child {
                node[end] {}
            }
    };
\end{tikzpicture}

\end{document}

Output of code

2
  • Can this be done till the second step (where it says bag 2) only? I'm trying so much time and it constantly collapses.
    – Y_gr
    Oct 28, 2015 at 17:14
  • can you do it so that on the second step all three have 3 branches Aug 10, 2019 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .