/// <summary> /// Создание автомата /// </summary> /// <param name="arrayTransition"></param> private void CreateAutomatonGraph(string[, ][] arrayTransition) { List <DFAGraphNode <string> > Q = new List <DFAGraphNode <string> >(); bool flagAttainability; automatonGraph = new Automaton(new List <string>(def.Sigma)); Automaton automatonGraphTemp = new Automaton(automatonGraph); // automatonGraph. // = new Automaton(def); for (int i = 0; i < def.Q.Length; i++) { if ((StaticAnyWhere.occurrence(def.F, new string[] { def.Q[i] })) && (def.Q[i] == def.Q0)) { automatonGraphTemp.addState(new DFAGraphNode <string>(def.Q[i], true, true)); } else if (StaticAnyWhere.occurrence(def.F, new string[] { def.Q[i] })) { automatonGraphTemp.addState(new DFAGraphNode <string>(def.Q[i], false, true)); } else if (def.Q[i] == def.Q0) { automatonGraphTemp.addState(new DFAGraphNode <string>(def.Q[i], true, false)); } else { automatonGraphTemp.addState(new DFAGraphNode <string>(def.Q[i], false, false)); } } automatonGraphTemp.findHead(); for (int i = 0; i < def.Q.Length; i++) { List <StateTransitionTable> _conversionTable = new List <StateTransitionTable>(); for (int j = 0; j < def.Sigma.Length; j++) { for (int k = 0; k < arrayTransition[i, j].Length; k++) { for (int ii = 0; ii < def.Q.Length; ii++) { if (arrayTransition[i, j][k] == def.Q[ii]) { _conversionTable.Add(new StateTransitionTable(automatonGraphTemp.findByName(def.Q[ii]), def.Sigma[j], true)); } } } } automatonGraphTemp.findByName(def.Q[i]).ConversionTable = _conversionTable; } flagAttainability = automatonGraphTemp.AttainabilityOfTheTop(); if (flagAttainability) { automatonGraph = automatonGraphTemp; if (def.Type == 0) { viewToDFABtn.Visibility = Visibility.Visible; } else if (def.Type == 1) { viewToDFABtn.Visibility = Visibility.Visible; transToDFABtn.Visibility = Visibility.Visible; } else if (def.Type == 2) { viewToDFABtn.Visibility = Visibility.Visible; transToDFABtn.Visibility = Visibility.Visible; } } else { ErrorWindow errorWindow = new ErrorWindow("Ошибка ввода", "Заключительное состояние не достижимо Возможно вы ошиблись при заполнении таблицы перехода, попробуйте изменить значения. Убедитесь, что конечное состояние достижимо."); errorWindow.ShowDialog(); // StaticAnyWhere.Error = "Заключительное состояние автомата не достижимо"; // StaticAnyWhere.Rootclass.GoTo("Pages/Error.xaml"); } }