public IEnumerable<IReductionRuleCommand> Find(Graph graph) { foreach (int vertex in graph.Vertices) { if (graph.Degree(vertex) == 0) { graph.RemoveVertex(vertex); yield return new Command(vertex); } } }
public IEnumerable<IReductionRuleCommand> Find(Graph graph) { foreach (int vertex in graph.Vertices) { // TODO: Count is not O(1) if (graph.Degree(vertex) == 1 && graph.Vertices.Count > 1) { BitSet connection = graph.OpenNeighborhood(vertex); graph.RemoveVertex(vertex); yield return new Command(vertex, connection); } } }
public IEnumerable<IReductionRuleCommand> Find(Graph graph) { foreach (int v in graph.Vertices) { foreach (int u in graph.Vertices) { if (v == u) { break; } // TODO: Count is not O(1) if (graph.Vertices.Count > 1 && ((graph.OpenNeighborhood(v) - u).Equals(graph.OpenNeighborhood(u) - v))) { graph.RemoveVertex(v); yield return new Command(v, u); break; } } } }