Dining Philosophers | BRITNeY Suite |
Dining Philosophers example that allows you to draw the state-space using low-level functions | Examples |
The model has not been altered, but a page with queries has been added , which can be used to draw the state-space once calculated.
The only thing differing from the Hello World example is that we create an instance of the Graph object rather than the GetString and ShowString objects.
The Queries page contains 4 queries.
The EvalAllNodes
and EvalAllArcs
functions evaluate a function for all nodes/arcs in the state-space (refer to CPN Tools' state-space manual chapter 5 for more information).
We can create a new node in the Graph by calling createNode
with the name of the new node. We compose this function with st_Node
, which give a textual representation of a node. All in all the parameter to ''"EvalAllNodes"" is a function that, given a node from the state-space, creates a node in the Graph named by a textual representation of the state-space node.
Similarily, createArc
creates an arc between two nodes (given their name) with a custom label, which is given as the third parameter (in this case the empty string).
The third query allows you to automatically layout the graph, and the fourth query allows you to export the graph in a format loadable by Graphviz.