3

I am having problems with spacing between branches in the following tree:

\documentclass[11pt]{article}
\usepackage{tikz} %vector art
\usetikzlibrary{snakes, matrix,shapes,arrows,positioning,chains}
\begin{document}

\tikzset{
% Two node styles for game trees: solid and hollow
solid node/.style={circle,draw,inner sep=1.5,fill=black},
hollow node/.style={circle,draw,inner sep=1.5,fill=white}
}

\begin{center}
\begin{tikzpicture}[
 scale=1.5,font=\footnotesize,
 level 1/.style={level distance=10mm,sibling distance=30mm},
 level 2/.style={level distance=15mm,sibling distance=10mm},
 level 3/.style={level distance=15mm,sibling distance=10mm}
]
% The Tree
\node(0)[solid node,label=above:{\textbf{Start}}]{} 
child{node(1)[hollow node]{$L$}
child{[black] node(11)[hollow node]{}}
child{[black] node(12)[hollow node]{}}
edge from parent node[left]{$p$}
}
child{node(2)[hollow node]{$H$}
child{[black] node(41)[hollow node, ]{}}
child{[black] node(42)[hollow node,]{}}
edge from parent node[right]{$1-p$}
};
% information set
\draw[dashed,bend right](11)to(12);
\draw[dashed,bend right](41)to(42);


\path (11) -- node (H) {$x_{1}$} (12);
\path (41) -- node {$y_{1}$} (42);


% scope env to locally redefine level 1 style
%\begin{scope}[
%  level 1/.style={sibling distance=10mm}
%]
\node(00)[below=4mm,hollow node] at (H) {$H$}
child{ node[hollow node] {}
          edge from parent node[left] {$A$}
}
child{ node[solid node, label=right:{\textbf{Start 2}}] {} 
child{node(3)[hollow node]{$L$}
child{[black] node(66)[hollow node, ]{}}
child{[black] node(77)[hollow node, ]{}}
edge from parent node[left]{$p$}
}
child{node(5)[hollow node]{$H$}
child{[black] node(6)[hollow node, ]{}}
child{[black] node(7)[hollow node, ]{}}
edge from parent node[right]{$1-p$}
}
edge from parent node[right] {$R$}
}
;
%New info set
\draw[dashed,bend right](6)to(7);
\draw[dashed,bend right](66)to(77);
\path (6) -- node (HH){$r_{2}$} (7);
\path (66) -- node (HL){$z_{2}$} (77);
\node(000)[below=4mm,hollow node] at (HH) {$L$}
child{ node[hollow node, label=below:{$\{U_{i}(c_{i1},c_{i2},0,g_{2})\}_{i=H,L}$}] {} 
          edge from parent node[left] {$A$}
}
child{ node[hollow node, label=below:{$\{U_{i}(c_{i1},c_{i1},0,0)\}_{i=H,L}$}] {} 
edge from parent node[right] {$R$}
}
;
\node(0000)[below=4mm,hollow node] at (HL) {$H$}
child{ node[hollow node, label=below:{$\{U_{i}(c_{i1},c_{i2},0,g_{2})\}_{i=H,L}$}] {} 
          edge from parent node[left] {$A$}
}
child{ node[hollow node, label=below:{$\{U_{i}(c_{i1},c_{i1},0,0)\}_{i=H,L}$}] {} 
edge from parent node[right] {$R$}
}
;
%\end{scope}
\end{tikzpicture}
\end{center}
\end{document}

I have tried to use scope so I could have local environments well-defined, and that solves the spacing problem, but at the cost of not being able to build child nodes in the way I want it: enter image description here

