Skip to content

Instantly share code, notes, and snippets.

@ansemjo
Created May 3, 2022 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ansemjo/2d5555350d72f188cf34ed3a6bd0e1d9 to your computer and use it in GitHub Desktop.
Save ansemjo/2d5555350d72f188cf34ed3a6bd0e1d9 to your computer and use it in GitHub Desktop.
generate complete graphs where all nodes are connected with each other using graph-tool
#!/usr/bin/env -S docker run --rm -it -v "${PWD}:/host" -w /host tiagopeixoto/graph-tool python complete.py
# https://graph-tool.skewed.de/static/doc/generation.html#graph_tool.generation.complete_graph
# usage: $ ./complete.py 64 && convert -density 300 complete-64.{pdf,png}
from sys import argv
n = int(argv.pop())
print(f"Generate complete-{n} ...")
from graph_tool import generation, draw
gr = generation.complete_graph(n)
pos = draw.sfdp_layout(gr, cooling_step=0.95, epsilon=1e-2)
draw.graph_draw(gr, pos=pos, output=f"complete-{n}.pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment