The main implementation is found in petri_net.rs
. It uses two BTreeMap
to store the places and transitions. References to places and transitions are named PlaceRef
and TransitionRef
respectively. Places and transitions are labeled with String
. The net keeps the places in order, which allows the iterators to be deterministic.
References to the places and transitions are returned when adding them to the net. These references can later be used to add arcs and to access the markings.
Note: References can be cloned. One may have as many references to a place or transition as desired.
- Petri Net Markup Language (PNML) https://www.pnml.org/
- LoLA - A Low Level Petri Net Analyzer https://theo.informatik.uni-rostock.de/theo-forschung/tools/lola/
- DOT (graph description language) https://en.wikipedia.org/wiki/DOT_(graph_description_language)
To get a local copy up and running follow these simple example steps.
- Install Rust using one of the methods described on the Rust Website
-
Clone the repo
git clone https://github.com/hlisdero/netcrab.git
-
Build the project with
cargo
cargo build
-
Run the tests to check that everything works with
cargo
cargo test
Creating a custom Petri net with a single place and a single transition forming a loop:
use netcrab::net::PetriNet;
let mut net = PetriNet::new();
let place_ref = net.add_place("Example place");
let transition_ref = net.add_transition("Example transition");
let result = net.add_arc_place_transition(&place_ref, &transition_ref);
assert!(result.is_ok());
let result = net.add_arc_transition_place(&transition_ref, &place_ref);
assert!(result.is_ok());
Note: For more examples, please refer to the unit tests in each module.
Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-MIT, LICENSE-APACHE for more information.
Project Link: https://github.com/hlisdero/netcrab
Based on the original work by Tom Meyer found in https://github.com/Skasselbard/PetriToStar.
This README.md
is based on the template provided by Best-README-Template