Anyone has a good idea on how to "fix" this spacing issue I am facing with this tree? Thank you.

  • This is a common problem with the standard TikZ tree methods. Better to use forest or tikz-qtree or the newer istgame package (for drawing game trees). What is a more efficient way to draw this tree? – Alan Munn Jan 13 '18 at 22:08
  • I will give it a try. Thank you @AlanMunn. Any ways to solve this in the environment I have it above? – Laura K Jan 13 '18 at 22:26
  • The thing is that Forest will space it for you. Otherwise, you have to do it. (Never used istgame, so don't know about that one.) If this is the only tree you need to draw, fair enough. Otherwise, it will be worth your while to learn a more powerful package. – cfr Jan 14 '18 at 3:53
4

I would recommend one of the more specialized tree drawing packages for doing this. forest or istgame might be most appropriate.

To do this manually you could could add explicit sibling distances for the L and H nodes that branch from Start 2:

\documentclass[11pt]{article}
\usepackage{tikz} %vector art
\usetikzlibrary{snakes, matrix,shapes,arrows,positioning,chains}
\begin{document}

\tikzset{
% Two node styles for game trees: solid and hollow
solid node/.style={circle,draw,inner sep=1.5,fill=black},
hollow node/.style={circle,draw,inner sep=1.5,fill=white}
}

\begin{center}
\begin{tikzpicture}[
 scale=1.5,font=\footnotesize,
 level 1/.style={level distance=10mm,sibling distance=30mm},
 level 2/.style={level distance=15mm,sibling distance=10mm},
 level 3/.style={level distance=15mm,sibling distance=10mm}
]
% The Tree
\node(0)[solid node,label=above:{\textbf{Start}}]{} 
child{node(1)[hollow node]{$L$}
child{[black] node(11)[hollow node]{}}
child{[black] node(12)[hollow node]{}}
edge from parent node[left]{$p$}
}
child{node(2)[hollow node]{$H$}
child{[black] node(41)[hollow node, ]{}}
child{[black] node(42)[hollow node,]{}}
edge from parent node[right]{$1-p$}
};
% information set
\draw[dashed,bend right](11)to(12);
\draw[dashed,bend right](41)to(42);


\path (11) -- node (H) {$x_{1}$} (12);
\path (41) -- node {$y_{1}$} (42);


% scope env to locally redefine level 1 style
%\begin{scope}[
%  level 1/.style={sibling distance=10mm}
%]
\node(00)[below=4mm,hollow node] at (H) {$H$}
child{ node[hollow node] {}
          edge from parent node[left] {$A$}
}
child{ node[solid node, label=right:{\textbf{Start 2}}] {} 
child[sibling distance=2.25in]{node(3)[hollow node]{$L$}
child{[black] node(66)[hollow node, ]{}}
child{[black] node(77)[hollow node, ]{}}
edge from parent node[left]{$p$}
}
child[sibling distance=2.25in]{node(5)[hollow node]{$H$}
child{[black] node(6)[hollow node, ]{}}
child{[black] node(7)[hollow node, ]{}}
edge from parent node[right]{$1-p$}
}
edge from parent node[right] {$R$}
}
;
%New info set
\draw[dashed,bend right](6)to(7);
\draw[dashed,bend right](66)to(77);
\path (6) -- node (HH){$r_{2}$} (7);
\path (66) -- node (HL){$z_{2}$} (77);
\node(000)[below=4mm,hollow node] at (HH) {$L$}
child{ node[hollow node, label=below:{$\{U_{i}(c_{i1},c_{i2},0,g_{2})\}_{i=H,L}$}] {} 
          edge from parent node[left] {$A$}
}
child{ node[hollow node, label=below:{$\{U_{i}(c_{i1},c_{i1},0,0)\}_{i=H,L}$}] {} 
edge from parent node[right] {$R$}
}
;
\node(0000)[below=4mm,hollow node] at (HL) {$H$}
child{ node[hollow node, label=below:{$\{U_{i}(c_{i1},c_{i2},0,g_{2})\}_{i=H,L}$}] {} 
          edge from parent node[left] {$A$}
}
child{ node[hollow node, label=below:{$\{U_{i}(c_{i1},c_{i1},0,0)\}_{i=H,L}$}] {} 
edge from parent node[right] {$ROO$}
}
;
%\end{scope}
\end{tikzpicture}
\end{center}
\end{document}

output of code

| improve this answer | |
  • That is a beauty, @AlanMunn. Thank you very much! – Laura K Jan 14 '18 at 16:47
2

Here is a solution to use the istgame package. With this package you can use \xtdistance{<lev dist>}{<sib dist>} to change the level and sibling distances.

enter image description here

\documentclass{standalone}

\usepackage{istgame}

\begin{document}   

\begin{istgame}[scale=1.5,font=\footnotesize]
\tikzset{oval node/.style={ellipse node,minimum size=1pt,inner sep=1pt}}
\xtShowEndPoints[oval node]
% The Tree
\xtdistance{10mm}{30mm}
\istroot(S)
  \istb{p}[al]  \istb{1-p}[ar]  \endist
\xtOwner(S){\textbf{Start}} % owner
\xtdistance{15mm}{10mm}
\istrooto(L)(S-1){L}
  \istb  \istb  \endist
\istrooto(H)(S-2){H}
  \istb  \istb  \endist
\xtInfoset[bend right,dashed](L-1)(L-2){$x_1$}[centered]
\xtInfoset[bend right,dashed](H-1)(H-2){$y_1$}[centered]
\xtdistance{10mm}{25mm}
\istrooto(00)([yshift=-18mm]L){H}
  \istb{A}[l]  \istb{R}[r]  \endist
% The Tree: Start 2
\xtdistance{10mm}{50mm}
\istroot(S2)(00-2)
  \istb{p}[al]  \istb{1-p}[ar]  \endist
\xtOwner(S2){\textbf{\ Start 2}}[right]
\xtdistance{15mm}{10mm}
\istrooto(L2)(S2-1){L}
  \istb  \istb  \endist
\istrooto(H2)(S2-2){H}
  \istb  \istb  \endist
\xtInfoset[bend right,dashed](L2-1)(L2-2){$z_2$}[centered]
\xtInfoset[bend right,dashed](H2-1)(H2-2){$r_2$}[centered]
\xtdistance{10mm}{25mm}
\istrooto(HH)([yshift=-18mm]L2){H}
  \istb{A}[l]{\{U_{i}(c_{i1},c_{i2},0,g_{2})\}_{i=H,L}}
  \istb{ROO}[r]{\{U_{i}(c_{i1},c_{i1},0,0)\}_{i=H,L}}
  \endist
\istrooto(LL)([yshift=-18mm]H2){L}
  \istb{A}[l]{\{U_{i}(c_{i1},c_{i2},0,g_{2})\}_{i=H,L}}
  \istb{R}[r]{\{U_{i}(c_{i1},c_{i1},0,0)\}_{i=H,L}}
  \endist
\end{istgame}
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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