I'm trying to recreate the following diagram from a book:
I tried using tikz's graphdrawing
package:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary {graphs, quotes, graphdrawing} \usegdlibrary{trees}
%\usetikzlibrary {arrows.meta,graphs,graphdrawing} \usegdlibrary {layered}
\begin{document}
\begin{tikzpicture}
\graph [
tree layout,
% layered layout,
grow down, branch right,
nodes={circle ,draw, minimum size=.65cm, inner sep=0pt, very thick},
level/.style={
sibling distance = .15cm,
sibling sep = 0.25cm,
level distance = 0cm,
level sep = 0.1cm
},
level 3/.style={
sibling distance = .0cm,
sibling sep = 0.6cm,
level distance = 0cm,
level sep = 0.1cm
}
] {
1--2--{3,4--{6,7},5--{8--{10,11},9}}
};
\end{tikzpicture}
\end{document}
Trying first the tree layout engine:
and then I tried the layered layout engine:
They're pretty close, but neither nails it. The original's layout seems to be a mixture of the two. Notice how the subgraph with 5 as root is layed out as a binary tree, while the 1-2-4 chain is what you get with the layered layout.
I also noticed that in the original, the 4 node sits a tad lower than its siblings. While the use of a different sibling seperation in level 3 in the layered layout places 4 a bit off-center wrt 2 for some reason.
The mammoth tikz manual didn't tell me how to:
- control level pre distance per node
- switch between layouts (probably not possible), or
- alternatively, nudging the leftmost child manually so the rest of the tree aligns properly.
Advice appreciated (including achieving this more easily with something else short of illustrator other than tikz)