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.1.5.tar.gz (2.8 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.1.5-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for finiteautomata-0.1.5.tar.gz
Algorithm Hash digest
SHA256 71021d7ad954f20eac5f5004b47f4e0f0f09534ad5d88fb406a2c9b667e82dd1
MD5 8af24206fcc71280749c4a6773f673b0
BLAKE2b-256 a16d51666e8ee4577e42c1b68e49713fe5d9b29bd563adf3a057a330210b4ce0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: finiteautomata-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 3.2 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.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f68c703769e4a69b03249c598095c339d474438d04962eb0ca3bd34276ad91ba
MD5 79309a03d92c8896a923183202ca11bb
BLAKE2b-256 84b7a198743e483422049f5103419fd971ba8c585e65e4e63a7abd8cfc313516

See more details on using hashes here.

Provenance

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