尝试创建二项式树

尝试创建二项式树

我很想拥有这幅二项式树绘图的精美 tikz 版本。 在此处输入图片描述

我的台词不太好,有人能帮助我吗

到目前为止我已完成以下事项:

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{pgf,tikz}
\usetikzlibrary{positioning}
\begin{document}


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

% Define styles for bags and leafs
\tikzstyle{bag} = [text width=2em, text centered]
\tikzstyle{edge from parent}=[draw]
\tikzstyle{end} = [text width=3em, text centered]
%\tikzstyle{every node}=[fill=red!30,rounded corners]



% The sloped option gives rotated edge labels. Personally
% I find sloped labels a bit difficult to read. Remove the sloped options
% to get horizontal labels. 

\begin{tikzpicture}[grow=right, sloped, edge from parent]
\node[bag] {$S_{0}$} % First bag
child{node[bag] {$S_{0}d$} % Step 1 down
   child{node[bag]{$S_{0}d^{2}$} % step 2 down
       child{node[end]{$S_{0}d^{3}$}} % step 3 down
       child{node[end] {}} % step 3 up
       }
   child{node[bag] {} % step 2 up
       child{node[end]{}} %step 3 down
       child{node[end] {}} %step 3 up
           }
  }
   child {node[bag] {$S_{0}u$} % step 1 up
      child{node[bag]{$S_{0}ud$}
          child{node[end]{$S_{0}ud^{2}$}} % step 3 down
          child{node[end]{}} % step 3 up
          } % step 2 down
        child{node[bag ]{$S_{0}u^{2}$} % step 2 up
           child{node[end]{$S_{0}u^{2}d$}} % step 3 down
           child{node[end]{$S_{0}u^{3}$}} % step 3 up
       }
  };
  \end{tikzpicture}

  \end{document}

答案1

你可以加

  edge from parent/.style={draw,
    edge from parent path={
      (\tikzparentnode.east) -- (\tikzchildnode.west)
    }
  }

在 的选项列表中tikzpicture在此处输入图片描述

相关内容