3

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.

4
  • 1
    Have you tried [,no edge] instead of []? (source, target) Nov 8, 2017 at 7:06
  • @HenriMenke: I had no idea about it! Thanks. If you send an answer, I will gratefully accept it.
    – user78499
    Nov 8, 2017 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. Nov 8, 2017 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.
    – user78499
    Nov 8, 2017 at 7:27

1 Answer 1

1

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

You must log in to answer this question.