automata_IO

Module to mange IO

List

dfa_json_importer(input_file) Imports a DFA from a JSON file.
dfa_to_json(dfa, name, path) Exports a DFA to a JSON file.
dfa_dot_importer(input_file) Imports a DFA from a DOT file.
dfa_to_dot(dfa, name, path) Generates a DOT file and a relative SVG image in path folder of the input DFA using graphviz library.
dfa_conformance_check Method or function hasn’t been implemented yet.
nfa_json_importer(input_file) Imports a NFA from a JSON file.
nfa_to_json(nfa, name, path) Exports a NFA to a JSON file.
nfa_dot_importer(input_file) Imports a NFA from a DOT file.
nfa_to_dot(nfa, name, path) Generates a DOT file and a relative SVG image in path folder of the input NFA using graphviz library.
afw_json_importer(input_file) Imports a AFW from a JSON file.
afw_to_json(afw, name, path) Exports a AFW to a JSON file.

Functions

PySimpleAutomata.automata_IO.afw_json_importer(input_file: str) → dict[source]

Imports a AFW from a JSON file.

Parameters:input_file (str) – path+filename to input JSON file;
Returns:(dict) representing a AFW.
PySimpleAutomata.automata_IO.afw_to_json(afw: dict, name: str, path: str = './')[source]

Exports a AFW to a JSON file.

Parameters:
  • afw (dict) – input AFW;
  • name (str) – output file name;
  • path (str) – path where to save the JSON file (default: working directory).
PySimpleAutomata.automata_IO.dfa_dot_importer(input_file: str) → dict[source]

Imports a DFA from a DOT file.

Of DOT files are recognized the following attributes:

  • nodeX shape=doublecircle -> accepting node;
  • nodeX root=true -> initial node;
  • edgeX label=”a” -> action in alphabet;
  • fake [style=invisible] -> dummy invisible node pointing
    to initial state (they will be skipped);
  • fake-> S [style=bold] -> dummy transition to draw the arrow
    pointing to initial state (it will be skipped).

Forbidden names:

  • ‘fake’ used for graphical purpose to drawn the arrow of the initial state;
  • ‘sink’ used as additional state when completing a DFA;
  • ‘None’ used when no initial state is present.
Forbidden characters:
  • (
  • )
  • spaces
Parameters:input_file (str) – path to the DOT file;
Returns:(dict) representing a DFA.
PySimpleAutomata.automata_IO.dfa_json_importer(input_file: str) → dict[source]

Imports a DFA from a JSON file.

Parameters:input_file (str) – path + filename to json file;
Returns:(dict) representing a DFA.
PySimpleAutomata.automata_IO.dfa_to_dot(dfa: dict, name: str, path: str = './')[source]

Generates a DOT file and a relative SVG image in path folder of the input DFA using graphviz library.

Parameters:
  • dfa (dict) – DFA to export;
  • name (str) – name of the output file;
  • path (str) – path where to save the DOT/SVG files (default: working directory)
PySimpleAutomata.automata_IO.dfa_to_json(dfa: dict, name: str, path: str = './')[source]

Exports a DFA to a JSON file.

If path do not exists, it will be created.

Parameters:
  • dfa (dict) – DFA to export;
  • name (str) – name of the output file;
  • path (str) – path where to save the JSON file (default: working directory)
PySimpleAutomata.automata_IO.nfa_dot_importer(input_file: str) → dict[source]

Imports a NFA from a DOT file.

Of .dot files are recognized the following attributes
  • nodeX shape=doublecircle -> accepting node;
  • nodeX root=true -> initial node;
  • edgeX label=”a” -> action in alphabet;
  • fakeX style=invisible -> dummy invisible nodes pointing
    to initial state (it will be skipped);
  • fakeX->S [style=bold] -> dummy transitions to draw arrows
    pointing to initial states (they will be skipped).

All invisible nodes are skipped.

Forbidden names:
  • ‘fake’ used for graphical purpose to drawn the arrow of the initial state
  • ‘sink’ used as additional state when completing a NFA
Forbidden characters:
  • (
  • )
  • spaces
Parameters:input_file (str) – Path to input DOT file;
Returns:(dict) representing a NFA.
PySimpleAutomata.automata_IO.nfa_json_importer(input_file: str) → dict[source]

Imports a NFA from a JSON file.

Parameters:input_file (str) – path+filename to JSON file;
Returns:(dict) representing a NFA.
PySimpleAutomata.automata_IO.nfa_to_dot(nfa: dict, name: str, path: str = './')[source]

Generates a DOT file and a relative SVG image in path folder of the input NFA using graphviz library.

Parameters:
  • nfa (dict) – input NFA;
  • name (str) – string with the name of the output file;
  • path (str) – path where to save the DOT/SVG files (default: working directory).
PySimpleAutomata.automata_IO.nfa_to_json(nfa: dict, name: str, path: str = './')[source]

Exports a NFA to a JSON file.

Parameters:
  • nfa (dict) – NFA to export;
  • name (str) – name of the output file;
  • path (str) – path where to save the JSON file (default: working directory).