public GraphEnumerator(Graph g, TraversalStrategyEnum ts = TraversalStrategyEnum.BFS) { graph = g ?? throw new NullReferenceException("The enumerable graph cannot be null."); version = g.Version; switch (ts) { case TraversalStrategyEnum.BFS: { strategy = new TraversalStrategyBFS(graph); break; } case TraversalStrategyEnum.DFS: { strategy = new TraversalStrategyDFS(graph); break; } } // if strategy's event fires, fire ours strategy.OnAllChildrenVisited += delegate(int nodeIndex) { OnAllChildrenVisited?.Invoke(nodeIndex); }; strategy.OnHasNoChildren += delegate(int nodeIndex) { OnHasNoChildren?.Invoke(nodeIndex); }; }
public void Dispose() { graph = null; strategy = null; }