-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransition.py
36 lines (33 loc) · 1004 Bytes
/
Transition.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Transition:
def __init__(self, dict):
self.dict = dict
@staticmethod
def getInitialStateFromTransition(transition):
sl = []
for x in transition.keys():
sl.append(x[0])
for y in transition[x]:
sl.append(y)
for z in sl:
if z.getIsInitialState():
return z
else:
pass
@staticmethod
def getFinalStateFromTransition(transition):#only works for NFA's
sl = []
for x in transition.keys():
sl.append(x[0])
for y in transition[x]:
sl.append(y)
for z in sl:
if z.getIsFinalState():
return z
else:
pass
@staticmethod
def printTransition(trans):
for key, value in trans.items():
gg = set([x.getName() for x in value])
s = ', '.join(gg)
print(f"δ({key[0].getName()}, {key[1]}) = {{{s}}} ")