public List <DFAState> GetAnyDFAPathToTarget(DFAState startState, DFAState targetState, HashSet <DFAState> visited) { List <DFAState> dfaStates = new List <DFAState>(); visited.Add(startState); if (startState.Equals(targetState)) { dfaStates.Add(targetState); return(dfaStates); } // for (Edge e : startState.edges) { // walk edges looking for valid // path for (int i = 0; i < startState.NumberOfTransitions; i++) { Transition e = startState.GetTransition(i); if (!visited.Contains((DFAState)e.Target)) { List <DFAState> path = GetAnyDFAPathToTarget((DFAState)e.Target, targetState, visited); if (path != null) { // found path, we're done dfaStates.Add(startState); dfaStates.AddRange(path); return(dfaStates); } } } return(null); }
public List<DFAState> GetAnyDFAPathToTarget(DFAState startState, DFAState targetState, HashSet<DFAState> visited) { List<DFAState> dfaStates = new List<DFAState>(); visited.Add(startState); if (startState.Equals(targetState)) { dfaStates.Add(targetState); return dfaStates; } // for (Edge e : startState.edges) { // walk edges looking for valid // path for (int i = 0; i < startState.NumberOfTransitions; i++) { Transition e = startState.GetTransition(i); if (!visited.Contains((DFAState)e.Target)) { List<DFAState> path = GetAnyDFAPathToTarget((DFAState)e.Target, targetState, visited); if (path != null) { // found path, we're done dfaStates.Add(startState); dfaStates.AddRange(path); return dfaStates; } } } return null; }