Graphviz memiliki beberapa command yang harus di perhatikan agar tidak salah dalam pembuatanya
command line yang terdapat pada Graphviz :
- dot : digunakan untuk menggambar graph berarah (directed graph) hierarkis.
- neato : menggambar graph standar. Gunakan aplikasi ini jika ingin menggambar graph tidak berarah (undirecred graph). Cocok untuk graph yang tidak terlalu besar (sekitar 100 node).
- fdp : menggambar graph layout seperti neato.
- sfdp : menggambar layout graph yang sangat besar.
- twopi : menggambar layout radial.
- circo : menggambar layout circular.
pertama >> new
kemudian akan keluar sebagai berikut
berikut source code yang di pergunakan di Graphviz
##"I made a program to generate dot files representing the LR(0) state graph along with computed LALR(1) lookahead for an arbitrary context-free grammar, to make the diagrams I used in this article: http://blog.lab49.com/archives/2471. The program also highlights errant nodes in red if the grammar would produce a shift/reduce or reduce/reduce conflict -- you may be able to go to http://kthielen.dnsalias.com:8082/ to produce a graph more to your liking". Contributed by Kalani Thielen.
##Command to get the layout: "dot -Gsize=10,15 -Tpng thisfile > thisfile.png"
digraph g {
graph [fontsize=30 labelloc="t" label="" splines=true overlap=false rankdir = "LR"];
ratio = auto;
"state0" [ style = "filled, bold" penwidth = 5 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #0</font></td></tr><tr><td align="left" port="r0">(0) s -> •e $ </td></tr><tr><td align="left" port="r1">(1) e -> •l '=' r </td></tr><tr><td align="left" port="r2">(2) e -> •r </td></tr><tr><td align="left" port="r3">(3) l -> •'*' r </td></tr><tr><td align="left" port="r4">(4) l -> •'n' </td></tr><tr><td align="left" port="r5">(5) r -> •l </td></tr></table>> ];
"state1" [ style = "filled" penwidth = 1 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #1</font></td></tr><tr><td align="left" port="r3">(3) l -> •'*' r </td></tr><tr><td align="left" port="r3">(3) l -> '*' •r </td></tr><tr><td align="left" port="r4">(4) l -> •'n' </td></tr><tr><td align="left" port="r5">(5) r -> •l </td></tr></table>> ];
"state2" [ style = "filled" penwidth = 1 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #2</font></td></tr><tr><td align="left" port="r4">(4) l -> 'n' •</td><td bgcolor="grey" align="right">=$</td></tr></table>> ];
"state3" [ style = "filled" penwidth = 1 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #3</font></td></tr><tr><td align="left" port="r5">(5) r -> l •</td><td bgcolor="grey" align="right">=$</td></tr></table>> ];
"state4" [ style = "filled" penwidth = 1 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #4</font></td></tr><tr><td align="left" port="r3">(3) l -> '*' r •</td><td bgcolor="grey" align="right">=$</td></tr></table>> ];
"state5" [ style = "filled" penwidth = 1 fillcolor = "black" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="black"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #5</font></td></tr><tr><td align="left" port="r0"><font color="white">(0) s -> e •$ </font></td></tr></table>> ];
"state6" [ style = "filled" penwidth = 1 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #6</font></td></tr><tr><td align="left" port="r1">(1) e -> l •'=' r </td></tr><tr><td align="left" port="r5">(5) r -> l •</td><td bgcolor="grey" align="right">$</td></tr></table>> ];
"state7" [ style = "filled" penwidth = 1 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #7</font></td></tr><tr><td align="left" port="r1">(1) e -> l '=' •r </td></tr><tr><td align="left" port="r3">(3) l -> •'*' r </td></tr><tr><td align="left" port="r4">(4) l -> •'n' </td></tr><tr><td align="left" port="r5">(5) r -> •l </td></tr></table>> ];
"state8" [ style = "filled" penwidth = 1 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #8</font></td></tr><tr><td align="left" port="r1">(1) e -> l '=' r •</td><td bgcolor="grey" align="right">$</td></tr></table>> ];
"state9" [ style = "filled" penwidth = 1 fillcolor = "white" fontname = "Courier New" shape = "Mrecord" label =<<table border="0" cellborder="0" cellpadding="3" bgcolor="white"><tr><td bgcolor="black" align="center" colspan="2"><font color="white">State #9</font></td></tr><tr><td align="left" port="r2">(2) e -> r •</td><td bgcolor="grey" align="right">$</td></tr></table>> ];
state0 -> state5 [ penwidth = 5 fontsize = 28 fontcolor = "black" label = "e" ];
state0 -> state6 [ penwidth = 5 fontsize = 28 fontcolor = "black" label = "l" ];
state0 -> state9 [ penwidth = 5 fontsize = 28 fontcolor = "black" label = "r" ];
state0 -> state1 [ penwidth = 1 fontsize = 14 fontcolor = "grey28" label = "'*'" ];
state0 -> state2 [ penwidth = 1 fontsize = 14 fontcolor = "grey28" label = "'n'" ];
state1 -> state1 [ penwidth = 1 fontsize = 14 fontcolor = "grey28" label = "'*'" ];
state1 -> state4 [ penwidth = 5 fontsize = 28 fontcolor = "black" label = "r" ];
state1 -> state2 [ penwidth = 1 fontsize = 14 fontcolor = "grey28" label = "'n'" ];
state1 -> state3 [ penwidth = 5 fontsize = 28 fontcolor = "black" label = "l" ];
state6 -> state7 [ penwidth = 1 fontsize = 14 fontcolor = "grey28" label = "'='" ];
state7 -> state8 [ penwidth = 5 fontsize = 28 fontcolor = "black" label = "r" ];
state7 -> state1 [ penwidth = 1 fontsize = 14 fontcolor = "grey28" label = "'*'" ];
state7 -> state2 [ penwidth = 1 fontsize = 14 fontcolor = "grey28" label = "'n'" ];
state7 -> state3 [ penwidth = 5 fontsize = 28 fontcolor = "black" label = "l" ];
}
masukan sourcecode berikut ke dalam Graphviz dan save dengan format, (namafile.dot) kemudian save
Penjelasan .
digraph g { di gunakan pada setiap awal yang terdapat pada Graphviz
port="r0">(0) di gunakan untuk menyambungkan portnya ..port Ke a
Berikut adalah hasilnya
Sumber : http://www.graphviz.org/