Class ReachabilityGraph
java.lang.Object
org.tweetyproject.logics.petri.syntax.reachability_graph.ReachabilityGraph
 All Implemented Interfaces:
Iterable<Marking>
,BeliefBase
,GeneralGraph<Marking>
,Graph<Marking>
A class to describe the graph of reachability between possible markings of a Petri net
 Author:
 Benedikt Knopp

Field Summary
Fields inherited from interface org.tweetyproject.graphs.Graph
IGNORE_SELFLOOPS, INVERT_SELFLOOPS, REMOVE_SELFLOOPS

Constructor Summary

Method Summary
Modifier and TypeMethodDescriptionboolean
add
(GeneralEdge<Marking> edge) Adds the given edge to this graph.boolean
Adds the given node to this graph.boolean
add
(MarkingEdge edge) add a marking edge to this graphboolean
areAdjacent
(Marking a, Marking b) Returns "true" iff the two nodes are connected by a directed edge from a to b or an undirected edge.boolean
check if all nodes (markings) of this graph describe the same Petri net, i.e.boolean
Returns "true" when this graph contains the given node or edge.boolean
existsDirectedPath
(Marking node1, Marking node2) Checks whether there is a (directed) path from node1 to node2.Returns the adjacency matrix of this graph (the order of the nodes is the same as returned by "iterator()").getChildren
(Node node) Returns the set of children (node connected via an undirected edge or a directed edge where the given node is the parent) of the given node.getComplementGraph
(int selfloops) Returns the complement graph of this graph, i.e.Retrieve a matrix that specifies for each pair of marking and transition how likely that transition is going to occur at that marking, based on the probability function that describes this graph.Returns the corresponding edge (a,b) if a and b are adjacent.getEdges()
Returns the edges of this graph.Retrieve the designated initial markingsgetMarking
(Marking marking) Retrieve, if present, the marking in this graph that equals the query marking in the sense that both markings describe the same token distribution over placesRetrieve the markingsReturns the signature of the language of this knowledge base.getNeighbors
(Marking node) Returns the set of neighbors of the given node.getNodes()
Returns the nodes of this graph.int
the number of edges in this graphint
Returns the number of nodes in this graph.getOutgoing
(Marking marking) For one particular marking, retrieve all outgoing edgesgetParents
(Node node) Returns the set of parents (node connected via an undirected edge or a directed edge where the given node is the child) of the given node.the probability function of this graph, which is null for defaultgetRestriction
(Collection<Marking> nodes) Returns copy of this graph consisting only of the given nodes and all corresponding edges.Returns the strongly connected components of this graph.Returns the set of sub graphs of this graph.Retrieve a matrix that specifies for each pair of markings how likely a transition between these markings is going to happen, based on the probability function that describes this graph.boolean
hasMarking
(Marking marking) Determine if the specified marking is present as a node in the graphboolean
Returns "true" iff the graph has a self loop (an edge from a node to itself).boolean
specifies if the probability function of this graph is 1.void
initializes a probability function over the edges of this graph according to Random Walk, i.e.void
Initialize a probability function over the edges of this graph according to a stochastic walk.void
Initialize a probability function over the edges of this graph according to a stochastic walk.boolean
Check whether a marking is a designated initial markingboolean
Checks whether this graph only contains weighted edges.iterator()
void
setPetriNet
(PetriNet petriNet) void
setProbabilityFunction
(ProbabilityFunction<MarkingEdge> probabilityFunction) sets the probability function of this graphvoid
fix the sorting to prepare linear algebra analysis in particular, assert a fixed ordering for indexbased matrix/vectoraccessMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.tweetyproject.commons.BeliefBase
toString
Methods inherited from interface java.lang.Iterable
forEach, spliterator

Constructor Details

ReachabilityGraph
Create a new instance Parameters:
petriNet
 the underlying Petri net


Method Details

add
Description copied from interface:Graph
Adds the given node to this graph. 
add
add a marking edge to this graph Parameters:
edge
 the edge Returns:
 true iff adding the edge was successful

