There are a set $A$ of trees. There is another set $B$ of trees that is the collection of all possible subtrees of the trees in $A$. I don't have $A$ but only have $B$, and I need to figure out the size of $A$. A brute-force way is making a graph of the trees. For each root node in $B$, find a tree that contains the node, if there exists such a tree, then make a link from the root node's tree to the containing tree. Finally I can obtain the number of trees in $A$ by counting the number of connected components in the graph. However, this may not be so efficient. How can I do it efficiently?
Counting the number of tree when the set of the subtrees is given
algorithms;trees;counting