public ISubGraph AddSubGraph(ISubGraph subgraph) { if (subgraph == null) { throw new ArgumentNullException(nameof(subgraph)); } if (!Equals(subgraph.Parent) && !SubGraphs.ContainsKey(subgraph.Parent)) { throw new ArgumentException( FormattableString.Invariant($"Parent of SubGraph {subgraph.Id} not within Graph!")); } if (!SubGraphs.ContainsKey(subgraph)) { SubGraphs[subgraph] = subgraph; } var addedSubGraph = SubGraphs[subgraph]; addedSubGraph.SetAttributes(subgraph.GetAttributes()); return(addedSubGraph); }