Want dot to run faster?

Here is a trick that may get dot to run faster (no guarantees, fine print to follow).
If you create dot input files that consist of multiple disconnected (sub)graphs, try:
ccomps -Cx myFile.gv | dot | gvpack -array_t99999 | neato -n2 -Tsvg -omyFile.svg
or
dot myFile.gv -Tsvg -Gpackmode=array_t99999 -o myFile.svg

(in theory, they are equivalent. In practice, not quite)
coloredText

What we are doing is splitting the graph into N disconnected (sub)graphs, doing layout independently on all N, and stitching them together into one graph. Usually, measurably faster than just running dot. Sometimes much faster.

How can you tell if a graph is a good candidate?

  • does dot take minutes or hours to process your graph?
  • ccomps -vC myFile.gv will tell you the number of disconnected components. Is it more than 1?

Don’t expect miracles.
The ccomps version finished a file with 150,851 nodes and 152,490 edges in 11 minutes! (regular dot took 81 minutes) (the packmode varient crashed at the end)
but
Some other files with disconnected (sub)graphs did not finish within a reasonable time. The above trick is not a panacea, dang.

Consider adding a comment about how often this trick works for you and how much it speeds things up. I’m curious how common large, disconnected (sub)graphs are.

p.s. the resulting graph is equivalent to, and very similar to a regular dot output. But not identical.