# how can i make plane/binary trees with dots?

I have been creating binary and plane trees using the following code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,chains,fit,shapes,calc}
\begin{tikzpicture}
\node[circle,draw](z){}
child[missing]{}
child{
node[circle,draw]{} child{node[circle,draw] {}} child[missing] };
\end{tikzpicture}
\end{document}


It makes very large circles on the end of the edges, and I am hoping to have smaller nodes instead, and eventually make something looking like this:

The circles are large due to the inner sep of nodes. You can set it with the option inner sep=<length> (e.g. inner sep=1pt), individual for each node or for the whole picture with

\begin{tikzpicture}[inner sep=1pt]


Or you can set styles for your nodes to easily change their apperance individually, as shown here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,chains,fit,shapes,calc}

\begin{document}
\begin{tikzpicture}
\tikzset{dot/.style={inner sep=1pt,circle,draw,fill},
circ/.style={inner sep=1pt,circle,draw}}
\node[dot](z){}
child[missing]{}
child{
node[dot]{} child{node[circ] {}} child[missing] };
\end{tikzpicture}
\end{document}


In the example the new styles dot and circ are only availabe in the tikzpicture. If you move the two lines for\tikzset into the preamble, they are available for all pictures.

If you need to draw many trees, it will be worth your while to learn Forest since it permits you to create powerful styles which you can apply to extremely concise tree specifications.

For example, defining three styles, dot tree, dot tree spread and add arrow allows us to write

\begin{forest}
[[[][]][][[[][][]]][]]
\end{forest}
\begin{forest}
where level=0{!1.no edge, coordinate}{
if n=1{}{
edge path'={(!p) -- ()},
},
},
[[[][]][][[[][][]]][]]
\end{forest}
\begin{forest}
dot tree,
where n children=0{
before computing xy={l*=.5, s*=.5},
edge+={densely dashed},
}{},
[[[][[][]]][[][[[][]][[[][[][[][]]]][]]]]]
\end{forest}


to produce the series of three trees shown in the question:

Complete code:

\documentclass[border=10pt]{standalone}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\forestset{
dot tree/.style={
/tikz/>=Latex,
for tree={
inner sep=1pt,
fill,
draw,
circle,
calign angle=45,
calign=fixed edge angles,
},
baseline,
before computing xy={
where n children>=4{
tempcounta/.option=n children,
tempdima/.option=!1.s,
tempdimb/.option=!l.s,
tempdimb-/.register=tempdima,
tempdimc/.process={RRw2+P {tempcounta}{tempdimb}{##2/(##1-1)}},
for children={
if={>On>OR<&{n}{1}{n}{tempcounta}}{
s/.register=tempdima,
s+/.process={ORw2+P  {n} {tempdimc} {(##1-1)*##2} }
}{},
},
}{},
},
},
dot tree,
for tree={fit=rectangle},
},
tikz+={
\draw [thick, blue!15!gray]  (current bounding box.east) ++(2.5mm,0) edge [->] ++(10mm,0) ++(2.5mm,0) coordinate (o);
}
}
}
\begin{forest}
[[[][]][][[[][][]]][]]
\end{forest}
\begin{forest}
where level=0{!1.no edge, coordinate}{
if n=1{}{
edge path'={(!p) -- ()},
},
},
[[[][]][][[[][][]]][]]
\end{forest}
\begin{forest}
dot tree,
where n children=0{
before computing xy={l*=.5, s*=.5},
edge+={densely dashed},
}{},
[[[][[][]]][[][[[][]][[[][[][[][]]]][]]]]]
\end{forest}
\end{document}