# How to remove some edges of a forest?

I'm basically working on this @cfr's answer to replicate the following formula as a LaTeX equation:

Here are the desired state tree structures:

source:

\documentclass[border=2pt,multi,tikz]{standalone}
\usepackage{forest}
% ateb: addaswyd o ateb Ignasi: https://tex.stackexchange.com/a/351690/
\forestset{%
state tree/.style={%
for tree={
math content,
parent anchor=children,
child anchor=parent,
tier/.option=level,
calign=center,
},
where={>On>{n children}{2}}{
for nodewalk={
filter={children}{>On=!On=!&{n}{1}{n'}{1}}
}{no edge}
}{},
before computing xy={
where={isodd(n_children)}{
tempdima/.process={OOOw3+d{!n=1.s}{!n'=1.s}{n children}{(##2-##1)/(##3-1)}},
tempdimb/.option={!n=1.s},
for children={
s/.process={RROw3+d{tempdima}{tempdimb}{n}{##2+(##1*(##3-1))}}
},
}{},
},
},
}
\begin{document}
\begin{forest}
state tree,
[R
[A
[]
[b
[b_{1}
[0]
[\dot{\cup}]
[1]
]
[\times]
[b_{2}
[2]
[\dot{\cup}]
[3]
]
]
]
[\times]
[B
[c]
[]
]
]
\end{forest}
\end{document}


target:

\documentclass[border=2pt,multi,tikz]{standalone}
\usepackage{forest}
% ateb: addaswyd o ateb Ignasi: https://tex.stackexchange.com/a/351690/
\forestset{%
state tree/.style={%
for tree={
math content,
parent anchor=children,
child anchor=parent,
tier/.option=level,
calign=center,
},
where={>On>{n children}{2}}{
for nodewalk={
filter={children}{>On=!On=!&{n}{1}{n'}{1}}
}{no edge}
}{},
before computing xy={
where={isodd(n_children)}{
tempdima/.process={OOOw3+d{!n=1.s}{!n'=1.s}{n children}{(##2-##1)/(##3-1)}},
tempdimb/.option={!n=1.s},
for children={
s/.process={RROw3+d{tempdima}{tempdimb}{n}{##2+(##1*(##3-1))}}
},
}{},
},
},
}
\begin{document}

\begin{forest}
state tree,
[R
[A
[a]
[]
]
[\times]
[B
[]
[d
[d_{1}]
[]
]
]
]
\end{forest}
\end{document}


and finally embedding them into equation environment:

\documentclass[border=2pt,preview]{standalone}
\usepackage{graphicx}
\usepackage{amsmath}

\begin{document}

$\Delta(\raisebox{-12ex}{\includegraphics{source.pdf}},\beta) = \raisebox{-10ex}{\includegraphics{target.pdf}}$

\end{document}


The question is how one should get rid of the edge connecting a parent node to a child node when the latter is removed. (I just tried to fix this problem by using only one child node and changing the edge orientation using grow=whatever-degree option; however, this approach is neither general nor reliable enough for all scenarios.)

Edit: I can remove the empty nodes, i.e., []s, to end up with something like this:

however, I prefer to have deflected edges for this application.

• Have you tried [,no edge] instead of []? (source, target) – Henri Menke Nov 8 '17 at 7:06
• @HenriMenke: I had no idea about it! Thanks. If you send an answer, I will gratefully accept it. – Roboticist Nov 8 '17 at 7:12
• Looks like you didn't see the forest for the trees (pun intended). I actually got this from the other question you linked. – Henri Menke Nov 8 '17 at 7:25
• @HenriMenke: Well, I checked them; however, the options of this class are such abundant that I seemingly missed it. My bad imprecision. Thanks anyway. – Roboticist Nov 8 '17 at 7:27

You can suppress the edge to the child by adding the option no edge after the node text. In case of a node with no text this looks like [,no edge].