grandalf
Graph and drawing algorithms framework
What it is and what it does
Grandalf is a pure-Python graph layout library that solves the geometric problem of positioning nodes and routing edges for visualization. It implements two layout strategies: Sugiyama (hierarchical/dot-style) and force-driven (energy minimization), each designed to be simple enough to read and modify. The library does not handle rendering—it computes coordinates and edge paths, leaving the actual drawing to your choice of graphics toolkit (matplotlib, Qt, GTK, etc.).
The package is intentionally lightweight (about 1500 lines total, with individual algorithms under 600 lines) and trades speed for simplicity and hackability. It targets experimental work and small-to-medium graphs rather than production-scale visualization. With only pyparsing as a runtime dependency and no graphics toolkit requirement, it integrates easily into headless or custom rendering pipelines.
Use it for:
- Compute node positions for a hierarchical flowchart or organizational chart, then render with your preferred graphics library.
- Prototype a force-directed graph layout algorithm by modifying the energy minimization code directly.
- Generate graph coordinates in a headless environment (server, CLI tool) without requiring a display or graphics toolkit.
- Integrate graph layout into a custom visualization pipeline where you control rendering separately from layout.
- Experiment with graph drawing algorithms in a small, readable codebase without the overhead of heavyweight libraries.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Grandalf computes node coordinates and routes edges for graph layouts using Sugiyama hierarchical or force-driven algorithms, then leaves the actual drawing to your graphics toolkit of choice.
Yes, if you need graph layout coordinates for experimental or small-scale work and want to control rendering separately. The low install friction and copyleft license are straightforward. However, dormant maintenance (last release January 2023) means you should not expect bug fixes or updates; use it only if the current feature set meets your needs and you are comfortable maintaining a fork if required.
Install
grandalf on PyPI
pip
pip install grandalfuv
uv add grandalfpoetry
poetry add grandalfInstalling grandalf
Before you install
Low friction: pure Python with only pyparsing as a runtime dependency, distributed as a wheel. Dormant maintenance status—last release was 2023-01-10 and no commits since 2024-08-10—means bug fixes or feature updates are unlikely, though the codebase is small and stable.
License in practice
Dual-licensed under GPLv2 and EPLv1 (copyleft). Any derivative work or distribution must comply with copyleft terms; proprietary or closed-source projects may face licensing constraints.
Quickstart
pip install grandalf
from grandalf.graphs import Graph, Vertex, Edge
from grandalf.layouts import SugiyamaLayout
v1, v2 = Vertex('a'), Vertex('b')
g = Graph()
g.add_vertices(v1, v2)
g.add_edge(Edge(v1, v2))
layout = SugiyamaLayout(g)
layout.compute_layout()
print(v1.x, v1.y) # Node coordinates
Verify before relying
- Whether the package works reliably with modern Python versions (requires_python is unspecified in metadata).
- Performance characteristics for graphs approaching the 'thousands of nodes' upper bound mentioned in the description.
Package facts
| License | GPLv2 | EPLv1 (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pyparsing |
| Maintenance | dormant — 1,312 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,833,940/month — #2,870 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: grandalf-0.8-py3-none-any.whl
Keywords: graph, drawings, graphviz, networkx
Tags
More Graphics packages
Pillow adds image processing capabilities to…
permissive · top 100 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
matplotlib-inlineEnables matplotlib figures to display inline…
permissive · top 1,000 on PyPI
pymupdfPyMuPDF extracts, renders, converts, and…
agpl · top 1,000 on PyPI
pypdfium2pypdfium2 is a Python binding to PDFium that…
permissive · top 1,000 on PyPI
altairAltair is a declarative Python library for…
permissive · top 1,000 on PyPI
streamlit-agraphRenders interactive network graphs in Streamlit…
unclear · top 15,000 on PyPI
planarityTests whether a graph is planar, computes…
permissive · top 15,000 on PyPI
pygraphvizPyGraphviz provides a Python interface to…
permissive · top 5,000 on PyPI
graphframesGraphFrames provides distributed graph…
permissive · top 5,000 on PyPI
graspologicGraspologic provides graph statistical…
permissive · top 15,000 on PyPI
asciidagRenders directed acyclic graphs as ASCII art in…
copyleft · top 15,000 on PyPI
graphvizGenerates DOT language source code for graph…
permissive · top 1,000 on PyPI
altgraphaltgraph constructs and analyzes graphs…
permissive · top 5,000 on PyPI
GvGenGvGen generates Graphviz dot files…
permissive · top 15,000 on PyPI
squarifyComputes treemap layout rectangles from a list…
permissive · top 15,000 on PyPI