Skip to main content

A more intuitive way to create finite automata diagrams.

Project description

finiteautomata

A more intuitive way to create finite automata diagrams.

Features

  • Define start, accept, and intermediate states.
  • Add transitions (including self-loops), can also chain multiple transitions.
  • Render state diagrams (using Graphviz under the hood).

Installation

pip install finiteautomata

To use the finiteautomata package in your code:

from finiteautomata import FiniteAutomata

# Create instance of FiniteAutomata
fsm = FiniteAutomata()

Syntax Documentation

  • state(state: str)
    Adds a state to the automata.
    Usage:

    fsm.state('q0')
    
  • start(state: str)
    Sets the starting state of the automata. If the state does not already exist, it will be created.
    Usage:

    fsm.start('q0')
    
  • accept(state: str)
    Marks a state as an accepting state. Accept states are displayed with a double circle in the diagram.
    Usage:

    fsm.accept('q1')
    
  • transition(from_state: str, symbol: str, to_state: str)
    Adds a transition from one state to another, where the symbol denotes the input triggering the transition.
    Self-loops are supported by setting from_state equal to to_state.
    Usage:

    fsm.transition('q0', 'a', 'q1')  # Transition from q0 to q1 on input 'a'
    fsm.transition('q1', 'b', 'q1')  # Self-loop on q1 for input 'b'
    
  • draw(filename: str = 'fsm', format: str = 'png', view: bool = False)
    Renders the finite automata as a diagram using Graphviz.

    • filename: Base name for the output file (without extension).
    • format: File format (e.g., 'png', 'pdf').
    • view: If set to True, the diagram is automatically opened after rendering.

    Usage:

    fsm.draw('my_automata', view=True)
    

    The method groups transitions with the same source and destination, listing multiple symbols where applicable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finiteautomata-0.2.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finiteautomata-0.2.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file finiteautomata-0.2.0.tar.gz.

File metadata

  • Download URL: finiteautomata-0.2.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for finiteautomata-0.2.0.tar.gz
Algorithm Hash digest
SHA256 19fb173393051a895a152aef1b6b4ec0469de107ab6dd85fae7902677200c353
MD5 3aca26dfb16304f5744d8f9e974f570d
BLAKE2b-256 d3aa1a0228e2cfef0dad23b821ab17d70f9fd8bf38e4895b178e6fd9e99caa79

See more details on using hashes here.

Provenance

The following attestation bundles were made for finiteautomata-0.2.0.tar.gz:

Publisher: publish.yml on vishruthb/finiteautomata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file finiteautomata-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: finiteautomata-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for finiteautomata-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90ee0ac09f038d78b8ce85fbee7d1605bdd47b5bb3249926cc2b0cbfc129f76c
MD5 24afd7f366c4242e28fff9ab4bd0be5e
BLAKE2b-256 b0188cf1a710737e819e92556b393f033a981f747efaccbffcd81e6be5751d91

See more details on using hashes here.

Provenance

The following attestation bundles were made for finiteautomata-0.2.0-py3-none-any.whl:

Publisher: publish.yml on vishruthb/finiteautomata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page