2007/08/20

Draw simple graphs with DOT

A quick and painless way to generate directed and undirected graphs under windows / Linux.
The DOT language is useful because it can be easily generated by a script and hence can be used to automatically generate documentation.
It is also useful to quickly draw a professional looking graph without having to use a graphical interface.

Example:



Here is a simple graph:


Do you get it? Visit my blog often and you will never need time or ideas again to solve your problems!

Here is the .dot script that generated the graph.

Source Code: [File=Graph.dot]



digraph G
{
Computer -> David;
Problem -> David;
Time -> David;
Idea -> David;

{rank=same; Problem; Idea; David; Computer; Time;}

David -> Blog;
Problem -> You;
Blog -> You [dir=both, color=lawngreen, style = bold];
You -> Solve;

You [shape=box]
Problem [shape=tripleoctagon, color = red, style=filled, fillcolor=yellow]
David [label = "David Malin", shape=box]
Blog [label = "davidmaling.blogspot.com", shape=diamond, fontsize=15, color=steelblue3]
}


The following command will compile the .dot file into a png image:


dot -Tpng -O Graph.dot


Neat no? The program (dot) can be obtained here:
http://graphviz.org/

You can read the wikipedia entry about dot:
http://en.wikipedia.org/wiki/DOT_language

... or download a more complete documentation here:
http://graphviz.org/Documentation/dotguide.pdf

Graph on!

P.S: Send me your home-made graph and I will post it on the blog. :)

[Generated at: 2007_08_21_01h34m18s]

No comments: