Graphviz compacting graph

772 views Asked by At

I'm generating a graph with graphviz and the circo tool it provides.

The graph generated is a nice shape, but the lengths of the edges between the nodes are a lot larger than they need to be, which makes the text of the nodes be small (relative to the output image) and so hard to read.

How can I make the node be bigger (relatively) in the output image, so that the text inside the nodes is easier to read,

Output image:

enter image description here

Source graph file:

digraph G {
    FoundUrlToFollow [shape=box];
    "Fetch the URL" [shape=circle];
    FoundUrlToFollow -> "Fetch the URL";
    ResponseReceived [shape=box];
    "Fetch the URL" [shape=circle, label=<Fetch the URL>];
    "Fetch the URL" -> ResponseReceived;
    ResponseError [shape=box];
    "Fetch the URL" [shape=circle, label=<Fetch the URL>];
    "Fetch the URL" -> ResponseError;
    ResponseReceived [shape=box];
    "Log response" [shape=circle];
    ResponseReceived -> "Log response";
    ResponseReceived [shape=box];
    "Is the response OK?" [shape=circle];
    ResponseReceived -> "Is the response OK?";
    ResponseOk [shape=box];
    "Is the response OK?" [shape=circle, label=<Is the response<br/>OK?>];
    "Is the response OK?" -> ResponseOk;
    ResponseOk [shape=box];
    "Is the response HTML?" [shape=circle];
    ResponseOk -> "Is the response HTML?";
    HtmlToParse [shape=box];
    "Is the response HTML?" [shape=circle, label=<Is the response<br/>HTML?>];
    "Is the response HTML?" -> HtmlToParse;
    HtmlToParse [shape=box];
    "Parse the HTML to find links" [shape=circle];
    HtmlToParse -> "Parse the HTML to find links";
    FoundUrl [shape=box];
    "Parse the HTML to find links" [shape=circle, label=<Parse the HTML<br/>to find links>];
    "Parse the HTML to find links" -> FoundUrl;
    FoundUrl [shape=box];
    "Should we follow this URL?" [shape=circle];
    FoundUrl -> "Should we follow this URL?";
    FoundUrlToSkip [shape=box];
    "Should we follow this URL?" [shape=circle, label=<Should we<br/>follow this<br/>URL?>];
    "Should we follow this URL?" -> FoundUrlToSkip;
    FoundUrlToFollow [shape=box];
    "Should we follow this URL?" [shape=circle, label=<Should we<br/>follow this<br/>URL?>];
    "Should we follow this URL?" -> FoundUrlToFollow;
    FoundUrlToSkip [shape=box];
    "Log skipped links" [shape=circle];
    FoundUrlToSkip -> "Log skipped links";
    graph [label="Switches are circles. Events are boxes.", fontsize="12", overlap=scale];
    edge [splines=curved];
}

Command:

circo -Tpng -ograph_so.png graph.dot
2

There are 2 answers

3
CapelliC On

I would try to add mindist (less than 1) to graph:

graph [..., overlap=scale, mindist=.6];

[edit]

maybe the renderer version make a difference: here is the outcome on my machine

enter image description here

0
hobbs On

Try varying -Gsize (units of inches) and -Gdpi. You'll find that if you change them both together, you get different outputs with the same pixel size, but with different spacing between the nodes relative to the size of the nodes themselves. -Gnodesep and -Nfontsize might also be useful to tweak. You might also have better luck by rendering to EPS or PDF or SVG and then converting that to PNG, instead of using Graphviz's PNG renderer. Getting pleasing output from Graphviz is, in my experience, a very inexact science.