private void convertNfaToTableFormat(List <State> states, List <Letter> alphabet)
        {
            foreach (State state in states)
            {
                AutomataRow  row = new AutomataRow();
                AutomataCell initialStateCell = new AutomataCell(null);
                initialStateCell.statesInCell.Add(state);
                row.cells.Add(initialStateCell);

                foreach (Letter letter in alphabet)
                {
                    if (row.cells.Any(_ => _.belongsTo != null && _.belongsTo.data == letter.data))
                    {
                        continue;
                    }

                    List <Transition> possibleTransitions = this._transitions.FindAll(_ => _.initialState.data == state.data &&
                                                                                      _.connectingLetter.data == letter.data);

                    List <State> destinationState = possibleTransitions.Select(_ => _.destinationState).ToList();

                    AutomataCell statesToLetterCell = new AutomataCell(letter);
                    statesToLetterCell.statesInCell = destinationState;

                    row.cells.Add(statesToLetterCell);
                }

                _automataTable.rows.Add(row);
            }
        }
        private AutomataTable recursiveTableCreation(AutomataTable table, List <AutomataCell> cellsStack, List <Letter> alphabet)
        {
            if (cellsStack.Count == 0)
            {
                return(table);
            }

            foreach (AutomataCell cell in cellsStack.ToList())
            {
                cellsStack.Remove(cell);

                AutomataRow  row               = new AutomataRow();
                AutomataCell initialCell       = new AutomataCell(null);
                List <State> initialCellStates = new List <State>();

                foreach (State state in cell.statesInCell)
                {
                    initialCellStates.AddRange(getEClosureStates(state, new List <State>()));
                }

                foreach (State state in initialCellStates)
                {
                    initialCell.AddStateToCell(state);
                }

                row.cells.Add(initialCell);

                foreach (Letter letter in alphabet)
                {
                    if (letter.data == '_')
                    {
                        continue;
                    }

                    AutomataCell dataCell = this.createCellForLetter(initialCell, letter);

                    row.cells.Add(dataCell);

                    this.insertCellToStack(table, cellsStack, dataCell, row);
                }

                table.rows.Add(row);

                recursiveTableCreation(table, cellsStack, alphabet);
            }

            return(table);
        }
 private void insertCellToStack(AutomataTable table, List <AutomataCell> cellsStack, AutomataCell dataCell, AutomataRow row)
 {
     if (!table.rows.Any(_ => _.cells.Any(x => x.belongsTo == null && x.statesInCell.SequenceEqual(dataCell.statesInCell))) &&
         !row.cells.Any(x => x.belongsTo == null && x.statesInCell.SequenceEqual(dataCell.statesInCell)))
     {
         cellsStack.Insert(cellsStack.Count, dataCell);
     }
 }