  
  [1XB [33X[0;0YDrawing automata[133X[101X
  
  [33X[0;0YThe  drawing of graphs described here uses [10Xgraphviz[110X [DEG+02], a software for
  drawing  graphs  developed  at  AT  &  T  Labs,  that  can  be  obtained  at
  [7Xhttps://www.graphviz.org/[107X.[133X
  
  
  [1XB.1 [33X[0;0YInstalling some external programs[133X[101X
  
  [33X[0;0YIn    order    to   create   the   drawings   you   should   have   graphviz
  ([7Xhttps://www.graphviz.org/[107X)  installed  and  to  view  them  you should have
  installed some [10Xpdf[110X viewer.[133X
  
  
  [1XB.2 [33X[0;0YFunctions to draw automata[133X[101X
  
  [1XB.2-1 DrawAutomaton[101X
  
  [33X[1;0Y[29X[2XDrawAutomaton[102X( [3XA[103X[, [3Xstate_names[103X, [3XL[103X] ) [32X function[133X
  
  [33X[0;0YThis  function  draws automaton [3XA[103X. The arguments [3Xstate_names[103X, [3XL[103X and [3Xfile[103X are
  optional.[133X
  
  [33X[0;0YAn  automaton with [10Xn[110X states will be drawn with numbers [10X1[110X to [10Xn[110X written inside
  the  corresponding  graph  node.  The  argument  [3Xstate_names[103X  is a list of [10Xn[110X
  strings  which  will  be the new text written inside the corresponding graph
  node.[133X
  
  [33X[0;0YThe argument [3XL[103X is a list of lists of integers, each of which specifies a set
  of states to be drawn in a different color.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=Automaton("det",3,2,[ [ 2, 3, 0 ], [ 0, 1, 2 ] ],[ 1 ],[ 1, 2, 3 ]);;[127X[104X
    [4X[25Xgap>[125X [27XDrawAutomaton(x);[127X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XDrawAutomaton(x,["st 1", "2", "C"]);[127X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XDrawAutomaton(x,["st 1", "2", "C"],[[2],[1,3]]);[127X[104X
  [4X[32X[104X
  
  [33X[0;0YThe  output  of  the  three  previous  [10XDrawAutomaton[110X  commands  would be the
  following diagrams, respectively.[133X
  
  [1XB.2-2 DotForDrawingAutomaton[101X
  
  [33X[1;0Y[29X[2XDotForDrawingAutomaton[102X( [3Xarg[103X ) [32X function[133X
  
  [33X[0;0YThis  function  computes  the  dot  code  that  can  be  used  to display an
  automaton.  This can be done by using the function [2XDrawAutomaton[102X ([14XB.2-1[114X) (if
  the  system  is properly configured) or by the user in some independent way.
  The arguments and options are the same than those of [2XDrawAutomaton[102X ([14XB.2-1[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XDotStringForDrawingAutomaton(x);[127X[104X
    [4X[28X"digraph  Automaton{\n\"1\" -> \"2\" [label=\"a\",color=red];\n\"2\" -> \"3\" \[128X[104X
    [4X[28X[label=\"a\",color=red];\n\"2\" -> \"1\" [label=\"b\",color=blue];\n\"3\" -> \[128X[104X
    [4X[28X\"2\" [label=\"b\",color=blue];\n\"1\" [shape=triangle,peripheries=2, style=fi\[128X[104X
    [4X[28Xlled, fillcolor=white];\n\"2\" [shape=doublecircle, style=filled, fillcolor=wh\[128X[104X
    [4X[28Xite];\n\"3\" [shape=doublecircle, style=filled, fillcolor=white];\n}\n"[128X[104X
    [4X[28X      [128X[104X
  [4X[32X[104X
  
  [33X[0;0YBy  using  Print  (or PrinTo, if one wants to print to a file) the string is
  displayed as follows:[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XPrint(last);[127X[104X
    [4X[28Xdigraph  Automaton{[128X[104X
    [4X[28X"1" -> "2" [label="a",color=red];[128X[104X
    [4X[28X"2" -> "3" [label="a",color=red];[128X[104X
    [4X[28X"2" -> "1" [label="b",color=blue];[128X[104X
    [4X[28X"3" -> "2" [label="b",color=blue];[128X[104X
    [4X[28X"1" [shape=triangle,peripheries=2, style=filled, fillcolor=white];[128X[104X
    [4X[28X"2" [shape=doublecircle, style=filled, fillcolor=white];[128X[104X
    [4X[28X"3" [shape=doublecircle, style=filled, fillcolor=white];[128X[104X
    [4X[28X}[128X[104X
  [4X[32X[104X
  
  [33X[0;0YThe dot code produced for the remaining pictures:[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XPrint(DotStringForDrawingAutomaton(x,["st 1", "2", "C"]));[127X[104X
    [4X[28Xdigraph  Automaton{[128X[104X
    [4X[28X"st 1" -> "2" [label="a",color=red];[128X[104X
    [4X[28X"2" -> "C" [label="a",color=red];[128X[104X
    [4X[28X"2" -> "st 1" [label="b",color=blue];[128X[104X
    [4X[28X"C" -> "2" [label="b",color=blue];[128X[104X
    [4X[28X"st 1" [shape=triangle,peripheries=2, style=filled, fillcolor=white];[128X[104X
    [4X[28X"2" [shape=doublecircle, style=filled, fillcolor=white];[128X[104X
    [4X[28X"C" [shape=doublecircle, style=filled, fillcolor=white];[128X[104X
    [4X[28X}[128X[104X
    [4X[25Xgap>[125X [27XPrint(DotStringForDrawingAutomaton(x,["st 1", "2", "C"],[[2],[1,3]]));[127X[104X
    [4X[28Xdigraph  Automaton{[128X[104X
    [4X[28X"st 1" -> "2" [label="a",color=red];[128X[104X
    [4X[28X"2" -> "C" [label="a",color=red];[128X[104X
    [4X[28X"2" -> "st 1" [label="b",color=blue];[128X[104X
    [4X[28X"C" -> "2" [label="b",color=blue];[128X[104X
    [4X[28X"st 1" [shape=triangle,peripheries=2, style=filled, fillcolor=burlywood];[128X[104X
    [4X[28X"2" [shape=doublecircle, style=filled, fillcolor=brown];[128X[104X
    [4X[28X"C" [shape=doublecircle, style=filled, fillcolor=burlywood];[128X[104X
    [4X[28X}[128X[104X
  [4X[32X[104X
  
  [1XB.2-3 DrawSubAutomaton[101X
  
  [33X[1;0Y[29X[2XDrawSubAutomaton[102X( [3XA[103X, [3XB[103X ) [32X function[133X
  
  [33X[0;0YThis  function tests if automaton [10X A [110X is a subautomaton of [10X B [110X in which case
  draws  [10X  B  [110X  highlighting  the edges not in [10X A [110X by drawing them in a dotted
  style, while the others are drawn in a plain style.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XA := Automaton("nondet",5,"abc",[ [ [ 2, 3 ], [ 5 ], [ 1, 4, 5 ], [ 1, 5 ],[127X[104X
    [4X[28X[ 3, 4 ] ], [ [ 1, 4, 5 ], [ ], [ 1 ], [ 1, 3, 5 ], [ 1, 2, 5 ] ], [ [ ],[128X[104X
    [4X[28X[ 2, 4, 5 ], [ 1, 3, 5 ], [ ], [ 2, 3, 4 ] ] ],[ ],[ 2, 3, 4 ]);;[128X[104X
    [4X[25Xgap>[125X [27XB := Automaton("nondet",5,"abc",[ [ [ 2, 3 ], [ 5 ], [ 1, 4, 5 ], [ 1, 5 ],[127X[104X
    [4X[28X[ 3, 4 ] ], [ [ 1, 4, 5 ], [ ], [ 1 ], [ 1, 3, 5 ], [ 1, 2, 5 ] ], [ [ 1, 4, 5 ],[128X[104X
    [4X[28X[ 2, 4, 5 ], [ 1, 3, 5 ], [ 2, 3, 4, 5 ], [ 2, 3, 4 ] ] ],[ 3, 4, 5 ],[ 2, 3, 4 ]);;[128X[104X
    [4X[25Xgap>[125X [27XDrawSubAutomaton(A,B);[127X[104X
  [4X[32X[104X
  
  [33X[0;0YThe  output  is  as  follows,  in  case  the  configuration of your computer
  permits. Otherwise, you may be interested in the dot code, as pshown below.[133X
  
  [1XB.2-4 DotStringForDrawingSubAutomaton[101X
  
  [33X[1;0Y[29X[2XDotStringForDrawingSubAutomaton[102X( [3XA[103X, [3XB[103X ) [32X function[133X
  
  [33X[0;0YThis  function  computes  the  dot code that can be used to draw automata A,
  with  the  subsutomaton  B  emphasized.  It is silently used by the function
  [2XDrawSubAutomaton[102X  ([14XB.2-3[114X)  (if  the system is properly configured) or can be
  used by the user in some independent way.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XDotStringForDrawingSubAutomaton(A,B);[127X[104X
    [4X[28X"digraph  Automaton {\n1 -> 2 [label=\"a\",color=red];\n1 -> 3 [label=\"a\",co\[128X[104X
    [4X[28Xlor=red];\n1 -> 1 [label=\"b\",color=blue];\n1 -> 4 [label=\"b\",color=blue];\[128X[104X
    [4X[28X\n1 -> 5 [label=\"b\",color=blue];\n1 -> 1 [label=\"c\",color=green,style = do\[128X[104X
    [4X[28Xtted];\n1 -> 4 [label=\"c\",color=green,style = dotted];\n1 -> 5 [label=\"c\",\[128X[104X
    [4X[28Xcolor=green,style = dotted];\n2 -> 5 [label=\"a\",color=red];\n2 -> 2 [label=\[128X[104X
    [4X[28X\"c\",color=green];\n2 -> 4 [label=\"c\",color=green];\n2 -> 5 [label=\"c\",co\[128X[104X
    [4X[28Xlor=green];\n3 -> 1 [label=\"a\",color=red];\n3 -> 4 [label=\"a\",color=red];\[128X[104X
    [4X[28X\n3 -> 5 [label=\"a\",color=red];\n3 -> 1 [label=\"b\",color=blue];\n3 -> 1 [l\[128X[104X
    [4X[28Xabel=\"c\",color=green];\n3 -> 3 [label=\"c\",color=green];\n3 -> 5 [label=\"c\[128X[104X
    [4X[28X\",color=green];\n4 -> 1 [label=\"a\",color=red];\n4 -> 5 [label=\"a\",color=r\[128X[104X
    [4X[28Xed];\n4 -> 1 [label=\"b\",color=blue];\n4 -> 3 [label=\"b\",color=blue];\n4 ->\[128X[104X
    [4X[28X 5 [label=\"b\",color=blue];\n4 -> 2 [label=\"c\",color=green,style = dotted];\[128X[104X
    [4X[28X\n4 -> 3 [label=\"c\",color=green,style = dotted];\n4 -> 4 [label=\"c\",color=\[128X[104X
    [4X[28Xgreen,style = dotted];\n4 -> 5 [label=\"c\",color=green,style = dotted];\n5 ->\[128X[104X
    [4X[28X 3 [label=\"a\",color=red];\n5 -> 4 [label=\"a\",color=red];\n5 -> 1 [label=\"\[128X[104X
    [4X[28Xb\",color=blue];\n5 -> 2 [label=\"b\",color=blue];\n5 -> 5 [label=\"b\",color=\[128X[104X
    [4X[28Xblue];\n5 -> 2 [label=\"c\",color=green];\n5 -> 3 [label=\"c\",color=green];\n\[128X[104X
    [4X[28X5 -> 4 [label=\"c\",color=green];\n3 [shape=triangle,color=gray];\n4 [shape=tr\[128X[104X
    [4X[28Xiangle,color=gray];\n5 [shape=triangle,color=gray];\n2 [shape=doublecircle];\n\[128X[104X
    [4X[28X3 [shape=doublecircle];\n4 [shape=doublecircle];\n1 [shape=circle];\n}\n"[128X[104X
    [4X[28X      [128X[104X
  [4X[32X[104X
  
  [33X[0;0YBy  using  Print  (or PrinTo, if one wants to print to a file) the string is
  displayed as follows:[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XPrint(last);[127X[104X
    [4X[28Xdigraph  Automaton {[128X[104X
    [4X[28X1 -> 2 [label="a",color=red];[128X[104X
    [4X[28X1 -> 3 [label="a",color=red];[128X[104X
    [4X[28X1 -> 1 [label="b",color=blue];[128X[104X
    [4X[28X1 -> 4 [label="b",color=blue];[128X[104X
    [4X[28X1 -> 5 [label="b",color=blue];[128X[104X
    [4X[28X1 -> 1 [label="c",color=green,style = dotted];[128X[104X
    [4X[28X1 -> 4 [label="c",color=green,style = dotted];[128X[104X
    [4X[28X1 -> 5 [label="c",color=green,style = dotted];[128X[104X
    [4X[28X2 -> 5 [label="a",color=red];[128X[104X
    [4X[28X2 -> 2 [label="c",color=green];[128X[104X
    [4X[28X2 -> 4 [label="c",color=green];[128X[104X
    [4X[28X2 -> 5 [label="c",color=green];[128X[104X
    [4X[28X3 -> 1 [label="a",color=red];[128X[104X
    [4X[28X3 -> 4 [label="a",color=red];[128X[104X
    [4X[28X3 -> 5 [label="a",color=red];[128X[104X
    [4X[28X3 -> 1 [label="b",color=blue];[128X[104X
    [4X[28X3 -> 1 [label="c",color=green];[128X[104X
    [4X[28X3 -> 3 [label="c",color=green];[128X[104X
    [4X[28X3 -> 5 [label="c",color=green];[128X[104X
    [4X[28X4 -> 1 [label="a",color=red];[128X[104X
    [4X[28X4 -> 5 [label="a",color=red];[128X[104X
    [4X[28X4 -> 1 [label="b",color=blue];[128X[104X
    [4X[28X4 -> 3 [label="b",color=blue];[128X[104X
    [4X[28X4 -> 5 [label="b",color=blue];[128X[104X
    [4X[28X4 -> 2 [label="c",color=green,style = dotted];[128X[104X
    [4X[28X4 -> 3 [label="c",color=green,style = dotted];[128X[104X
    [4X[28X4 -> 4 [label="c",color=green,style = dotted];[128X[104X
    [4X[28X4 -> 5 [label="c",color=green,style = dotted];[128X[104X
    [4X[28X5 -> 3 [label="a",color=red];[128X[104X
    [4X[28X5 -> 4 [label="a",color=red];[128X[104X
    [4X[28X5 -> 1 [label="b",color=blue];[128X[104X
    [4X[28X5 -> 2 [label="b",color=blue];[128X[104X
    [4X[28X5 -> 5 [label="b",color=blue];[128X[104X
    [4X[28X5 -> 2 [label="c",color=green];[128X[104X
    [4X[28X5 -> 3 [label="c",color=green];[128X[104X
    [4X[28X5 -> 4 [label="c",color=green];[128X[104X
    [4X[28X3 [shape=triangle,color=gray];[128X[104X
    [4X[28X4 [shape=triangle,color=gray];[128X[104X
    [4X[28X5 [shape=triangle,color=gray];[128X[104X
    [4X[28X2 [shape=doublecircle];[128X[104X
    [4X[28X3 [shape=doublecircle];[128X[104X
    [4X[28X4 [shape=doublecircle];[128X[104X
    [4X[28X1 [shape=circle];[128X[104X
    [4X[28X}[128X[104X
  [4X[32X[104X
  
  [1XB.2-5 DotStringForDrawingGraph[101X
  
  [33X[1;0Y[29X[2XDotStringForDrawingGraph[102X( [3XG[103X ) [32X function[133X
  [33X[1;0Y[29X[2XDrawGraph[102X( [3XG[103X ) [32X function[133X
  
  [33X[0;0YDraws a graph specified as an adjacency list [10XG[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XG := [[1,2,3],[5],[3,4],[1],[2,5]];[127X[104X
    [4X[28X[ [ 1, 2, 3 ], [ 5 ], [ 3, 4 ], [ 1 ], [ 2, 5 ] ][128X[104X
    [4X[25Xgap>[125X [27XPrint(DotStringForDrawingGraph(G));[127X[104X
    [4X[28Xdigraph Graph__{[128X[104X
    [4X[28X1 -> 1 [style=bold, color=black];[128X[104X
    [4X[28X1 -> 2 [style=bold, color=black];[128X[104X
    [4X[28X1 -> 3 [style=bold, color=black];[128X[104X
    [4X[28X2 -> 5 [style=bold, color=black];[128X[104X
    [4X[28X3 -> 3 [style=bold, color=black];[128X[104X
    [4X[28X3 -> 4 [style=bold, color=black];[128X[104X
    [4X[28X4 -> 1 [style=bold, color=black];[128X[104X
    [4X[28X5 -> 2 [style=bold, color=black];[128X[104X
    [4X[28X5 -> 5 [style=bold, color=black];[128X[104X
    [4X[28X1 [shape=circle];[128X[104X
    [4X[28X2 [shape=circle];[128X[104X
    [4X[28X3 [shape=circle];[128X[104X
    [4X[28X4 [shape=circle];[128X[104X
    [4X[28X5 [shape=circle];[128X[104X
    [4X[28X}[128X[104X
  [4X[32X[104X
  
  [33X[0;0YThe dot code can be used to produce the following picture (which may also be
  produced by typing [10XDrawGraph(G);[110X[133X
  
  [1XB.2-6 DrawSCCAutomaton[101X
  
  [33X[1;0Y[29X[2XDrawSCCAutomaton[102X( [3XA[103X[, [3Xstate_names[103X, [3XL[103X] ) [32X function[133X
  
  [33X[0;0YDraws  automaton  [10X  A  [110X and highlights it's strongly connected components by
  drawing the other edges in a dotted style.[133X
  
  [33X[0;0YThe  optional  arguments [3Xstate_names[103X and [3XL[103X are as described in [2XDrawAutomaton[102X
  ([14XB.2-1[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xrcg := Automaton("det",6,"ab",[ [ 3, 3, 6, 5, 6, 6 ], [ 4, 6, 2, 6, 4, 6 ] ],[127X[104X
    [4X[28X[ ],[ ]);;[128X[104X
    [4X[25Xgap>[125X [27XPrint(DotStringForDrawingSCCAutomaton(rcg));[127X[104X
    [4X[28Xdigraph  Automaton{[128X[104X
    [4X[28X"1" -> "3" [label="a",color=red,style = dotted];[128X[104X
    [4X[28X"2" -> "3" [label="a",color=red];[128X[104X
    [4X[28X"3" -> "6" [label="a",color=red,style = dotted];[128X[104X
    [4X[28X"4" -> "5" [label="a",color=red];[128X[104X
    [4X[28X"5" -> "6" [label="a",color=red,style = dotted];[128X[104X
    [4X[28X"6" -> "6" [label="a",color=red,style = dotted];[128X[104X
    [4X[28X"1" -> "4" [label="b",color=blue,style = dotted];[128X[104X
    [4X[28X"2" -> "6" [label="b",color=blue,style = dotted];[128X[104X
    [4X[28X"3" -> "2" [label="b",color=blue];[128X[104X
    [4X[28X"4" -> "6" [label="b",color=blue,style = dotted];[128X[104X
    [4X[28X"5" -> "4" [label="b",color=blue];[128X[104X
    [4X[28X"6" -> "6" [label="b",color=blue,style = dotted];[128X[104X
    [4X[28X"1" [shape=circle, style=filled, fillcolor=white];[128X[104X
    [4X[28X"2" [shape=circle, style=filled, fillcolor=white];[128X[104X
    [4X[28X"3" [shape=circle, style=filled, fillcolor=white];[128X[104X
    [4X[28X"4" [shape=circle, style=filled, fillcolor=white];[128X[104X
    [4X[28X"5" [shape=circle, style=filled, fillcolor=white];[128X[104X
    [4X[28X"6" [shape=circle, style=filled, fillcolor=white];[128X[104X
    [4X[28X}[128X[104X
  [4X[32X[104X
  
  [33X[0;0YThe dot code can be used to produce the following picture (which may also be
  produced by typing [10XDrawGraph(G);[110X[133X
  
