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.

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.

share|improve this question
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 '11 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 '11 at 21:56
add comment

1 Answer

  • 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

share|improve this answer
    
Thanks that's great I will try that. –  XYZ Dec 24 '11 at 22:01
add comment

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.