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:
- pack | Graphviz
- packMode | Graphviz
- dot gets stuck running mincross for a very long time on large graphs (#2475) · Issues · graphviz / graphviz · GitLab
How to time a Graphviz run:
- on Linux (& Macos?)
time -p dot -Tsvg -omyfile.svg myfile.gv -v - on Windows - less straight-forward, use python, gawk, or powershell (see https://stackoverflow.com/questions/673523/how-do-i-measure-execution-time-of-a-command-on-the-windows-command-line)