Пример #1
0
    def __init__(self, fsm: MealyMachine):
        self.fsm = fsm
        self.A = fsm.get_alphabet()

        self.states = self.fsm.get_states()
        self.root = PartitionNode(self.states, self.A, self)

        self.nodes = [self.root]

        self.wanted = set([state.name for state in fsm.get_states()])
        self.closed = set()
        self.solution = set()
Пример #2
0
def _render(fsm: MealyMachine, filename):
    states = sorted(fsm.get_states(), key=lambda x: int(x.name.strip('s')))
    alphabet = sorted(fsm.get_alphabet())

    g = Digraph('G', filename=filename)
    g.attr(rankdir='LR')

    # Add states
    for state in states:
        g.node(state.name)

    # Add transitions:
    for state in states:
        for action, (other_state, output) in sorted(state.edges.items(), key=lambda x: x[0]):
            g.edge(state.name, other_state.name, label=f'{action}/{output}')

    g.save()