3

How do I add the red circle as shown in below image but with dashed line circle.

enter image description here

I want it to follow the path structure.

So far, this is my code:

\begin{forest}
[$root : s_0$
[$a: s_*$
[$d: s_*$]
[$d: s_*$
[$c: s_*$]
]
]
[$a: s_a$
[$b: s_b$
[$c: s_c$]
]
[$b: s_*$
[$d: s_*$]
[$c: s_*$
[$d: s_*$
[$d: s_*$]
]
]
]
]
]
\end{forest}
3

hobby package has some algorithms which can help you draw such curves. This is a quick proposal, you can make your curve nicer if you spend more time adjusting things.

\documentclass[tikz]{standalone}
\usepackage{forest}
\usetikzlibrary{hobby}
\begin{document}
\begin{forest}
[$root : s_0$, name= s0
    [$a: s_*$
        [$d: s_*$]
        [$d: s_*$
            [$c: s_*$]
        ]
    ]
    [$a: s_a$, name= sa
        [$b: s_b$, name= sb
            [$c: s_c$, name= sc]
        ]
        [$b: s_*$
            [$d: s_*$]
            [$c: s_*$
                [$d: s_*$
                    [$d: s_*$]
                ]
            ]
        ]
    ]
]
\draw[dashed,red] (s0.west) to[closed,curve through={
    (s0.south)..(sb.north west)..(sc.south west)..
    (sc.south east)..([xshift=.2cm]sb.east)..
    (sa.east)..(s0.east)..([tension in=-2]s0.north)
}] (s0.west);
\end{forest}
\end{document}

enter image description here

4

Like this?

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{forest}


\begin{document}
\begin{forest}
[$root : s_0$, name= s0
[$a: s_*$
[$d: s_*$]
[$d: s_*$
[$c: s_*$]
]
]
[$a: s_a$, name= sa
[$b: s_b$, name= sb
[$c: s_c$, name= sc]
]
[$b: s_*$
[$d: s_*$]
[$c: s_*$
[$d: s_*$
[$d: s_*$]
]
]
]
]
]
\draw[dashed,red]
 (s0.20) .. controls ++([shift={(0:1.25)}]sa) and (sb.0) .. (sc.0)
 .. controls ([shift={(-90:1)}]sc) and ([shift={(-180:0.75)}]sc) .. (sb.180)
  .. controls ([shift={(160:2)}]s0) and (s0.90) .. cycle;
\end{forest}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.