Beside drawing state spaces in CPN Tools, it is possible to export state space graph and SCC graph structure from CPN Tools to Graphviz. Graphviz is open source graph drawing software developed at AT&T Research Labs.
With functions that are described below, the graph structure of (partial) state spaces and SCC graphs can be exported to files that can be then used as input files to Graphviz tools. The Graphviz tools can then be used to draw the graphs, display the graphs, and export the graphs to various formats such as PostScript, JPEG, and PNG.
Exporting State Space and SCC Graph Structure
After the state space tool has been entered, a number of functions are available for exporting state space and SCC graph structure.
OGtoGraphviz.ExportNodes (filename: string , nodelist: Node list)
Exports the nodes in the list.OGtoGraphviz.ExportNodePath (filename, nodelist)
Checks whether the nodes form a path (i.e. whether there is an arc between each node and its immediate successor in the list). If this is the case, the nodes and arcs are exported. If there are multiple arcs between two neighbouring nodes, they are all exported.OGtoGraphviz.ExportArcs (filename, arclist : Arc list)
Exports the arcs and their source and destination nodes.OGtoGraphviz.ExportArcPath (filename, arclist)
Checks whether the arcs form a path (i.e. whether the destination node of an arc is the same as the source node of its immediate successor in the list). If this is the case, the arcs and their source and destination nodes are exported.OGtoGraphviz.ExportSuccessors (filename, nodelist)
Exports the nodes in the list, their immediate successor arcs, and their immediate successor nodes. The function only exports nodes and arcs which have already been calculated.OGtoGraphviz.ExportPredecessors (filename, nodelist)
Analogous toOGtoGraphviz.ExportSuccessors
OGtoGraphviz.ExportStateSpace (filename)
Exports the nodes and arcs in the state space that has been calculated. The calculated state space may only be a partial state space.OGtoGraphviz.ExportSccGraph (filename)
Exports the nodes and arcs in the Scc graph.
Nodes and Arcs are defined in Chapter 3 of the manual for the state space tool.
Using the Export Functions
Evaluating the functions above will export the desired graph structure to a file. The Create Auxiliary Text and Evaluate ML tools can be used to evaluate the functions.
The file that is created adheres to the DOT language that is the input file format for the Graphviz tools.
Using Graphviz
The following is a very brief introduction to how to use Graphviz. For more information about using Graphviz, see the web site for Graphviz.
Download and Install Graphviz
Before Graphviz can be used to draw SCC graphs and (parts of) state spaces, you must first download and install it. See the see the web site for Graphviz for instructions for downloading and installing Graphviz.
Drawing Graphs
There are at least three different ways to draw the graphs that are exported from CPN Tools to Graphviz tools.
One alternative is to run the dot
program from a command line:
$ dot -Tps SuccessorsList.dot -o SuccessorsList.ps
In this example, the graph will be drawn and saved in PostScript format.
A second alternative is to use the graphical interface to the dot
tool, e.g. to draw and save the graph in JPEG format:
A third alternative is to use the dotty
program to draw and display the graph:
Example Net
An example net can be found in a subdir of cpntools called Samples\\ResourceAllocation
.
The file is
Related pages
Verification, State space tools, Draw state spaces with CPN Tools
You must be logged in to post a comment.