def _has_recursion(self, to_visit: str, visited: Set[str]) -> bool:
"""
Checks if the automata has recursive states, using a depth
first search approach.
"""
if to_visit in visited:
return True
visited.add(to_visit)
reachable = set() # type: Set[str]
# Find the reachable through all symbols
for symbol in self._alphabet:
reachable.update(self._find_reachable({to_visit}, symbol))
for state in reachable:
if self._has_recursion(state, copy.deepcopy(visited)):
return True
return False
评论列表
文章目录