This commit is contained in:
deadsmond 2019-11-25 19:55:46 +01:00
parent 075301248c
commit 03b07b1d4f

View File

@ -41,8 +41,12 @@ class automata:
for q in self.state:
# move state to its transition
q = self.get_node_transition(q, i)
# if the list is empty, return false
if not self.state:
return False
# flatten list of states
self.state = [item for sublist in self.state for item in sublist]
# check if automata is in accepting state
return self.check_if_accepted()
# check if there is common part between states of automata and accepting states
@ -55,11 +59,11 @@ class automata:
if self.graph[q]:
# search through all its connections to find value
for transition in self.graph[q]:
print(transition)
# if value is like searched for
if transition[0] == i:
# append next node
result.append(transition[1])
for key in transition:
if key == i:
# append next node
result.append(transition[key])
# return list of next nodes
return result