1

enter image description here

Can somebody help me with this code? I tried to write it. Thank you

\begin{forest}
        el/.style={edge label={node[auto,pos=0.6]{$#1$}}},
        el'/.style={edge label={node[auto,pos=0.6,swap]{$#1$}}},
        for tree={math content,s sep+=4em,l sep+=1.5em,edge={semithick,-latex}}
        [(a,b)
        [{((D,L)},el'=(a,b)]
        [(D,R),el= (a,b)
        [{(4,4,1},el'=c]
        [{(6,0,0)},el=d]
        ]
        ]
    \end{forest}

2 Answers 2

5

You could do this with tikz-cd instead of forest.

enter image description here

\documentclass{article}
\usepackage{tikz-cd}

\tikzcdset{arrow style=tikz, diagrams={>=latex}}

\begin{document}

\[\begin{tikzcd}[row sep=1cm, column sep=0cm]
 & (5,5,2) & & (4,4,1)\\
 & & \{a,b\}\arrow[ul,"{(U,L)}"]\arrow[ur,"{(U,R)}"']\arrow[dl,"{(D,L)}"']\arrow[dr,"{(D,R)}"]\\
 & P\arrow[dl,"N"']\arrow[dr,"P"] & & (5,5,2)\\
(4,4,1) & & (6,0,0)
\end{tikzcd}\]

\end{document}
3
  • That's a nice library to use. Thanks a lot!
    – Henam
    Commented May 19, 2020 at 5:35
  • 1
    @Henam, you are very welcome. It may seem strange, but at TeX.SX we typically don't use comments for giving thanks. Instead, simply vote up answers that you find helpful.
    – Sandy G
    Commented May 19, 2020 at 13:31
  • 1
    A good answer cannot have a zero score.
    – Sebastiano
    Commented May 19, 2020 at 20:39
5

If you need to draw many game trees, another option is to use the istgame package:

enter image description here

\documentclass{standalone}

\usepackage{istgame}

\begin{document}

\begin{istgame}[->,font=\scriptsize]
\tikzset{oval node/.style={ellipse node,draw=none}}
\xtdistance{20mm}{40mm}
\istrooto'[90](0){\{a,b\}}
  \istb{(U,L)}[bl]{(5,5,2)}
  \istb{(U,R)}[br]{(4,4,1)}
  \endist
\istrooto(0){\{a,b\}}
  \istb[->-=.92]{(D,L)}[al]
  \istb{(D,R)}[ar]{(5,5,2)}
  \endist
\istrooto(1)(0-1){P}
  \istb{N}[al]{(4,4,1)}
  \istb{P}[ar]{(6,0,0)}
  \endist
\end{istgame}

\end{document}

You must log in to answer this question.

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