public boolean isDeterministic() { if (!_allStates.contains(_initialState)) throw new InternalReasonerException(); for (final State<T> s : _allStates) { final Set<T> seenSymbols = new HashSet<>(); for (final Transition<T> t : s.getTransitions()) { final T symbol = t.getName(); if (t.isEpsilon() || !seenSymbols.add(symbol)) return false; } } return true; }
public boolean isDeterministic() { if (!_allStates.contains(_initialState)) throw new InternalReasonerException(); for (final State<T> s : _allStates) { final Set<T> seenSymbols = new HashSet<>(); for (final Transition<T> t : s.getTransitions()) { final T symbol = t.getName(); if (t.isEpsilon() || !seenSymbols.add(symbol)) return false; } } return true; }
public Set<State<T>> epsilonClosure(final State<T> s, final Set<State<T>> init) { Set<State<T>> result = init; // s is in the epsilon closure of itself result.add(s); // for each edge from s for (final Transition<T> e : s.getTransitions()) // if this is an epsilon transition and the result // does not contain 'to' state then add the epsilon // closure of 'to' state to the result set if (e.isEpsilon() && !result.contains(e.getTo())) result = epsilonClosure(e.getTo(), result); return result; }
public Set<State<T>> epsilonClosure(final State<T> s, final Set<State<T>> init) { Set<State<T>> result = init; // s is in the epsilon closure of itself result.add(s); // for each edge from s for (final Transition<T> e : s.getTransitions()) // if this is an epsilon transition and the result // does not contain 'to' state then add the epsilon // closure of 'to' state to the result set if (e.isEpsilon() && !result.contains(e.getTo())) result = epsilonClosure(e.getTo(), result); return result; }
if (t.isEpsilon()) n1.addTransition(n2); else
if (t.isEpsilon()) n1.addTransition(n2); else
private State<Role> copyState(final State<Role> oldState, final TransitionGraph<Role> newTG, final Map<State<Role>, State<Role>> newStates) { State<Role> newState = newStates.get(oldState); if (newState == null) { newState = newTG.newState(); newStates.put(oldState, newState); for (final Transition<Role> t : oldState.getTransitions()) { final State<Role> oldTo = t.getTo(); final State<Role> newFrom = copyState(oldTo, newTG, newStates); if (t.isEpsilon()) newTG.addTransition(newFrom, newState); else newTG.addTransition(newFrom, t.getName().getInverse(), newState); } } return newState; } }
private State<Role> copyState(final State<Role> oldState, final TransitionGraph<Role> newTG, final Map<State<Role>, State<Role>> newStates) { State<Role> newState = newStates.get(oldState); if (newState == null) { newState = newTG.newState(); newStates.put(oldState, newState); for (final Transition<Role> t : oldState.getTransitions()) { final State<Role> oldTo = t.getTo(); final State<Role> newFrom = copyState(oldTo, newTG, newStates); if (t.isEpsilon()) newTG.addTransition(newFrom, newState); else newTG.addTransition(newFrom, t.getName().getInverse(), newState); } } return newState; } }