private static void processFinishNode(DState state) { foreach (var node in state.Nodes) { if (node.Start.Outputs.Count == 0) { state.isFinishNode = true; break; } } }
private static bool IsStateInCollection(DState state, IEnumerable <DState> states) { bool ans = false; foreach (var sec in states) { if (IsEqualStates(state, sec)) { ans = true; break; } } return(ans); }
private static DState EqualStateFromCollection(DState state, IEnumerable <DState> states) { DState ans = null; foreach (var sec in states) { if (IsEqualStates(state, sec)) { ans = sec; break; } } return(ans); }
private static bool IsEqualStates(DState first, DState second) { bool equal = first.Nodes.Count == second.Nodes.Count; if (equal) { foreach (var node in first.Nodes) { if (!second.Nodes.Contains(node)) { equal = false; } } } return(equal); }
private static DState Move(DState dState, char a) { DState res = new DState(); //var epsState = EClosure(dState); foreach (var node in dState.Nodes) { foreach (var link in node.Start.Outputs) { if (link.Subj == a) { res.AddNode(link.Destination); } } } var epsState = EClosure(res); return(epsState); }
private static DState EClosure(DState dState) { Stack <Node> statesStack = new Stack <Node>(); DState res = new DState(); foreach (var node in dState.Nodes) { statesStack.Push(node); res.AddNode(node); } while (statesStack.Count > 0) { var state = statesStack.Pop(); foreach (var link in state.Start.Outputs) { if (link.Subj == Utils.eps && !res.Nodes.Contains(link.Destination)) { res.AddNode(link.Destination); statesStack.Push(link.Destination); } } } return(res); }
public void Bind(DState next, char c) { GraphAutomat.Bind(this, next, c); }