q.put(temp[0]) while not q.empty(): state = q.get() temp_states = [state] for i in range(1, len(temp)): if len(set(temp[i]).intersection(state)) > 0: state = list(set(temp[i] + state)) temp_states.append(temp[i]) elif q.empty(): q.put(temp[i]) new_states.append(state) temp = [x for x in temp if x not in temp_states] return new_states def print_table(self): pp = pprint.PrettyPrinter() pp.pprint(self.table) if __name__ == "__main__": nfa = Automata() nfa.getGraphFromFile("test.txt") dfa = nfa.toDFA() # dfa.printGraph() m = Minimization(dfa) # m.print_table() mdfa = m.minimize() mdfa.printStateTable() mdfa.printGraph() # mdfa.render("mtest/dfa")