[Tex/LaTex] How to remove some edges of a forest

foresttikz-pgf

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

enter image description here

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}

leading to:

enter image description here

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:

enter image description here

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

Best Answer

The question is how one should get rid of the edge connecting a parent node to a child node when the latter is removed.

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].

Related Question