Skip to content

graph-layout

A collection of graph layout algorithms in Python: force-directed, constraint-based, hierarchical, circular, spectral, orthogonal, and planar straight-line drawings, with SVG, DOT, and GraphML export.

Install

pip install graph-layout

The ILP-based compaction path needs SciPy:

pip install "graph-layout[ilp]"

Quick start

Every layout takes nodes, links, and a canvas size, runs with .run(), and exports with .to_svg().

layout = CircularLayout(
    nodes=[{"index": i} for i in range(10)],
    links=[{"source": i, "target": (i + 1) % 10} for i in range(10)],
    size=(320, 320),
).run()
0 1 2 3 4 5 6 7 8 9
Circular layout of a 10-cycle

The figure above is not a checked-in image. It was produced by running the code beside it during the documentation build, so it cannot drift from the API. See Embedding Visualizations for how to write one.

Where to go next

Page Contents
Gallery One live figure per algorithm family
Algorithms What each algorithm does and when to use it
Preprocessing Graph cleanup before layout
Embedding Visualizations Authoring live figures in these docs

The README covers the full API, metrics, and the constraint system.