I have a non-binary tree.
I want to find all "sub-trees" that are connected to root.
Sub-tree is a a link group of tree nodes.
every group is colored in it's own color.
What would be be the best approach? Run recursion down and up for every node?
The data structure of every treenode is a list of children, list of parents. (the type of children and parents are treenodes)
Group defined if there is a kind of "closure" between nodes where root itself is not part of the closure.
As you can see from the graph you can't travel from pink to other nodes (you CAN NOT use root).
From brown node you can travel to it's child so this form another group.
Finally you can travel from any cyan node to other cyan nodes so the form another group