class FA(Automaton, metaclass=ABCMeta)¶
Classes and methods for working with all finite automata.
FA
¶
Bases: Automaton
The FA
class is an abstract base class from which all finite automata inherit.
Every subclass of FA can be rendered natively inside of a Jupyter notebook
(automatically calling show_diagram
without any arguments) if installed with
the visual
optional dependency.
iter_transitions()
abstractmethod
¶
Iterate over all transitions in the automaton. Each transition is a tuple of the form (from_state, to_state, symbol)
show_diagram(input_str=None, path=None, *, layout_method='dot', horizontal=True, reverse_orientation=False, fig_size=None, font_size=14.0, arrow_size=0.85, state_separation=0.5)
¶
Generates a diagram of the associated automaton.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_str |
Optional[str]
|
String consisting of input symbols. If set, will add processing of the input string to the diagram. |
None
|
path |
Union[str, PathLike, None]
|
Path to output file. If None, the output will not be saved. |
None
|
horizontal |
bool
|
Direction of node layout in the output graph. |
True
|
reverse_orientation |
bool
|
Reverse direction of node layout in the output graph. |
False
|
fig_size |
Union[Tuple[float, float], Tuple[float], None]
|
Figure size. |
None
|
font_size |
float
|
Font size in the output graph. |
14.0
|
arrow_size |
float
|
Arrow size in the output graph. |
0.85
|
state_separation |
float
|
Distance between nodes in the output graph. |
0.5
|
Returns:
Type | Description |
---|---|
AGraph
|
A diagram of the given automaton. |