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 thesymboldenotes the input triggering the transition.
Self-loops are supported by settingfrom_stateequal toto_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 toTrue, 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a87630b138cd2b53bfeb1e2b18cbdbe3ea4ea2f21555e3887b53d47699ed6539
|
|
| MD5 |
fdc009769aa9797445d63593dd978347
|
|
| BLAKE2b-256 |
60a1dc33a8e7474553433a13120e9c9f512f86cef67c34e073ce72187d248f31
|
Provenance
The following attestation bundles were made for finiteautomata-1.0.tar.gz:
Publisher:
publish.yml on vishruthb/finiteautomata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
finiteautomata-1.0.tar.gz -
Subject digest:
a87630b138cd2b53bfeb1e2b18cbdbe3ea4ea2f21555e3887b53d47699ed6539 - Sigstore transparency entry: 180084938
- Sigstore integration time:
-
Permalink:
vishruthb/finiteautomata@4fd5feb4674b3c3c8623d16ccc3477306e4b4493 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/vishruthb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4fd5feb4674b3c3c8623d16ccc3477306e4b4493 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c8641321ad8508af4f8638d3e89dd9dd30db5446da3bf3ea3a3ebad352e365a
|
|
| MD5 |
68b9f403e55263f8b50d46b9f5aefcaa
|
|
| BLAKE2b-256 |
1ad1910b51fbf920de1a8cdfbbb9839b8a729cf4991d233180c3e3f2e4abfa54
|
Provenance
The following attestation bundles were made for finiteautomata-1.0-py3-none-any.whl:
Publisher:
publish.yml on vishruthb/finiteautomata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
finiteautomata-1.0-py3-none-any.whl -
Subject digest:
4c8641321ad8508af4f8638d3e89dd9dd30db5446da3bf3ea3a3ebad352e365a - Sigstore transparency entry: 180084943
- Sigstore integration time:
-
Permalink:
vishruthb/finiteautomata@4fd5feb4674b3c3c8623d16ccc3477306e4b4493 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/vishruthb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4fd5feb4674b3c3c8623d16ccc3477306e4b4493 -
Trigger Event:
push
-
Statement type: