public class PetriNet extends AbstractGraph<PetriNet,Flow,Node> implements IGraph<PetriNet,Flow,Node>
| Constructor and Description |
|---|
PetriNet()
Creates a new PetriNet with the name "".
|
PetriNet(PetriNet pn)
Copies a petri net.
|
PetriNet(java.lang.String name)
Creates a new PetriNet with the given name.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addFinalMarking(Marking m)
Adds a final marking to this petri net.
|
boolean |
containsNode(Node n)
Checks if this petri net contains a node.
|
boolean |
containsNode(java.lang.String id)
Checks if this petri net contains a node with the given id.
|
boolean |
containsPlace(Place p)
Checks if this petri net contains a place.
|
boolean |
containsPlace(java.lang.String id)
Checks if this petri net contains a place with the given id.
|
boolean |
containsTransition(java.lang.String id)
Checks if this petri net contains a transition with the given id.
|
boolean |
containsTransition(Transition t)
Checks if this petri net contains a transition.
|
Flow |
createFlow(Flow flow)
Creates a new flow in this petri net by copying the values from an existing arc.
|
Flow |
createFlow(Node source,
Node target)
Creates a new flow in this petri net with the given source, target and weight 1.
|
Flow |
createFlow(Node source,
Node target,
int weight)
Creates a new flow in this petri net with the given source, target and weight.
|
Flow |
createFlow(java.lang.String sourceId,
java.lang.String targetId)
Creates a new flow in this petri net with the given sourceId, targetId and weight 1.
|
Flow |
createFlow(java.lang.String sourceId,
java.lang.String targetId,
int weight)
Creates a new flow in this petri net with the given sourceId, targetId and weight.
|
Place |
createPlace()
Creates a new place with an autogenerated id to the petri net.
|
Place |
createPlace(Place p)
Creates a new place to the petri net by copying the values from a existing place.
|
Place |
createPlace(java.lang.String id)
Creates a new place to the petri net with the given id.
|
Place[] |
createPlaces(int count)
Creates #count new places in this petri net with auto generated ids.
|
Place[] |
createPlaces(Place... placeList)
Creates a few new places in this petri net by copying the values from the other places.
|
Place[] |
createPlaces(java.lang.String... idList)
Creates a few new places in this petri net with the given ids.
|
Transition |
createTransition()
Creates a new transition with an autogenerated id and the same as label to the petri net.
|
Transition |
createTransition(java.lang.String id)
Creates a new transition to the petri net with the given id.
|
Transition |
createTransition(java.lang.String id,
java.lang.String label)
Creates a new transition to the petri net with the given id and label.
|
Transition |
createTransition(Transition t)
Creates a new transition to the petri net by copying the values from a existing place.
|
Transition[] |
createTransitions(int count)
Creates #count new transitions in this petri net with auto generated ids and the same as label.
|
Transition[] |
createTransitions(java.lang.String... idList)
Creates a few new transitions in this petri net with the given ids.
|
Transition[] |
createTransitions(Transition... transitionList)
Creates a few new transitions in this petri net by copying the values from the other transitions.
|
java.util.Set<Flow> |
getEdges()
Retrieves a view of the current edge set of the graph.
|
java.util.Set<Marking> |
getFinalMarkings()
Gets a view of the final markings of this petri net.
|
Flow |
getFlow(Node source,
Node target)
Returns a flow with the given source and target.
|
Flow |
getFlow(java.lang.String sourceId,
java.lang.String targetId)
Returns a flow with the given source and target id.
|
int[][] |
getIncidenceMatrix()
Calculates and returns the incidencematrix of this petri net.
|
Marking |
getInitialMarking()
Returns a copy of the initial marking of this petri net.
|
Marking |
getInitialMarkingCopy()
Deprecated.
Use
getInitialMarking() instead, because the function name is better. |
java.lang.String |
getName()
Retrieves the name of this graph or "" if not set.
|
Node |
getNode(java.lang.String id)
Retrieves the node with the given id.
|
java.util.Set<Node> |
getNodes()
Retrieves a view of the current node set of the graph.
|
Place |
getPlace(java.lang.String id)
Returns the place with the given id.
|
java.util.Set<Place> |
getPlaces()
Gets a view of the places of this petri net.
|
java.util.Set<Flow> |
getPostsetEdges(Node node)
Retrieves a view of all edges beginning in the given node.
|
java.util.Set<Flow> |
getPostsetEdges(java.lang.String id)
Retrieves a view of all edges beginning in the node with the given id.
|
java.util.Set<Node> |
getPostsetNodes(Node node)
Retrieves a view of all nodes which have an incoming edge from the given node.
|
java.util.Set<Node> |
getPostsetNodes(java.lang.String id)
Retrieves a view of all nodes which have an incoming edge from the node with the given id.
|
java.util.Set<Flow> |
getPresetEdges(Node node)
Retrieves a view of all edges targeting the given node.
|
java.util.Set<Flow> |
getPresetEdges(java.lang.String id)
Retrieves a view of all edges targeting the node with the given id.
|
java.util.Set<Node> |
getPresetNodes(Node node)
Retrieves a view of all nodes which have an outgoing edge to the given node
|
java.util.Set<Node> |
getPresetNodes(java.lang.String id)
Retrieves a view of all nodes which have an outgoing edge to the node identified by the id.
|
Transition |
getTransition(java.lang.String id)
Returns the transition with the given id.
|
java.util.Set<Transition> |
getTransitions()
Gets a view of the transitions of this petri net.
|
void |
removeFlow(Flow flow)
* Removes a flow from this petri net.
|
void |
removeFlow(Node source,
Node target)
Removes a flow with the given source and target from this petri net.
|
void |
removeFlow(java.lang.String sourceId,
java.lang.String targetId)
Removes a flow with the given source and target id from this petri net.
|
void |
removeNode(Node node)
Removes a node from this petri net.
|
void |
removeNode(java.lang.String id)
Removes a node with the given id from this petri net.
|
void |
removePlace(Place place)
Removes a place from this petri net.
|
void |
removePlace(java.lang.String id)
Removes a place from this petri net.
|
void |
removeTransition(java.lang.String id)
Removes a transition from this petri net.
|
void |
removeTransition(Transition trans)
Removes a transition from this petri net.
|
void |
setInitialMarking(Marking m)
Sets the initial marking for this petri net.
|
void |
setName(java.lang.String name) |
addListener, invokeListeners, removeListenercopyExtensions, getCopyExtensions, getExtension, getExtensions, getExtensionsWithoutProperty, getExtensionsWithProperty, getWriteToFileExtensions, hasExtension, putExtension, putExtension, removeExtensionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, removeListenergetExtension, putExtension, removeExtensionpublic PetriNet()
public PetriNet(java.lang.String name)
name - Name of the petri net as String.public PetriNet(PetriNet pn)
pn - the petri net that should be copied.public Flow createFlow(java.lang.String sourceId, java.lang.String targetId)
sourceId - the id of the source node.targetId - the id of the target node.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if one of the ids does not match a node in this petri net.FlowExistsException - thrown if a flow with the same source and target already exists in this
petri net.IllegalFlowException - thrown if argument don't correspond to a place and a transition.public Flow createFlow(java.lang.String sourceId, java.lang.String targetId, int weight)
sourceId - the id of the source node.targetId - the id of the target node.weight - the weight of the new created flow.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if one of the ids does not match a node in this petri net.FlowExistsException - thrown if a flow with the same source and target already exists in this
petri net.IllegalFlowException - thrown if argument don't correspond to a place and a transition.public Flow createFlow(Node source, Node target, int weight)
source - the source node.target - the target node.weight - the weight of the new created flow.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if one of the ids does not match a node in this petri net.FlowExistsException - thrown if a flow with the same source and target already exists in this
petri net.IllegalFlowException - thrown if argument don't correspond to a place and a transition.public Flow createFlow(Node source, Node target)
source - the source node.target - the target node.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if one of the ids does not match a node in this petri net.FlowExistsException - thrown if a flow with the same source and target already exists in this
petri net.IllegalFlowException - thrown if argument don't correspond to a place and a transition.public Flow createFlow(Flow flow)
flow - the template flow.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if one of the ids does not match a node in this petri net.FlowExistsException - thrown if a flow with the same source and target already exists in this
petri net.IllegalFlowException - thrown if argument don't correspond to a place and a transition.public Place createPlace(java.lang.String id)
id - the id of the new place.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Place createPlace()
public Place createPlace(Place p)
p - the template place.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Place[] createPlaces(Place... placeList)
placeList - a list of places to get the id and extensions from.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Place[] createPlaces(java.lang.String... idList)
idList - a list of ids.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Place[] createPlaces(int count)
count - how many places should be created.public Transition createTransition(java.lang.String id)
id - the id of the new transition.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Transition createTransition(java.lang.String id, java.lang.String label)
id - the id of the new transition.label - the label of the new transition.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Transition createTransition()
public Transition createTransition(Transition t)
t - the template transition.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Transition[] createTransitions(Transition... transitionList)
transitionList - a list of transitions to get the id, label and extensions from.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Transition[] createTransitions(java.lang.String... idList)
idList - a list of ids.java.lang.IllegalArgumentException - thrown if passing a null argument.NodeExistsException - thrown if an other node with the same id already exists in the petri net.public Transition[] createTransitions(int count)
count - how many transitions should be created.public void removeFlow(java.lang.String sourceId,
java.lang.String targetId)
sourceId - the id of the source node of the flow to remove.targetId - the id of the target node of the flow to remove.NoSuchEdgeException - thrown if there is no flow with the given target and source in this petri
net.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if one of the ids does not match a node in this petri net.public void removeFlow(Node source, Node target)
source - the source node of the flow to remove.target - the target node of the flow to remove.NoSuchEdgeException - thrown if there is no flow with the given target and source in this petri
net.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given nodes do not belong to this petri net.public void removeFlow(Flow flow)
flow - the flow to remove.NoSuchEdgeException - thrown if this flow does not belong to this petri net.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the belonging nodes do not match in this petri net.public void removeNode(java.lang.String id)
id - the id of the node to remove.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given node do not belong to this petri net.public void removeNode(Node node)
node - the node to remove.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given node do not belong to this petri net.public void removePlace(java.lang.String id)
id - the id of the place to remove.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given place do not belong to this petri net.public void removePlace(Place place)
place - the place to remove.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given place do not belong to this petri net.public void removeTransition(java.lang.String id)
id - the id of the transition to remove.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given transition do not belong to this petri net.public void removeTransition(Transition trans)
trans - the transition to remove.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given transition do not belong to this petri net.public Flow getFlow(java.lang.String sourceId, java.lang.String targetId)
sourceId - the id of the source node of the flow.targetId - the id of the target node of the flow.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if one of the given nodes do not belong to this petri net.NoSuchEdgeException - thrown if there is no flow between the given nodes in this petri net.public Flow getFlow(Node source, Node target)
source - the source node of the flow.target - the target node of the flow.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if one of the given nodes do not belong to this petri net.NoSuchEdgeException - thrown if there is no flow between the given nodes in this petri net.public Place getPlace(java.lang.String id)
id - the id of the place to get.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given id do not belong to this petri net.public Transition getTransition(java.lang.String id)
id - the id of the transition to get.java.lang.IllegalArgumentException - thrown if passing a null argument.NoSuchNodeException - thrown if the given id do not belong to this petri net.public boolean containsNode(java.lang.String id)
id - the id of the node.java.lang.IllegalArgumentException - thrown if passing a null argument.public boolean containsNode(Node n)
n - the node.java.lang.IllegalArgumentException - thrown if passing a null argument.public boolean containsPlace(java.lang.String id)
id - the id of the place.java.lang.IllegalArgumentException - thrown if passing a null argument.public boolean containsPlace(Place p)
p - the place.java.lang.IllegalArgumentException - thrown if passing a null argument.public boolean containsTransition(java.lang.String id)
id - the id of the transition.java.lang.IllegalArgumentException - thrown if passing a null argument.public boolean containsTransition(Transition t)
t - the transition.java.lang.IllegalArgumentException - thrown if passing a null argument.public java.util.Set<Place> getPlaces()
public java.util.Set<Transition> getTransitions()
public void setInitialMarking(Marking m)
m - the marking to set as initial.java.lang.IllegalArgumentException - thrown if the given marking do not belong to this petri net.public Marking getInitialMarking()
@Deprecated public Marking getInitialMarkingCopy()
getInitialMarking() instead, because the function name is better.public boolean addFinalMarking(Marking m)
m - the marking to add as final marking.java.lang.IllegalArgumentException - thrown if the given marking do not belong to this petri net.public java.util.Set<Marking> getFinalMarkings()
public int[][] getIncidenceMatrix()
public void setName(java.lang.String name)
public java.lang.String getName()
IGraphpublic Node getNode(java.lang.String id)
getNode in interface IGraph<PetriNet,Flow,Node>id - the id of the node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the id exists in this petri net.public java.util.Set<Flow> getEdges()
IGraphpublic java.util.Set<Node> getNodes()
IGraphpublic java.util.Set<Node> getPresetNodes(java.lang.String id)
getPresetNodes in interface IGraph<PetriNet,Flow,Node>id - the id of a node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the given id exists in this graph.public java.util.Set<Node> getPostsetNodes(java.lang.String id)
getPostsetNodes in interface IGraph<PetriNet,Flow,Node>id - The id of a node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the given id exists in this graph.public java.util.Set<Flow> getPresetEdges(java.lang.String id)
getPresetEdges in interface IGraph<PetriNet,Flow,Node>id - The id of a node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the given id exists in this graph.public java.util.Set<Flow> getPostsetEdges(java.lang.String id)
getPostsetEdges in interface IGraph<PetriNet,Flow,Node>id - The id of a node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the given id exists in this graph.public java.util.Set<Flow> getPostsetEdges(Node node)
getPostsetEdges in interface IGraph<PetriNet,Flow,Node>node - The node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the given id exists in this graph.StructureException - thrown if the given node does not belong to this graph.public java.util.Set<Node> getPostsetNodes(Node node)
getPostsetNodes in interface IGraph<PetriNet,Flow,Node>node - The node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the given id exists in this graph.StructureException - thrown if the given node does not belong to this graph.public java.util.Set<Flow> getPresetEdges(Node node)
getPresetEdges in interface IGraph<PetriNet,Flow,Node>node - The node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the given id exists in this graph.StructureException - thrown if the given node does not belong to this graph.public java.util.Set<Node> getPresetNodes(Node node)
getPresetNodes in interface IGraph<PetriNet,Flow,Node>node - the node.java.lang.IllegalArgumentException - thrown if null is passed to the method.NoSuchNodeException - thrown if no node with the given id exists in this graph.StructureException - thrown if the given node does not belong to this graph.