public override Graph Apply(Graph g) { var h = new Graph(g.Order); // copy atom/topology information this is unchanged for (int u = 0; u < g.Order; u++) { if (g.TopologyOf(u).Type == Configuration.ConfigurationType.DoubleBond) { h.AddAtom(ReducedAtom(g, u)); } else { h.AddAtom(g.GetAtom(u)); h.AddTopology(g.TopologyOf(u)); } } var replacements = new Traversal(g).replacement; // append the edges, replacing any which need to be changed for (int u = 0; u < g.Order; u++) { foreach (var e in g.GetEdges(u)) { if (e.Other(u) > u) { var ee = e; if (replacements.TryGetValue(e, out Edge replacement)) { ee = replacement; } h.AddEdge(ee); } } } return(h); }