Speeding Up Graphviz - Packing large graphs

Here is a Graphviz attribute that can significantly speed up certain inputs.

The good news:

  • it is very simple to use - just add one line to the input or the command line
  • it is very unlikely to cause the enginr to run slower or produce a “bad” graph
  • the speed improvement can be >50%, sometimes >95%

The down side:

  • it only helps if the input graph contains more than 1 disconnected graphs (e.g. see below)
  • probably will not speed up small graphs (< 1000 edges - just a guess)
  • it may require Graphviz release 12.0.0 or later (workaround possible for older releases)

The change:

  • add this graph [packmode=array_t999999]
    or
  • add “-Gpackmode=array_t999999” to your command line

How to tell if your input contains multiple disconnected files

  • this command give a count of disconnected graphs: gv -cn myfile.gv
  • this command give a count of disconnected graphs & count of edges: gv -cne myfile.gv (edge count is first field)
    OR
  • for more specifics, use the ccomps program (see https://www.graphviz.org/pdf/ccomps.1.pdf)

For more info on packmode see:

How to time a Graphviz run:

[the above entry was rewritten for clarity]