public DirectedDFS(Digraph graph, IEnumerable <int> sources) { _marked = new bool[graph.GetVertices()]; foreach (var s in sources) { if (!_marked[s]) { DFS(graph, s); } } }
public bool Recognizes(string txt) { var pc = new Bag <int>(); var dfs = new DirectedDFS(_graph, 0); for (var v = 0; v < _graph.GetVertices(); v++) { if (dfs.Marked(v)) { pc.Add(v); } } for (var i = 0; i < txt.Length; i++) { var match = new Bag <int>(); foreach (var v in pc) { if (v < _states) { if (_regx[v] == txt[i] || _regx[v] == '.') { match.Add(v + 1); } } } pc = new Bag <int>(); dfs = new DirectedDFS(_graph, match); for (var v = 0; v < _graph.GetVertices(); v++) { if (dfs.Marked(v)) { pc.Add(v); } } } return(pc.Any(v => v == _states)); }
public DirectedDFS(Digraph graph, int size) { _marked = new bool[graph.GetVertices()]; DFS(graph, size); }