Custom Graph: Difference between revisions

(Created page with "You can visualise the state of an individual B, Z, TLA+ or Alloy model using custom graph definitions which are laid out using GraphViz. Thereby it is possible to specify general graph attributes, the nodes and the edges of the graph.")
 
No edit summary
Line 2: Line 2:


Thereby it is possible to specify general graph attributes, the nodes and the edges of the graph.
Thereby it is possible to specify general graph attributes, the nodes and the edges of the graph.
There are various ways such a custom graph can be defined.
The most powerful is providing a single DEFINITION called <tt>CUSTOM_GRAPH</tt> which defines global graph properties as well as defines nodes and edges.
Suppose we have a B model with a binary relation <tt>edge</tt> and a set <tt>NODES</tt> as well as a total function <tt>ice</tt> from these nodes to BOOL.
Here is an example custom graph definition:
<pre>
CUSTOM_GRAPH == rec(layout:"dot", rankdir:"TB",
                    nodes:ran( %j.(j:NODES |
                              rec(value:j, style:"filled",
                                fillcolor:IF ice(j)=TRUE THEN "mistyrose" ELSE "white" END
                              ))),
                    edges:rec(color:"gray", arrowhead:"odot",
                              arrowtail:"odot", dir:"both",
                              label:"edge",
                              edges: edge)
                    );
</pre>

Revision as of 12:34, 6 January 2024

You can visualise the state of an individual B, Z, TLA+ or Alloy model using custom graph definitions which are laid out using GraphViz.

Thereby it is possible to specify general graph attributes, the nodes and the edges of the graph.

There are various ways such a custom graph can be defined. The most powerful is providing a single DEFINITION called CUSTOM_GRAPH which defines global graph properties as well as defines nodes and edges.

Suppose we have a B model with a binary relation edge and a set NODES as well as a total function ice from these nodes to BOOL. Here is an example custom graph definition:

 CUSTOM_GRAPH == rec(layout:"dot", rankdir:"TB",
                     nodes:ran( %j.(j:NODES |
                               rec(value:j, style:"filled",
                                fillcolor:IF ice(j)=TRUE THEN "mistyrose" ELSE "white" END
                              ))),
                    edges:rec(color:"gray", arrowhead:"odot",
                              arrowtail:"odot", dir:"both",
                              label:"edge",
                              edges: edge)
                    );