complement

Function complement 

Source
pub fn complement(nfa: &NFA) -> NFA
Expand description

Compute the complement of an NFA. The resulting NFA accepts all string that are not accepted by the input NFA and rejects all strings that are accepted by the input NFA. This is achieved by swapping the final and non-final states of the input automaton. This requires that the automaton is deterministic. If the input automaton is not deterministic, it will be determinized first. If the the input automaton is already deterministic, the algorithm takes O(n) time, where n is the number of states in the automaton. If the input automaton is not deterministic, the algorithm takes another O(2^n) time for determinization, where n is the number of states in the automaton.