I created some code based on an answer here: Drawing binary trees with LaTeX labels.
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{graphs,graphdrawing,graphs.standard,arrows.meta}
\usegdlibrary{trees}
\begin{document}
\tikzgraphsset{%
levels/.store in=\tikzgraphlevel,
levels=1,
declare={full_binary_tree}{[
/utils/exec={
\edef\treenodes{%
\directlua{%
function treenodes(l)
if l == 0 then
return "/"
else
return "/ [layer distance=" .. l*10 .. "]-> {" .. treenodes(l-1) .. ", " .. treenodes(l-1) .. "}"
end
end
tex.print(treenodes(\tikzgraphlevel) .. ";")
}%
}
},
parse/.expand once=\treenodes
]}
}
\begin{tikzpicture}
\graph[binary tree layout, grow=down, sibling distance=0pt, significant sep=-5pt, nodes={fill=red, draw=none, circle, inner sep=4pt, outer sep=0pt}, edge={style={very thick}}]{
full_binary_tree [levels=5];
};
\end{tikzpicture}
\end{document}
Compile this with lualatex
and you get this:
Question: Can anyone suggest an edit to the script above, to terminate the tree with nodes that are vertical ellipsis (three vertical dots) indicating an infinite regression of the tree downwards?
Thus, the lowest row of nodes (and only the lowest row) would be styled differently so they are ellipsis dots instead of red circles.
Thanks.
Best Answer
While you're waiting for a lua solution, here is a possibility with
forest
.