private void CloneAndAddAllSubgraphs(IGraph root, ISubGraph currentSubgraph, IDictionary <ISubGraph, ISubGraph> subgraphDictionary) { foreach (var subgraph in currentSubgraph.GetSubGraphSubGraphs()) { var clonedSubgraph = new SubGraph(subgraphDictionary[currentSubgraph], subgraph.Id); clonedSubgraph.SetAttributes(subgraph.GetAttributes()); clonedSubgraph.SetNodeAttributes(subgraph.GetNodeAttributes()); clonedSubgraph.SetEdgeAttributes(subgraph.GetEdgeAttributes()); var addedSubgraph = root.AddSubGraph(clonedSubgraph); subgraphDictionary[subgraph] = addedSubgraph; CloneAndAddAllSubgraphs(root, subgraph, subgraphDictionary); } }