I want to create a graph like the one shown below... but way too complex. I want to use separate images for each of the square nodes and the same image for each of the circle nodes.
I want to know whether using GraphViz is the best option or are there any other options?
Also, I would like to know if I can create a template node in GraphViz for the circle one and reuse it? I don't want to specify the attributes like image, shape, etc. again and again.
Sure, here's the code to draw the graph in your Question (and which is shown rendered by dot, below).
digraph g {
rankdir = TB;
bgcolor = white;
edge[arrowsize=.7, color=black];
node[shape=box, color=black]
{rank=same; a, b, c};
{rank=same; d, e, f};
{rank=same; g, h};
{rank=same; i, j, k};
d[color=blue; shape=circle];
e[color=blue; shape=circle];
k[color=blue; shape=circle];
a -> d;
b -> d;
b -> e;
c -> e;
d -> g;
e -> h;
d -> i;
d -> j;
j -> k;
h -> k;
k -> f;
}
the first line digraph is for directed graph (for graphs in which the edges have a direction).
The fourth and fifth lies above set default attributes for edges and nodes, respectively. In other words, once you've done this, you only need to style (include attribues + values) nodes (or edges) which you want to style differently than the default values. You can have more than one node "template" by creating subgraphs, or discrete groups nodes (see the dot Manual).
rank=same allows you to specifiy a group of nodes having the same vertical position (provided rankdir is set to TB, which meant "top-to-bottom").
By default, the node name (e.g., a, b, c in my graph) is used as the node's label. If you don't want this shown in the rendered graph, just set label=""
Graphviz is definitely appropriate for what you are asking. The main graphviz.org site appears to be down for the moment, but someone has kindly mirrored the gallery examples (with source) to Flickr.
http://www.flickr.com/photos/kentbye/sets/72157601523153827/
As far as I am aware, you cannot create "templates", but you can do something like this for the circles:
node[shape=circle, color=white, style=solid];
node1;node2;node3;
This will define a node (think of it as a "state" when evaluating the file line-by-line) and then you can define your circle nodes in that "state" before switching to your rectangles.
Depending on your platform, you may also be able to import your .dot file and fine-tune it for publication. There are also a large number of generators and convertors for the format.
Mind you, if you are working on Mac OS X 10.7 "Lion", I have not been able to find or build a working version of Graphviz yet. In which case I would say it is not yet appropriate for your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With