This site has been archived and will no longer be updated.
You can find my new profile at neilpahl.com. My new blog is at 808.ninja.
Created on Sun, 26 Feb 2012. Last Modified on Fri, 20 Apr 2012.
I installed graphviz in the command line on ubuntu with
sudo apt-get install graphviz
On mac, I used macports via the command
sudo port install graphviz
Next, I created a dot file with a text editor. Something simple like:
digraph G { one -> two; one -> three; one -> four; four -> five -> six; five -> one; six -> two; }
then, save it as dotFile.dot
Next, in the command line, you can use that dot file to generate the graph. The format is as follows:
dot -Txxx dotFile.dot -o graphName.xxx
so for png, I use:
dot -Tpng dotFile.dot -o graphname.png
see the man page with
man dot
and you will see instructions for the command line usage for:
dot - filter for drawing directed graphs
neato - filter for drawing undirected graphs
twopi - filter for radial layouts of graphs
circo - filter for circular layout of graphs
fdp - filter for drawing undirected graphs
sfdp - filter for drawing large undirected graphs
I used dot above, but if you try generating the graph with neato, twopi, circo, fdp, or sfdp you get differently structured graphs. So, testing it out, I got the following:
dot -Tpng dotFile.dot -o dotGraph.png
neato -Tpng dotFile.dot -o neatoGraph.png
twopi -Tpng dotFile.dot -o twopiGraph.png
circo -Tpng dotFile.dot -o circoGraph.png
fdp -Tpng dotFile.dot -o fdpGraph.png
sfdp -Tpng dotFile.dot -o sfdpGraph.png
They all use the same .dot file, but I have yet to determine the fundamental defferences between each. I'm sure that each method has its advantages and drawbacks... things usually work that way. Perhaps as I learn about more about writing .dot files It will become more clear.
Next, I need to learn how to add some more style to my graphs, I'll look to the pdf guide found at http://www.graphviz.org/pdf/dotguide.pdf
or, in case they moved it, I uploaded a copy you can download here
I think I will print out some of the appendices for quick reference on styles I can use while creating graphs.
PLEASE let me know if I'm doing something wrong, or if you have any suggestions or requests~
blog comments powered by Disqus