1

I was wondering how do I encircle the branch of the tree as shown in the picture.

Here is what I have so far

 \begin{tikzpicture}
    \node[circle,draw,fill=gray]{s}
        child{node[circle,draw,fill=white]{}
             child{node[circle,draw,fill=gray]{}}
        }
        child{node[circle,draw,fill=white]{}
             child{node[circle,draw,fill=gray]{}}
        }
        child{node[circle,draw,fill=white]{}
            child{node[circle,draw,fill=gray]{}}
        };
\end{tikzpicture}

tikz tree

1

1 Answer 1

4

Welcome! There are many ways to draw such a halo, here is one of them.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{backgrounds}
\begin{document}

\begin{tikzpicture}[halo/.style={line join=round,
 double,line cap=round,double distance=#1,shorten >=-#1/2,shorten <=-#1/2},
 halo/.default=7mm]
    \node[circle,draw,fill=gray](s){s}
        child{node[circle,draw,fill=white]{}
             child{node[circle,draw,fill=gray]{}}
        }
        child{node[circle,draw,fill=white]{}
             child{node[circle,draw,fill=gray]{}}
        }
        child{node[circle,draw,fill=white](R1){}
            child{node[circle,draw,fill=gray](R2){}}
        };
 \begin{scope}[on background layer]     
  \draw[halo] (s) -- (R1.center) -- (R2);       
 \end{scope}
 \path (R2.south) ++ (0,-3.5mm); % shorten does not get taken into account by the bounding box
\end{tikzpicture}
\end{document}

enter image description here

1
  • Thank you, that is very helpful.
    – KaneM
    Feb 13, 2020 at 20:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .