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-1.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-1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: finiteautomata-1.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.9

File hashes

Hashes for finiteautomata-1.0.tar.gz
Algorithm Hash digest
SHA256 a87630b138cd2b53bfeb1e2b18cbdbe3ea4ea2f21555e3887b53d47699ed6539
MD5 fdc009769aa9797445d63593dd978347
BLAKE2b-256 60a1dc33a8e7474553433a13120e9c9f512f86cef67c34e073ce72187d248f31

See more details on using hashes here.

Provenance

The following attestation bundles were made for finiteautomata-1.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-1.0-py3-none-any.whl.

File metadata

  • Download URL: finiteautomata-1.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.9

File hashes

Hashes for finiteautomata-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c8641321ad8508af4f8638d3e89dd9dd30db5446da3bf3ea3a3ebad352e365a
MD5 68b9f403e55263f8b50d46b9f5aefcaa
BLAKE2b-256 1ad1910b51fbf920de1a8cdfbbb9839b8a729cf4991d233180c3e3f2e4abfa54

See more details on using hashes here.

Provenance

The following attestation bundles were made for finiteautomata-1.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