if input edges has repeating subtrees, how to map a rooted directed acyclic graph (DAG) input as noded edges
问题 a visual example of my valid tree structure is given below. as you see I have 2 p4 subtrees at level 2. level p1 0 /\ / \ / \ / \ / \ / \ / \ p2 p3 1 / \ / \ / \ / \ p4 c3 p4 c4 2 / \ / \ c1 c2 c1 c2 3 my initial input to represent the tree by edges is: $edges = [ [ 'pid' => 'p1', 'cid' => 'p2' ], [ 'pid' => 'p1', 'cid' => 'p3' ], [ 'pid' => 'p2', 'cid' => 'p4' ], [ 'pid' => 'p2', 'cid' => 'c3' ], [ 'pid' => 'p3', 'cid' => 'p4' ], [ 'pid' => 'p3', 'cid' => 'c4' ], [ 'pid' => 'p4', 'cid' =>