Skip to content

Instantly share code, notes, and snippets.

@trcook
Created January 22, 2015 03:47
Show Gist options
  • Save trcook/14ad4f409b66788a6697 to your computer and use it in GitHub Desktop.
Save trcook/14ad4f409b66788a6697 to your computer and use it in GitHub Desktop.
This is a good basic template for drawing a tikz picture tree.
% place in preamble:
%\usetikzlibrary{trees}
%\usetikzlibrary{decorations.text}
\begin{figure}[htb]
\centering
\ffigbox[\FBwidth]{\caption{Alliance Decisions in An incomplete information framework}
\label{}}{
\begin{tikzpicture}
% various formatting follows:
[font=\footnotesize,
grow=right,
level 1/.style={sibling distance=6em},
level 2/.style={sibling distance=1em}, level distance=3cm,
level 3/.style={sibling distance=5em}]
% begin tree
\node[circle,draw] (N) {N} % root
% nature pushes to holder on right (reliable type)
% BEGIN RIGHT SIDE
child [grow=right]{
node (reliable_holder) {Holder}
% BEGIN UPPER RIGHT SIDE
child [grow=up]{
node (reliable_signaled) {Observer}
child{
node (reliable_signaled_accept){$(x+y,z)$}
edge from parent node [right] {accept}
}
child{
node (reliable_signaled_reject){}
edge from parent node [left] {reject}
}
}
% UPPER RIGHT SIDE END
% BEGIN LOWER RIGHT SIDE
child [grow=down]{
node (reliable_not_signaled) {Observer}
child[]{
node (reliable_not_signaled_reject) {}
edge from parent node [left] {accept}
}
child[]{
node (reliable_not_signaled_accept) {}
edge from parent node [right] {reject}
}
}
}
% LOWER RIGHT SIDE END
% RIGHT SIDE END
% BEGIN LEFT SIDE
child[grow=left]{node(unreliable_holder){Holder}
% BEGIN UPPER LEFT SIDE
child [grow=up]{
node (not_reliable_signaled) {Observer}
child{
node {}
edge from parent node[right] {reject}
}
child{
node {}
edge from parent node[left] {accept}
}
}
% UPPER LEFT SIDE END
% BEGIN LOWER LEFT SIDE
child [grow=down]{node (not_reliable_not_signaled) {Observer}
child{
node (not_reliable_not_signaled_reject) {}
edge from parent node [left] {accept}
}
child{
node (not_reliable_not_signaled_accept) {}
edge from parent node [right] {reject}
}
}
% LOWER LEFT SIDE END
}
%LEFT SIDE END
;
\draw[dashed] (not_reliable_not_signaled) -- (reliable_not_signaled)
node[midway,above] {};
\draw[dashed] (not_reliable_signaled) -- (reliable_signaled)
node[midway,above] {};
\path (N) edge node[above]{$Pr($reliable $)$} node[below]{$\lambda$} (reliable_holder);
\path (N) edge node[above]{$Pr(\neg$ reliable $)$} node[below]{$1-\lambda$} (unreliable_holder);
\path (unreliable_holder) edge node[left, sloped=false]{signal} (not_reliable_signaled);
\path (unreliable_holder) edge node[left ,sloped=false]{$\neg$ signal} (not_reliable_not_signaled);
\path (reliable_holder) edge node[right, sloped=false]{signal} (reliable_signaled);
\path (reliable_holder) edge node[right ,sloped=false]{$\neg$ signal} (reliable_not_signaled);
\end{tikzpicture}
}
\end{figure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment