Site-wide Tags:  Linux(17) | CommandLine(12) | Ubuntu(10) | RemoteAccess(7) | Tools(7) | Vim(7) | LiftWeb(5) | SBT(5) | SoftwareDev(5) | Mac(5) | Scripts(4) | WebDev(4) | Diagrams(4) | Lifty(3) | NetworkDrives(3) | Processwire(3) | Security(3) | Fog(3) | VCS(3) | BestPractices(3) | RaspberryPi(2) | WebDesign(2) | Encryption(2) | Windows(2) | SSH(2) | WinCommandPrompt(2) | GitHubRepos(2) | Emacs(2) | PHP(2) | IDE(2) | ErrorMsgs(2) | JVM(2) | Hardware(2) | Bash(2) | Networks(2) | Graphviz(2) | Cloning | Cygwin | Graphics | Java | SystemRecovery | lessc | Maven | Python | PXE | Samba | LXDE | PackageManagement | LifeHacks | LESS |

This site has been archived and will no longer be updated.
You can find my new homepage at neilpahl.com.

Entry 2: Creating A Graph From A Dot File Via The Command Line

Topic: Graphviz   

Tags:  Linux   CommandLine   Mac   Diagrams   Graphviz   

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

All Entries Within This Topic:

  • 1: The Plan
  • 2: Creating A Graph From A Dot File Via The Command Line

Subscribe to this topic:

Browse Topics: