Next: , Previous: , Up: Top   [Contents]


5 Graph Language Tutorial

The language of the graphs (the DOT language) is documented well on the graphviz pages at http://www.graphviz.org/. Here we give a brief introduction (using Msc-generator additions).

You need to start with either the graph or strict graph to specify a graph, the second version does not allow multiple edges between the same two nodes.

After this, you can list nodes and edges enclosed between curly braces. Although there is no need to terminate the lines with a semicolon, we suggest to do so for better readability. Node names are underlined the first time they are used (as with signalling chart entities).

exA7_cshexA7

You can use various arrow symbols (-> or <=, for example) to generate edges with different style. The rankdir=LR line instructs the DOT layout algorithm to lay out from left to right as opposed to from top to bottom.

You can group nodes using curly braces. This is useful to add edges to all of them in one go or to instruct the dot algorithm to lay them out on the same level. The latter can be observed with node ‘e1’ being on the same rank (left-right position) as ‘D and d’. This is because both of them are mentioned inside a set of curly braces with rank=same. Whithout this, ‘e1’ would have been laid out right of ‘D and d’ as it happens with ‘e2’.

exA8_cshexA8

On the example above you can also see how to assign attributes. The label attribute can be substituted with the colon-syntax, but note that for graphs, you need to use two colons to indicate the label (as opposed to signalling charts), since single colons are used to indicate ports and compass direction. The latter is useful to impact at which angle an edge arrives/leaves the node. In the example above sw represents southwest, and the == arrow symbol results in an edge with no arrows, but double-lined.

Graphviz supports many attributes for nodes, edges and layout algorithms, try experimenting. You can also use the text formatting escapes for labels used by the signalling chart syntax, but only if you specify your label with the double colon syntax. Note that due to the peculiar design of graphviz the style attribute can have values that affect the line, fill or the shape of nodes. Multiple such values can be specified separated using the attribute multiple times.

exA9_cshexA9

You can use the subgraph keyword to make a part of the graph separate. By graphviz convention, if you select a name that begings with ‘cluster_’ the subgraph will be visibly shown. This convention is only honoured by some of the layout algorithms. As a syntactic sugar, Msc-generator defines the cluster keyword, that prepends ‘cluster_’ to the name you supply and automatically sets the label8

exB0_cshexB0

More details on the syntax of graphviz and the Msc-generator extensions can be found in Graph Language Reference.


Footnotes

(8)

If you do not specify any name, a numeric one is generated, but is not used as label.


Next: Block Diagram Language Tutorial, Previous: Signalling Chart Language Tutorial, Up: Top   [Contents]