/// <summary> /// Returns a new (deterministic and minimal) automaton that accepts the union of the given /// set of strings. The input character sequences are internally sorted in-place, so the /// input array is modified. @see StringUnionOperations. /// </summary> /// <param name="strings">The strings.</param> /// <returns></returns> public static Automaton MakeStringUnion(params char[][] strings) { if (strings.Length == 0) { return(MakeEmpty()); } Array.Sort(strings, StringUnionOperations.LexicographicOrderComparer); var a = new Automaton(); a.Initial = StringUnionOperations.Build(strings); a.IsDeterministic = true; a.Reduce(); a.RecomputeHashCode(); return(a); }
/// <summary> /// Minimizes (and determinizes if not already deterministic) the given automaton. /// </summary> /// <param name="a">The automaton.</param> public static void Minimize(Automaton a) { if (!a.IsSingleton) { switch (Automaton.Minimization) { case Automaton.MinimizeHuffman: MinimizationOperations.MinimizeHuffman(a); break; case Automaton.MinimizeBrzozowski: MinimizationOperations.MinimizeBrzozowski(a); break; default: MinimizationOperations.MinimizeHopcroft(a); break; } } a.RecomputeHashCode(); }
/// <summary> /// Returns a new (deterministic and minimal) automaton that accepts the union of the given /// set of strings. The input character sequences are internally sorted in-place, so the /// input array is modified. @see StringUnionOperations. /// </summary> /// <param name="strings">The strings.</param> /// <returns></returns> public static Automaton MakeStringUnion(params char[][] strings) { if (strings.Length == 0) { return MakeEmpty(); } Array.Sort(strings, StringUnionOperations.LexicographicOrderComparer); var a = new Automaton(); a.Initial = StringUnionOperations.Build(strings); a.IsDeterministic = true; a.Reduce(); a.RecomputeHashCode(); return a; }