add
Description copied from interface:Graph
Adds the given edge to this graph. If at least one of the nodes the given edge connects is not in the graph, an illegal argument exception is thrown. 
getNodes
Description copied from interface:Graph
Returns the nodes of this graph. 
getNumberOfNodes
public int getNumberOfNodes()Description copied from interface:Graph
Returns the number of nodes in this graph. Specified by:
getNumberOfNodes
in interfaceGraph<Marking>
 Returns:
 the number of nodes in this graph.

getNumberOfEdges
public int getNumberOfEdges()the number of edges in this graph Returns:
 the number of edges in this graph

areAdjacent
Description copied from interface:Graph
Returns "true" iff the two nodes are connected by a directed edge from a to b or an undirected edge. Specified by:
areAdjacent
in interfaceGraph<Marking>
 Parameters:
a
 some nodeb
 some node Returns:
 "true" iff the two nodes are connected by a directed edge from a to b or an undirected edge.

getEdge
Description copied from interface:Graph
Returns the corresponding edge (a,b) if a and b are adjacent. Otherwise it returns null. 
getEdges
Description copied from interface:Graph
Returns the edges of this graph. 
getPetriNet
 Returns:
 the petriNet

setPetriNet
 Parameters:
petriNet
 the petriNet to set

getProbabilityFunction
the probability function of this graph, which is null for default Returns:
 the probabilityFunction

setProbabilityFunction
sets the probability function of this graph Parameters:
probabilityFunction
 the probability function to set

initializeDefaultProbabilityFunction
public void initializeDefaultProbabilityFunction()initializes a probability function over the edges of this graph according to Random Walk, i.e. all outgoing edges of one particular node are assigned to the same probability and the sum of these probabilities equals to 1. 
initializeRandomProbabilityFunction
public void initializeRandomProbabilityFunction()Initialize a probability function over the edges of this graph according to a stochastic walk. The sum of probabilities of outgoing edges at each node equals to 1, and for multiple outgoing edges, probabilities are randomized. 
initializeIrregularProbabilityFunction
public void initializeIrregularProbabilityFunction()Initialize a probability function over the edges of this graph according to a stochastic walk. For multiple outgoing edges, exactly one edge receives a probability of 1 and all other edges a probability of 0. This may turn some transitions dead. 
hasValidProbabilityFunction
public boolean hasValidProbabilityFunction()specifies if the probability function of this graph is 1. initialized, and 2. assigns for each marking a total (summed up) probability of 1 for all successor edges. This implies that each marking needs to have at least one successor marking. Returns:
 true iff the probability function is valid

sortMarkings
public void sortMarkings()fix the sorting to prepare linear algebra analysis in particular, assert a fixed ordering for indexbased matrix/vectoraccess 
getTransitionMatrix
Retrieve a matrix that specifies for each pair of markings how likely a transition between these markings is going to happen, based on the probability function that describes this graph. Returns:
 the transition matrix
 Throws:
IllegalStateException
 iff the probability function of this graph is invalid

getControlMatrix
Retrieve a matrix that specifies for each pair of marking and transition how likely that transition is going to occur at that marking, based on the probability function that describes this graph. Returns:
 the control matrix
 Throws:
IllegalStateException
 iff the probability function of this graph is invalid

iterator

contains
Description copied from interface:Graph
Returns "true" when this graph contains the given node or edge. 
getChildren
Description copied from interface:Graph
Returns the set of children (node connected via an undirected edge or a directed edge where the given node is the parent) of the given node. Specified by:
getChildren
in interfaceGraph<Marking>
 Parameters:
node
 some node (must be in the graph). Returns:
 the set of children of the given node.

getParents
Description copied from interface:Graph
Returns the set of parents (node connected via an undirected edge or a directed edge where the given node is the child) of the given node. Specified by:
getParents
in interfaceGraph<Marking>
 Parameters:
node
 some node (must be in the graph). Returns:
 the set of parents of the given node.

