Goto Chapter: Top 1 2 3 4 5 6 A B C Bib Ind
Top of Book Previous Chapter Next Chapter

B Drawing automata
B.1 Installing some external programs
B.2 Functions to draw automata
B.2-1 DrawAutomaton
B.2-2 DrawAutomata
B.2-3 DrawGraph
B.2-4 DrawSCCAutomaton
B.3 Drawings output formats
B.4 Drawings extra graph attributes

### B Drawing automata

The drawing of graphs described here uses `graphviz` [DEGKNW02], a software for drawing graphs developed at AT & T Labs, that can be obtained at http://www.graphviz.org/.

#### B.1 Installing some external programs

In order to create the drawings you should install graphviz and to view them you should install one of evince, ggv, gsview or gv.

#### B.2 Functions to draw automata

##### B.2-1 DrawAutomaton

`> DrawAutomaton`( A[, state_names, L, file] ) | ( function )

This function draws automaton A. The arguments state_names, L and file are optional.

An automaton with `n` states will be drawn with numbers `1` to `n` written inside the corresponding graph node. The argument state_names is a list of `n` strings which will be the new text written inside the corresponding graph node.

The argument L is a list of lists of integers, each of which specifies a set of states to be drawn in a different color.

The argument file is a string that specifies the name of the file containing the drawing. If it is not give, it defaults to `"automaton"`.

    gap> x:=Automaton("det",3,2,[ [ 2, 3, 0 ], [ 0, 1, 2 ] ],[ 1 ],[ 1, 2, 3 ]);;
    gap> DrawAutomaton(x,"file_name");
    Displaying file: /tmp/tmp.Rj0v1s/file_name.dot.ps

    gap> DrawAutomaton(x,["st 1", "2", "C"],"file_name");
    Displaying file: /tmp/tmp.BCH3FO/file_name.dot.ps

    gap> DrawAutomaton(x,["st 1", "2", "C"],[[2],[1,3]]);
    Displaying file: /tmp/tmp.LPnJMq/automaton.dot.ps

The output of the three previous `DrawAutomaton` commands would be the following diagrams displayed in a ghostview window, respectively.

##### B.2-2 DrawAutomata

`> DrawAutomata`( A, B[, file] ) | ( function )

This function tests if automaton `A` is a subautomaton of `B` in which case draws `B` highlighting the edges not in `A` by drawing them in a dotted style, while the others are drawn in a plain style.

##### B.2-3 DrawGraph

`> DrawGraph`( G[, file] ) | ( function )

Draws a graph specified as an adjacency list `G`.

##### B.2-4 DrawSCCAutomaton

`> DrawSCCAutomaton`( A[, state_names, L, file] ) | ( function )

Draws automaton `A` and highlights it's strongly connected components by drawing the other edges in a dotted style.

The optional arguments state_names, L and file are as described in `DrawAutomaton` (B.2-1).

#### B.3 Drawings output formats

Since drawings are mostly used in the SgpViz package, please refer to that package's manual section of the same name.

#### B.4 Drawings extra graph attributes

Since drawings are mostly used in the SgpViz package, please refer to that package's manual section of the same name.

Top of Book Previous Chapter Next Chapter
Goto Chapter: Top 1 2 3 4 5 6 A B C Bib Ind

generated by GAPDoc2HTML