pub struct Net {
pub name: String,
pub transitions: IndexVec<TransitionId, Transition>,
pub places: IndexVec<PlaceId, Place>,
/* private fields */
}Expand description
Timed Petri net, with produce, consume, condition and inhibitors arcs
This structure is indexed with PlaceId and TransitionId to allow easy access to places
and transitions.
As this kind of network is a superset of standard Petri net, we can create one from standard Petri net without loosing any informations.
Fields§
§name: StringName of this network
transitions: IndexVec<TransitionId, Transition>Transitions of the network
places: IndexVec<PlaceId, Place>Places of the network
Implementations§
Source§impl Net
impl Net
Sourcepub fn create_place(&mut self) -> PlaceId
pub fn create_place(&mut self) -> PlaceId
Create a place with automatic name
Sourcepub fn create_transition(&mut self) -> TransitionId
pub fn create_transition(&mut self) -> TransitionId
Create a transition with an empty name
Sourcepub fn get_name_by_index(&self, index: &NodeId) -> Option<String>
pub fn get_name_by_index(&self, index: &NodeId) -> Option<String>
Get node name with its id
Sourcepub fn get_index_by_name(&self, name: &str) -> Option<NodeId>
pub fn get_index_by_name(&self, name: &str) -> Option<NodeId>
Get node id with its name
Sourcepub fn add_arc(&mut self, arc: Kind) -> Result<(), Box<dyn Error>>
pub fn add_arc(&mut self, arc: Kind) -> Result<(), Box<dyn Error>>
Add an arc in the network. This kind of network support only arc::Kind::Consume,
arc::Kind::Produce, arc::Kind::Inhibitor and arc::Kind::Test arcs.
§Errors
Return NetError::UnsupportedArc when trying to add a kind of arc which is not supported
Sourcepub fn delete_place(&mut self, place: PlaceId)
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.
Sourcepub fn delete_transition(&mut self, transition: TransitionId)
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.
Sourcepub fn add_priority(&mut self, tr_index: TransitionId, over: TransitionId)
pub fn add_priority(&mut self, tr_index: TransitionId, over: TransitionId)
Add a priority relation in the network