public Automata <String> inverseAutomata(Automata <String> automaton)
        {
            Automata <String> invertedAutomaton = new Automata <string>(automaton.getAlphabet());

            foreach (String state in automaton.getFinalStates())
            {
                invertedAutomaton.defineAsStartState(state);
            }

            foreach (Transition <String> transition in automaton.getTransitions())
            {
                invertedAutomaton.addTransition(transition);
            }

            foreach (String state in automaton.getStates())
            {
                if (!automaton.getFinalStates().Contains(state))
                {
                    invertedAutomaton.defineAsFinalState(state);
                }
            }

            foreach (String state in automaton.getFinalStates())
            {
                if (state != invertedAutomaton.getStartStates().First())
                {
                    invertedAutomaton.addTransition(new Transition <string>(invertedAutomaton.getStartStates().First(), state));
                }
            }


            return(invertedAutomaton);
        }
        public Automata <String> renameStates(Automata <String> automaton)
        {
            Automata <String>           renamedAutomaton = new Automata <string>(automaton.getAlphabet());
            Dictionary <String, String> referencer       = new Dictionary <string, string>();
            int counter = 0;

            foreach (String state in automaton.getStates())
            {
                referencer.Add(state, "q" + counter++);
                Console.WriteLine("q" + counter);
            }
            if (automaton.getStates().Contains("Ø"))
            {
                referencer["Ø"] = "Ø";
            }
            foreach (Transition <String> transition in automaton.getTransitions())
            {
                renamedAutomaton.addTransition(new Transition <string>(referencer[transition.getFromState()], transition.getSymbol(), referencer[transition.getToState()]));
            }
            foreach (String state in automaton.getFinalStates())
            {
                renamedAutomaton.defineAsFinalState(referencer[state]);
            }
            foreach (String state in automaton.getStartStates())
            {
                renamedAutomaton.defineAsStartState(referencer[state]);
            }
            return(renamedAutomaton);
        }
        //For a single state

        public SortedSet <String> findStartState(Automata <String> Automata)
        {
            SortedSet <String> foundStates = new SortedSet <String>();

            foreach (var start in Automata.getStartStates())
            {
                foundStates.Add(start);
                foreach (var item in Automata.getToStates(start, '$'))
                {
                    if (!foundStates.Contains(item))
                    {
                        foundStates.Add(item);
                    }
                }
            }
            return(foundStates);
        }
//		public Automata<String> reverseAutomata(Automata<String> automaton)
//		{
//			Automata<String> reversedAutomaton = new Automata<String>(automaton.getAlphabet());
//
//			foreach (Transition<String> transition in automaton.getTransitions())
//			{
//				transition.reverseFromToState();
//				reversedAutomaton.addTransition(transition);
//			}
//
//			foreach (String state in automaton.getStartStates()) {
//				reversedAutomaton.defineAsStartState(state);
//			}
//
//			foreach (String state in automaton.getFinalStates()) {
//				reversedAutomaton.defineAsFinalState(state);
//			}
//			reversedAutomaton.printTransitions();
//
//			reversedAutomaton = inverseAutomata(reversedAutomaton);
//
//			reversedAutomaton.printTransitions();
//			return reversedAutomaton;
//		}

        public Automata <String> reverseAutomata(Automata <String> automaton)
        {
            Automata <String> reversedAutomaton = new Automata <string>(automaton.getAlphabet());

            foreach (Transition <String> transition in automaton.getTransitions())
            {
                reversedAutomaton.addTransition(new Transition <String> (transition.getToState(), transition.getSymbol(), transition.getFromState()));
            }

            foreach (String state in automaton.getFinalStates())
            {
                reversedAutomaton.defineAsStartState(state);
            }

            foreach (String state in automaton.getStartStates())
            {
                reversedAutomaton.defineAsFinalState(state);
            }

            return(reversedAutomaton);
        }