Draw tree in tikz
Here's a version using the istgame
package which is designed specifically for drawing game theory trees. The package doesn't have a dashed stye for the dashed continuum of branches, so I've created a new command modelled on the existing istgame
continuum of branches macro \istcntm
macro. This macro is called \istcntmx
and allows you pass TikZ options to the triangle. Its syntax is otherwise identical.
\documentclass{article}
\usepackage{istgame}
\makeatletter
\ExplSyntaxOn
\NewDocumentCommand \istcntmx
{ t' O{\istdefault@grow} r() D(){0,0} O{dashed} G{} D+.{\cntmdefault@levdist}D.+{\cntmdefault@sibdist} }
{
\IfBooleanTF {#1}
{
\istCntmRootx' [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
{
\istCntmRootx [ #2 ] ( #3 ) ( #4 ) [ #5 ] + #7 .. #8 +
}
}
\NewDocumentCommand\istCntmRootx{t'O{south}r()D(){0,0}O{dashed}G{.5}D+.{\cntmdefault@levdist}D.+{\cntmdefault@sibdist}}
{
\IfBooleanTF {#1}
{
\cntmdistance{#7}{#8}
\tikzset{level~1/.style={level~distance=\cntmlevdist,sibling~ distance=\cntmsibdist]}}
\setistNullNodeStyle[]{\istdefault@nullnodesize}[]
\node (#3) at (#4) [null~node] {} [\xtgrowprime=#2] child[#5] child[#5];
\draw [#5] (#3) -- (#3-1) -- (#3-2);
\setistNullNodeStyle{\istdefault@nullnodesize}
}
{
\cntmdistance{#7}{#8}
\tikzset{level~1/.style={level~distance=\cntmlevdist,sibling~ distance=\cntmsibdist]}}
\setistNullNodeStyle[]{\istdefault@nullnodesize}[]
\node (#3) at (#4) [null~node] {} [\xtgrow=#2] child[#5] child[#5];
\draw [#5] (#3) -- (#3-1) -- (#3-2);
\setistNullNodeStyle{\istdefault@nullnodesize}
}
}
\ExplSyntaxOff
\makeatother
\setistDecisionNodeStyle[black]{6pt}
\tikzset{blue node/.style={draw=blue,fill=cyan!50,circle=6pt}}
\begin{document}
\begin{istgame}
\xtdistance{20mm}{35mm}
\istcntmx(0)+15mm..25mm+
\istroot(0)
\istb*{}[]{(a^{0},1-a^{0})}[[xshift=10pt,yshift=-8pt]right]
\endist
\istroot(1)(0-1)[blue node]<[yshift=-3pt]below>{$x_{2}$}
\istb{acc}[al]{(a^{0},1-a^{0})} \istb{not}[ar]{x_{3}}[r]
\endist
\istroot(2)(1-2)[blue node]
\istcntmx(0-1)(1-2)+15mm..25mm+
\istb*{}[]{(a^{1},1-a^{1})}[[xshift=10pt,yshift=-8pt]right]
\endist
\istroot(3)(2-1)<[yshift=-3pt]below>{$x_{4}$}
\istb{acc}[al]{(\delta_{1}a^{1},\delta_{2}(1-a^{1}))} \istb*{not}[ar]
\endist
\end{istgame}
\end{document}
Here is a starter. Run with xelatex
or use auto-pst-pdf
:
\documentclass{article}
\usepackage{pst-tree}
\newcommand\Triangle[1][black]{\TRIANGLE[#1]}
\def\TRIANGLE[#1](#2){\rput[t](#2){%
\pspolygon[linestyle=dashed](0,0)(-1.3,-1.3)(1.3,-1.3)}%
\pscircle[fillstyle=solid,fillcolor=#1](#2){5pt}}
\begin{document}
\psset{treesep=2,levelsep=2}
\psTree{\Tdot[dotsize=10pt,name=x1]}%
\psTree{\TC[radius=5pt,name=x2]_[tpos=0.8]{$(a^0,1-a^0)$}}
\TR[name=x2l]{$(a^0,1-a^0)$}^{$acc$}
\psTree{\TC[radius=5pt,name=x3]_{$not$}}
\Tdot[dotsize=10pt,name=x4]_[tpos=0.8]{$(a^1,1-a^1)$}
\endpsTree
\endpsTree
\endpsTree
\uput{10pt}[20](x1){$x_1$}%
\Triangle(x1)%
\uput{10pt}[-90](x2){$x_2$}%
\uput{10pt}[0](x3){$x_3$}%
\Triangle[cyan!40](x3)%
\end{document}
Apart from the istgame
package, which has been suggested in Alan Munn's comment, there is also the forest
package which is based on TikZ and can be used in order to draw general trees. I base my answer on this answer by @cfr, who will be able to provide a much more elegant version of this if she sees this. However, I think that already this answer illustrates some of the strengths of forest, namely that you can do things programmatically like e.g. the placement of the edge label
s, i.e. you do not have to do the repetitions by hand as in other approaches, and, what is perhaps more important, if you decide to change the typesetting of, say acc
to be upright (what I want to recommend), you do it once and not over and over.
\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{forest}
/tikz/my edge label/.style={inner sep=5pt, midway},
/tikz/c/.style n args={2}{circle,inner sep=3pt,draw,fill=#1,label=above
right:$#2$},
trian/.style={tikz={\draw[dashed]() -- ++(1,-1) --++({-2cm-3*sqrt(2)*1pt},0) -- ();}},
for tree={
l sep=4em,
s sep=8em,
anchor=center,
before typesetting nodes={
if n'=1{
if n=1{}{edge label/.wrap value={\noexpand node [my edge label,right]
{$not$} }}
}{
edge label/.wrap value={\noexpand node [my edge label,left] {$acc$} }
},
},
if n children=0{}{
circle,
draw,
}
}
[,c={black}{x_1},trian
[,c={cyan}{{(a^0,1-a^0)}},label=below:{$x_2$}
[{$(a^0,1-a^0)$}]
[,c={cyan}{{x_3}},trian
[,c={black}{{(a^1,1-a^1)}},label=below:{$x_4$}
[{$\bigl(\delta_1a^1,\delta_2(1-a^1)\bigr)$}]
[,c={black}{{x_5}},trian
[,c={cyan}{{(a^2,1-a^2)}},label=below:{$x_6$}
[{$\bigl((\delta_1)^2a^1,(\delta_2)^2(1-a^1)\bigr)$}]
[{$(0,0)$}]
]
]
]
]
]
]
\end{forest}
\end{document}