def _determinize_state(self, states_set: Set[str]) -> None:
"""
For a given set of states, verify whether they pertains to the
actual states of the FA. In negative case, add it and insert
the transitions properly
"""
name = "".join(sorted(states_set))
if name and name not in self._states:
self.add_state(name)
if states_set.intersection(self._final_states):
self._final_states.add(name)
for symbol in self._alphabet:
reachable = self._find_reachable(states_set, symbol)
if reachable:
self._transitions[name, symbol] = reachable
self._determinize_state(reachable)
评论列表
文章目录