# Drawing AND/OR trees in Tikz

Is there a simple way to achieve this type of graph?

Obviously a lot neater than this... But the important feature is the join between the two children of P.

This solution uses the powerful forest package together with the angles library of PGF/TikZ.

A special style, tree angle is defined which marks the angle between a child node and the next sibling.

The combination allows the tree itself to be specified very concisely:

\documentclass[tikz,border=5pt]{standalone}
\usepackage{forest}
\usetikzlibrary{arrows.meta, angles}
\begin{document}
\forestset{
tree angle/.style={
tikz={\path () coordinate (A) -- (!u) coordinate (B) -- (!n) coordinate (C) pic [draw] {angle};}
}
}
\begin{forest}
for tree={
draw,
circle,
edge={-{Stealth[]}},
l sep+=7.5pt
},
[P
[Q, tree angle
[T, tree angle]
[U]
]
[R]
[S
[V]
[W, tree angle]
[X]
]
]
\end{forest}
\end{document}


• Can you explain the tree angle rule? It doesn't render well for rectangle boxes. – Gqqnbig Jan 25 at 0:50

You should study pgfmanual (v2.10 as of mine) for trees library (sections 18.Making Trees Grow, 53.Tree Library) and placing nodes on a line or curve (sections 16.8 and 16.9).

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[level distance=1.5cm, grow=down,
every node/.style={draw, circle, thin},
edge from parent/.style={-latex, thick, draw}
]
\node (P) {P}
child {node (Q) {Q}
child {node (T) {T}}
child {node (U) {U}}
}
child {node (R) {R}}
child {node (S) {S}};

\path (P) -- coordinate[midway] (PQ) (Q);
\path (P) -- coordinate[midway] (PR) (R);

\draw (PQ) to[bend right=22] (PR);
\end{tikzpicture}
\end{document}