pub struct PetriNet {
    pub places: HashMap<Uuid, Place>,
    pub transitions: HashMap<Uuid, Transition>,
    pub arcs: Vec<Arc>,
    pub initial_marking: Option<Marking>,
    pub final_markings: Option<Vec<Marking>>,
}
Expand description

A Petri net of Places and Transitions

Bipartite graph of Places and Transitions with Arcs connecting them, as well as initial and final Markings

Fields§

§places: HashMap<Uuid, Place>

Places

§transitions: HashMap<Uuid, Transition>

Transitions

§arcs: Vec<Arc>

Arcs

§initial_marking: Option<Marking>

Initial marking

§final_markings: Option<Vec<Marking>>

Final markings (any of them are accepted as a final marking)

Implementations§

source§

impl PetriNet

source

pub fn new() -> Self

Create new PetriNet with no places or transitions

source

pub fn to_json(self) -> String

Serialize to JSON string

source

pub fn add_place(&mut self, place_id: Option<Uuid>) -> PlaceID

Add a place (with an optional passed UUID)

If no ID is passed, a new UUID will be generated

source

pub fn add_transition( &mut self, label: Option<String>, transition_id: Option<Uuid> ) -> TransitionID

Add a transition with an label (and with an optional passed UUID)

If no ID is passed, a new UUID will be generated

source

pub fn add_arc(&mut self, from_to: ArcType, weight: Option<u32>)

Add an arc

source

pub fn preset_of(&self, id: Uuid) -> PetriNetNodes

Get the preset of a PetriNet node referred to by passed id

source

pub fn preset_of_place(&self, p: PlaceID) -> Vec<TransitionID>

Get the preset of a PetriNet place

source

pub fn preset_of_transition(&self, t: TransitionID) -> Vec<PlaceID>

Get the preset of PetriNet transition referred to by passed id

source

pub fn postset_of(&self, id: Uuid) -> PetriNetNodes

Get postset of PetriNet node referred to by passed id

source

pub fn postset_of_place(&self, p: PlaceID) -> Vec<TransitionID>

Get postset of PetriNet place referred to by passed id

source

pub fn postset_of_transition(&self, t: TransitionID) -> Vec<PlaceID>

Get postset of PetriNet transition referred to by passed id

source

pub fn is_in_initial_marking(&self, p: &PlaceID) -> bool

Check if place is in initial marking

source

pub fn is_in_a_final_marking(&self, p: &PlaceID) -> bool

Check if place is in any final marking

Trait Implementations§

source§

impl Debug for PetriNet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PetriNet

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for PetriNet

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for PetriNet

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,