I'm trying to
- generate a graph to be displayed in a website via Graphviz.
- make each nodes clickable by imagemap (or some other tools).
To do so, I have to render the graph
- What attribute should I set to get the max width / height of the rendered graph? I looked into the page http://www.graphviz.org/doc/info/attrs.html and tried to manipulate attributes such as
size
but it didn't seem to work on me.
- How should I interpret the
pos
attributes of nodes and edges?
Controlling the size
As you correctly assumed, this can be done by modifying size
.
Here are some examples:
digraph {1->2;}
Image dimensions: 83*155px. This is the size of the graph with default settings.
digraph {size=1; 1->2;}
Image dimensions: 51*96px. The image got scaled down to fit in a 1 inch square (96 dpi). This is expected behavior because the documentation states:
If defined and the drawing is larger
than the given size, the drawing is
uniformly scaled down so that it fits
within the given size.
digraph {size=2; 1->2;}
Image dimensions: 83*155px. Again expected behavior, the graph is already smaller than 2 inches and does not need to be scaled down.
digraph {size="2!"; 1->2;}
Image dimensions: 103*192px. The graph was scaled up to until one of the dimensions equals 2 inches. Expected behavior because the documentation states:
If size ends in an exclamation point
(!), then it is taken to be the
desired size. In this case, if both
dimensions of the drawing are less
than size, the drawing is scaled up
uniformly until at least one dimension
equals its dimension in size.
Interpreting pos attributes of nodes and edges
I'm assuming you mean to pos
values of the xdot format.
The xdot of the graph
digraph {1->2;}
is the following
digraph {
node [label="\N"];
graph [bb="0,0,54,108",
_draw_="c 9 -#ffffffff C 9 -#ffffffff P 4 0 -1 0 108 55 108 55 -1 ",
xdotversion="1.2"];
1 [pos="27,90", width="0.75", height="0.5", _draw_="c 9 -#000000ff e 27 90 27 18 ", _ldraw_="F 14.000000 11 -Times-Roman c 9 -#000000ff T 27 84 0 7 1 -1 "];
2 [pos="27,18", width="0.75", height="0.5", _draw_="c 9 -#000000ff e 27 18 27 18 ", _ldraw_="F 14.000000 11 -Times-Roman c 9 -#000000ff T 27 12 0 7 1 -2 "];
1 -> 2 [pos="e,27,36.413 27,71.831 27,64.131 27,54.974 27,46.417", _draw_="c 9 -#000000ff B 4 27 72 27 64 27 55 27 46 ", _hdraw_="S 5 -solid c 9 -#000000ff C 9 -#000000ff P 3 31 46 27 36 24 46 "];
}
The pos values of the nodes designate the center of the node position. Since the bounding box of the graph is "0,0,54,108", the node positions "27,18" and "27,90" are perfectly centered horizontally.
For edges, I guess the pos
contains the points of the edge segments, whereas _draw_
contains the B-Spline control points (but I'm not really sure about that).