Change regex for detecting edges of graph
This commit is contained in:
parent
0dac5776a8
commit
e8bee03228
@ -1,7 +1,7 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
atandt_desc_pattern = re.compile(r"^([0-9]+) ([0-9]+) (\S+)( [0-9]+\.[0-9]+)?$")
|
||||
atandt_desc_pattern = re.compile(r"^([0-9]+)[ \t]([0-9]+)[ \t](\S+)([ \t][0-9]+(\.[0-9]+)?)?$") #^([0-9]+)[ \t]([0-9]+)[ \t](\S+)([ \t][0-9]+(\.[0-9]+)?)?$
|
||||
atandt_accepted_state_pattern = re.compile(r"^[0-9]+$")
|
||||
|
||||
current_state = 0
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Regex pattern for reading atandt format
|
||||
atandt_desc_pattern = re.compile(r"^([0-9]+)\t([0-9]+)\t(\S+)$") #^([0-9]+)\t([0-9]+)\t(\S+)$ regex for tab separated columns
|
||||
atandt_accepted_state_pattern = re.compile(r"^[0-9]+$")
|
||||
|
||||
@ -25,14 +25,14 @@ def dfs(graph, start):
|
||||
stack.add(el)
|
||||
while stack:
|
||||
edge = stack.pop()
|
||||
print('Current edge: {edge}'.format(edge = edge))
|
||||
#print('Current edge: {edge}'.format(edge = edge))
|
||||
if edge not in visited:
|
||||
visited.add(edge)
|
||||
children = set()
|
||||
for val in filter_set(state_move, edge[2]):
|
||||
stack.add(val)
|
||||
print('Stack: {stack}'.format(stack = stack))
|
||||
print('Visited: {visited}'.format(visited = visited))
|
||||
#print('Stack: {stack}'.format(stack = stack))
|
||||
#print('Visited: {visited}'.format(visited = visited))
|
||||
else:
|
||||
return [-1]
|
||||
return visited
|
||||
@ -52,6 +52,6 @@ print('Accept states: {accept_states}'.format(accept_states = accept_states))
|
||||
|
||||
vis = dfs(state_move, 0)
|
||||
if -1 in vis:
|
||||
print("Cycle")
|
||||
print("TAK")
|
||||
else:
|
||||
print("Tree")
|
||||
print("NIE")
|
||||
|
Loading…
Reference in New Issue
Block a user