I have a directed acyclic graph(tree) described by (Parent1 -> Child1), (Parent2 -> Child2), ...., (ParentN -> ChildN) tuples. Is there any algorithm that reconstructs the tree(graph) from these informations?
A better example:
Root
Parent1
Node1
Child1
Child2
Parent2
Node1
Child1
Child2
and as input I have only:
Root -> Parent1
Node1 -> Child1
Root -> Parent2
Parent1 -> Node1
Parent2 -> Node1
Node1 -> Child2
in no particular order.
Having only these tuples, can we reconstruct the tree in a structure like:
Node(name:String, children:List) ?