existsDirectedPath
Description copied from interface:Graph
Checks whether there is a (directed) path from node1 to node2. Specified by:
existsDirectedPath
in interfaceGraph<Marking>
 Parameters:
node1
 some node.node2
 some node. Returns:
 "true" if there is a directed path from node1 to node2.

getNeighbors
Description copied from interface:Graph
Returns the set of neighbors of the given node. Specified by:
getNeighbors
in interfaceGraph<Marking>
 Parameters:
node
 some node (must be in the graph). Returns:
 the set of neighbors of the given node.

getAdjacencyMatrix
Description copied from interface:Graph
Returns the adjacency matrix of this graph (the order of the nodes is the same as returned by "iterator()"). Specified by:
getAdjacencyMatrix
in interfaceGraph<Marking>
 Returns:
 the adjacency matrix of this graph

getComplementGraph
Description copied from interface:Graph
Returns the complement graph of this graph, i.e. the graph on the same set of vertices as this graph that connects two vertices v and w with an edge if and only if v and w are not connected in this graph. Specified by:
getComplementGraph
in interfaceGraph<Marking>
 Parameters:
selfloops
 Indicates how to deal with selfloops:
IGNORE_SELFLOOPS  ignore self loops (don't add and don't remove)
INVERT_SELFLOOPS  deal with self loops like ordinary edges (add if not present and remove if present)
REMOVE_SELFLOOPS  simple remove self loops, but don't add new ones. Returns:
 the complement graph of this graph.

getStronglyConnectedComponents
Description copied from interface:Graph
Returns the strongly connected components of this graph. A set of nodes is strongly connected, if there is a path from each node to each other. A set of nodes is called strongly connected component if it is strongly connected and maximal with respect to set inclusion. Specified by:
getStronglyConnectedComponents
in interfaceGraph<Marking>
 Returns:
 the strongly connected components of this graph.

getSubgraphs
Description copied from interface:Graph
Returns the set of sub graphs of this graph. Specified by:
getSubgraphs
in interfaceGraph<Marking>
 Returns:
 the set of sub graphs of this graph.

getRestriction
Description copied from interface:GeneralGraph
Returns copy of this graph consisting only of the given nodes and all corresponding edges. Specified by:
getRestriction
in interfaceGeneralGraph<Marking>
 Parameters:
nodes
 a set of nodes Returns:
 a graph.

hasSelfLoops
public boolean hasSelfLoops()Description copied from interface:Graph
Returns "true" iff the graph has a self loop (an edge from a node to itself). Specified by:
hasSelfLoops
in interfaceGraph<Marking>
 Returns:
 "true" iff the graph has a self loop (an edge from a node to itself).

isWeightedGraph
public boolean isWeightedGraph()Description copied from interface:Graph
Checks whether this graph only contains weighted edges. Specified by:
isWeightedGraph
in interfaceGraph<Marking>
 Returns:
 "true" if all edges are weighted in this graph.

hasMarking
Determine if the specified marking is present as a node in the graph Parameters:
marking
 the marking Returns:
 true if the marking is present

getMarking
Retrieve, if present, the marking in this graph that equals the query marking in the sense that both markings describe the same token distribution over places Parameters:
marking
 the query marking Returns:
 the marking that equals the query marking, or null if not present

getOutgoing
For one particular marking, retrieve all outgoing edges Parameters:
marking
 the marking of interest Returns:
 the sequence flow successors

checkConsistency
public boolean checkConsistency()check if all nodes (markings) of this graph describe the same Petri net, i.e. the same set of places Returns:
 true iff all markings describe the same set of places

getMinimalSignature
Description copied from interface:BeliefBase
Returns the signature of the language of this knowledge base. Specified by:
getMinimalSignature
in interfaceBeliefBase
 Returns:
 the signature of the language of this knowledge base.

getInitialMarkings
Retrieve the designated initial markings Returns:
 getInitialMarkings

isInitial
Check whether a marking is a designated initial marking Parameters:
marking
 the marking to check Returns:
 true iff the marking is initial

getMarkings
Retrieve the markings Returns:
 markings
