merging graph as subtree