Skip to content

Instantly share code, notes, and snippets.

@unixod
Last active April 23, 2019 06:21
Show Gist options
  • Save unixod/e932a181c1125921fa638f702376c295 to your computer and use it in GitHub Desktop.
Save unixod/e932a181c1125921fa638f702376c295 to your computer and use it in GitHub Desktop.
Graphviz tips

Visualize a large graph

$ cat graph.gv | sfdp -Goverlap=prism -Goverlap_scaling=-10 -Tsvg -o out.svg

Consider the using together with cluster:

$ cat graph.gv | cluster | sfdp -Goverlap=prism -Goverlap_scaling=-10 -Tsvg -o out.svg

Reference: http://www.kellyrob99.com/blog/2012/05/27/github-social-graphs-with-groovy-and-graphviz/

Combine several graphs into a single layout

$ dot a.gv b.gv | gvpack | dot -Tx11

Print graph statistics (like wc for text streams)

$ gc a.gv

Calculate advanced statistics using gvpr

# This part of example is taken from:
# https://stackoverflow.com/questions/28079686/graphviz-given-a-dot-file-how-to-compute-node-statistics

$ gvpr 'N {printf("Node %s - indegree %d, outdegree %d\n", $.name, $.indegree, $.outdegree);}' a.gv

Convert large svg to png

inkscape --export-png=large_graph.png -w 10000 large_graph.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment