26 using System.Collections.Generic;
32 public abstract class Dfs
45 private HashSet<Node> traversed;
49 protected int Level {
get;
private set; }
55 public void Run(
IGraph graph, IEnumerable<Node> roots = null)
65 default: arcFilter =
ArcFilter.Backward;
break;
68 traversed =
new HashSet<Node>();
71 if (traversed.Contains(node))
continue;
81 private bool Traverse(
Node node,
Arc arc)
86 foreach (var b
in Graph.
Arcs(node, arcFilter))
88 if (b == arc)
continue;
91 if (traversed.Contains(other))
93 if (!
BackArc(node, b))
return false;
98 if (!Traverse(other, b))
return false;