コード例 #1
0
ファイル: Automata.cs プロジェクト: YvensFaos/TinyBASIC_IDE
        /// <summary>
        /// Converte um afn para afd
        /// </summary>
        /// <param name="afn">Automato finito não determinístico</param>
        /// <param name="transictionList">Lista dos possíveis valores para transição de estado</param>
        /// <param name="nullSymbol">Símbolo representando do nulo/vazio dos automatos</param>
        /// <returns>Retorna um automato finito determínisco usando a construção de conjuntos do automato passado</returns>
        public static Automata <T, E> AFNtoAFD(Automata <T, E> afn, List <E> transictionList, E nullSymbol)
        {
            State <T, E> initialState = afn.InitialState;
            Dictionary <State <T, E>, PowerSet <T, E> > hash = new Dictionary <State <T, E>, PowerSet <T, E> >();

            //Retorna com o hash completo com todos os fechos
            PowerSet <T, E> initialPowerSet = GeneratePowerSet(initialState, transictionList, nullSymbol, hash);

            //Carrega o valor do estado do primeiro fecho transitivo
            initialState = initialPowerSet.PowerSetToState();

            //Carrega a lista com os estados do fecho transitivo criado
            List <State <T, E> > stateList = new List <State <T, E> >();

            foreach (State <T, E> state in hash.Keys)
            {
                PowerSet <T, E> powerSet = hash[state];
                stateList.Add(powerSet.PowerSetToState());
            }

            return(new Automata <T, E>(initialState, stateList, transictionList, nullSymbol));
        }