1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ||
Editor: page
Time: 2007/09/19 02:26:47 GMT-7 |
||
Note: |
added:
An Introduction to GraphViz
By Mihalis Tsoukalos on Wed, 2004-09-08 23:00.
How to use command-line tools and basic GraphViz utilities to produce graphs both simple and complex.
GraphViz is a collection of tools for manipulating graph structures and generating graph layouts. Graphs can be either directed or undirected. GraphViz offers both graphical and command-line tools. A Perl interface also is available, but it is not covered here for reasons of generality. Graphical tools are not going to be discussed in this article either. Instead, this article focuses on using GraphViz from the command line.
See more here: http://www.wickle.com/wikis/index.php/Graphviz_extension
The format of a GraphViz command is:
\begin{latex} \digraph[Options]{Name}{Specification} \end{latex}
Replace Options
with something like scale=1.0
and Specifications
with the actual graph, e.g. a->b; b->c
. Replace Name
with a name
for your graph.
The LaTeX? extension for GraphViz? (see: LatexTemplate?) produces files
named Name.dot
and Name.ps
in the images working directory. Since
this graph name is global, it is a good idea to prefix the name with
the name of the page on which the graph occurs.
The follow graphs are generated by MathAction?
My First Graph:
\begin{latex} \psfrag{alpha}[cc][cc]{$\alpha$} \psfrag{beta}[cc][cc]{$\beta$} \psfrag{gamma}[cc][cc]{$\gamma$} \digraph[scale=0.75]{GraphVizGraph1a}{rankdir=LR; alpha->beta; beta->gamma} \end{latex}
Produces: \begin{latex} \psfrag{alpha}[cc]?[cc]?{$\alpha$} \psfrag{beta}[cc]?[cc]?{$\beta$} \psfrag{gamma}[cc]?[cc]?{$\gamma$} \digraph[scale=0.75]?{GraphVizGraph?1a}{rankdir=LR; alpha->beta; beta->gamma} \end{latex}
A More Complex Example:
\begin{latex} \digraph[scale=0.8]{GraphVizGraph2a}{ size ="4,4"; main [shape=box]; /* this is a comment */ main -> parse [weight=8]; parse -> execute; main -> init [style=dotted]; main -> cleanup; execute -> { make_string; printf} init -> make_string; edge [color=red]; main -> printf [style=bold,label="100 times"]; make_string [label="make a string"]; node [shape=box,style=filled,color=".7 .3 1.0"]; execute -> compare; } \end{latex}
Produces: \begin{latex} \digraph[scale=0.8]?{GraphVizGraph?2a}{ size ="4,4"; main [shape=box]?; / this is a comment / main -> parse [weight=8]?; parse -> execute; main -> init [style=dotted]?; main -> cleanup; execute -> { make_string; printf} init -> make_string; edge [color=red]?; main -> printf [style=bold,label="100 times"]?; make_string [label="make a string"]?; node [shape=box,style=filled,color=".7 .3 1.0"]?; execute -> compare; } \end{latex}
http://www.linuxjournal.com/article/7275
This:
\begin{latex} \digraph{GraphVizGraph3a} { node [shape = record]; node0 [ label ="<f0> | <f1> J | <f2> "]; node1 [ label ="<f0> | <f1> E | <f2> "]; node4 [ label ="<f0> | <f1> C | <f2> "]; node6 [ label ="<f0> | <f1> I | <f2> "]; node2 [ label ="<f0> | <f1> U | <f2> "]; node5 [ label ="<f0> | <f1> N | <f2> "]; node9 [ label ="<f0> | <f1> Y | <f2> "]; node8 [ label ="<f0> | <f1> W | <f2> "]; node10 [ label ="<f0> | <f1> Z | <f2> "]; node7 [ label ="<f0> | <f1> A | <f2> "]; node3 [ label ="<f0> | <f1> G | <f2> "]; "node0":f0 -> "node1":f1; "node0":f2 -> "node2":f1; "node1":f0 -> "node4":f1; "node1":f2 -> "node6":f1; "node4":f0 -> "node7":f1; "node4":f2 -> "node3":f1; "node2":f0 -> "node5":f1; "node2":f2 -> "node9":f1; "node9":f0 -> "node8":f1; "node9":f2 -> "node10":f1; } \end{latex}
Gets you this:
\begin{latex}
\digraph{GraphVizGraph?3a}
{
node [shape = record]?;
node0 [ label ="
Finally:
\begin{latex} \digraph[scale=0.5]{GraphVizGraph4a} { rankdir = LR; node [shape=record, width=.1, height=.1]; node0 [label = "<p0> | <p1> | <p2> | <p3> | <p4> | | ", height = 3]; node[ width=2 ]; node1 [label = "{<e> r0 | 123 | <p> }" ]; node2 [label = "{<e> r10 | 13 | <p> }" ]; node3 [label = "{<e> r11 | 23 | <p> }" ]; node4 [label = "{<e> r12 | 326 | <p> }" ]; node5 [label = "{<e> r13 | 1f3 | <p> }" ]; node6 [label = "{<e> r20 | 123 | <p> }" ]; node7 [label = "{<e> r40 | b23 | <p> }" ]; node8 [label = "{<e> r41 | 12f | <p> }" ]; node9 [label = "{<e> r42 | 1d3 | <p> }" ]; node0:p0 -> node1:e; node0:p1 -> node2:e; node2:p -> node3:e; node3:p -> node4:e; node4:p -> node5:e; node0:p2 -> node6:e; node0:p4 -> node7:e; node7:p -> node8:e; node8:p -> node9:e; } \end{latex}
Draws a linked list
\begin{latex}
\digraph[scale=0.5]?{GraphVizGraph?4a}
{
rankdir = LR;
node [shape=record, width=.1, height=.1]?;
node0 [label = " }" ]?;
node2 [label = "{ }" ]?;
node3 [label = "{ }" ]?;
node4 [label = "{ }" ]?;
node5 [label = "{ }" ]?;
node6 [label = "{ }" ]?;
node7 [label = "{ }" ]?;
node8 [label = "{ }" ]?;
node9 [label = "{ }" ]?;
node0:p0 -> node1:e;
node0:p1 -> node2:e;
node2:p -> node3:e;
node3:p -> node4:e;
node4:p -> node5:e;
node0:p2 -> node6:e;
node0:p4 -> node7:e;
node7:p -> node8:e;
node8:p -> node9:e;
} \end{latex} I really like this new psfrag stuff!
\begin{latex}
\psfrag{a10}[cc]?[cc]?{$f^{'}(x)$}
\psfrag{b10}[cc]?[cc]?{$\int f^{'}(x)\ dx$}
\psfrag{c10}[cc]?[cc]?{$f(x)$}
\digraph[scale=1.5]?{GraphVizGraph1?0b}{rankdir=LR; a10->b10; b10->c10}
\end{latex}
Xy-pic version 3.7 <1999/02/16>
Copyright (c) 1991-1998 by Kristoffer H. Rose <krisrose@ens-lyon.fr>
Xy-pic is free software: see the User's Guide for details. Loading kernel: messages; fonts; allocations: state, direction,
utility macros; pictures: \xy, positions, objects, decorations;
kernel objects: directionals, circles, text; options; algorithms: directions,
edges, connections; Xy-pic loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xyall.tex
Xy-pic option: All features v.3.3
(/usr/share/texmf-tetex/tex/generic/xypic/xycurve.tex
Xy-pic option: Curve and Spline extension v.3.7 curve, circles, loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xyframe.tex
Xy-pic option: Frame and Bracket extension v.3.7 loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xycmtip.tex
Xy-pic option: Computer Modern tip extension v.3.3
(/usr/share/texmf-tetex/tex/generic/xypic/xytips.tex
Xy-pic option: More Tips extension v.3.3 loaded) loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xyline.tex
Xy-pic option: Line styles extension v.3.6 loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xyrotate.tex
Xy-pic option: Rotate and Scale extension v.3.3 loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xycolor.tex
Xy-pic option: Colour extension v.3.3 loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xymatrix.tex
Xy-pic option: Matrix feature v.3.4 loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xyarrow.tex
Xy-pic option: Arrow and Path feature v.3.5 path, \ar, loaded)
(/usr/share/texmf-tetex/tex/generic/xypic/xygraph.tex
Xy-pic option: Graph feature v.3.7 loaded) loaded))
(/usr/share/texmf-tetex/tex/latex/graphics/graphicx.sty
(/usr/share/texmf-tetex/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-tetex/tex/latex/graphics/graphics.sty
(/usr/share/texmf-tetex/tex/latex/graphics/trig.sty)
(/usr/share/texmf-tetex/tex/latex/graphics/graphics.cfg)
(/usr/share/texmf-tetex/tex/latex/graphics/dvips.def)))
(/usr/share/texmf-tetex/tex/latex/tools/verbatim.sty)
(/usr/share/texmf-tetex/tex/latex/graphviz/graphviz.sty
(/usr/share/texmf-tetex/tex/latex/psfrag/psfrag.sty))
(/usr/share/texmf-tetex/tex/latex/sage/sagetex.sty
Writing sage input file 1414042181583197085-18px.sage
(./1414042181583197085-18px.sout)) (./1414042181583197085-18px.aux)
I can't write on file `1414042181583197085-18px.aux'.
\document ...ate \openout \@mainaux \jobname .aux
\immediate \write \@mainau...
l.57 \begin{document} Please type another output file name
Emergency stop.
\document ...ate \openout \@mainaux \jobname .aux
\immediate \write \@mainau...
l.57 \begin{document} No pages of output.
Transcript written on 1414042181583197085-18px.log.
Some or all expressions may not have rendered properly,
because Latex returned the following error:
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
\write18 enabled.
entering extended mode
(./1414042181583197085-18px.tex
LaTeX2e <2003/12/01>
Babel <v3.8d> and hyphenation patterns for american, french, german, ngerman, b
ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch, esperanto, e
stonian, finnish, greek, icelandic, irish, italian, latin, magyar, norsk, polis
h, portuges, romanian, russian, serbian, slovak, slovene, spanish, swedish, tur
kish, ukrainian, nohyphenation, loaded.
(/usr/share/texmf-tetex/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard LaTeX document class
(/usr/share/texmf-tetex/tex/latex/base/size10.clo))
(/usr/share/texmf-tetex/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texmf-tetex/tex/latex/amsmath/amstext.sty
(/usr/share/texmf-tetex/tex/latex/amsmath/amsgen.sty))
(/usr/share/texmf-tetex/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texmf-tetex/tex/latex/amsmath/amsopn.sty))
(/usr/share/texmf-tetex/tex/latex/amsfonts/amsfonts.sty)
(/usr/share/texmf-tetex/tex/latex/amsfonts/amssymb.sty)
(/usr/share/texmf-tetex/tex/latex/amscls/amsthm.sty)
(/usr/share/texmf-tetex/tex/generic/xypic/xy.sty
(/usr/share/texmf-tetex/tex/generic/xypic/xy.tex Bootstrap'ing: catcodes,
docmode, (/usr/share/texmf-tetex/tex/generic/xypic/xyrecat.tex)
(/usr/share/texmf-tetex/tex/generic/xypic/xyidioms.tex)