pnets::standard

Struct Net

Source
pub struct Net {
    pub name: String,
    pub transitions: IndexVec<TransitionId, Transition>,
    pub places: IndexVec<PlaceId, Place>,
    /* private fields */
}
Expand description

Standard Petri net, with only produce and consume arcs

This structure is indexed with PlaceId and TransitionId to allow easy access to places and transitions.

As this kind of network is a subset of timed Petri net, so we can create one from timed Petri net (but you loose arc::Kind::Inhibitor, arc::Kind::StopWatch and arc::Kind::StopWatchInhibitor arcs and timings).

Fields§

§name: String

Name of this network

§transitions: IndexVec<TransitionId, Transition>

Transitions of the network

§places: IndexVec<PlaceId, Place>

Places of the network

Implementations§

Source§

impl Net

Source

pub fn create_place(&mut self) -> PlaceId

Create a place in the network without name and return its index

Source

pub fn create_transition(&mut self) -> TransitionId

Create a transition in the network without name and return its index

Source

pub fn get_name_by_index(&self, index: &NodeId) -> Option<String>

Get node name with its id

Source

pub fn get_index_by_name(&self, name: &str) -> Option<NodeId>

Get node id with its name

Source

pub fn rename_node(&mut self, id: NodeId, name: &str) -> Result<(), NetError>

Rename node

Source

pub fn add_arc(&mut self, arc: Kind) -> Result<(), NetError>

Add an arc in the network. This kind of network support only arc::Kind::Consume and arc::Kind::Produce arcs.

§Errors

Return NetError::UnsupportedArc when trying to add a kind of arc which is not supported

Source

pub fn delete_place(&mut self, place: PlaceId)

Disconnect a place in the network

The place is not really deleted to avoid memory relocation and extra information about this place such as name can be useful later.

Source

pub fn delete_transition(&mut self, transition: TransitionId)

Disconnect a transition in the network

The transition is not really deleted to avoid memory relocation and extra information about this transitions such as name can be useful later.

Source

pub fn clone_place(&mut self, old_pl: PlaceId) -> PlaceId

Clone an existing place with all its arcs

Source

pub fn new_without_disconnected( &self, ) -> (Net, IndexVec<TransitionId, TransitionId>, IndexVec<PlaceId, PlaceId>)

Create a new network without all disconected nodes and without labels to avoid extra memory consumption.

It returns a new network and the mapping between old indexes and new indexes.

Trait Implementations§

Source§

impl Clone for Net

Source§

fn clone(&self) -> Net

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Net

Source§

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

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

impl Default for Net

Source§

fn default() -> Net

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

impl From<&Net> for Net

Source§

fn from(standard: &Net) -> Self

Converts to this type from the input type.
Source§

impl From<Net> for Net

Source§

fn from(timed: Net) -> Self

Converts to this type from the input type.
Source§

impl Index<PlaceId> for Net

Source§

type Output = Place

The returned type after indexing.
Source§

fn index(&self, index: PlaceId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<TransitionId> for Net

Source§

type Output = Transition

The returned type after indexing.
Source§

fn index(&self, index: TransitionId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<PlaceId> for Net

Source§

fn index_mut(&mut self, index: PlaceId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<TransitionId> for Net

Source§

fn index_mut(&mut self, index: TransitionId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl Freeze for Net

§

impl !RefUnwindSafe for Net

§

impl Send for Net

§

impl Sync for Net

§

impl !Unpin for Net

§

impl !UnwindSafe for Net

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.