A tidy-like API for network manipulation with the igraph library inspired by:
The main purpose of using this library on top of python-igraph is to support relational data manipulation.
tg = Tidygraph.from_dataframe(...)
tg.activate(ActiveType.EDGES).join(..., how="outer").mutate({"rank": lambda x: 1.0 - x["score"]})Important
This library is experimental, and updates may be infrequent. Use at your own risk.
This package is available on PyPI.
You can install plot backends (cairo, matplotlib, or plotly) using the extras option.
# Base
pip install tidygraph
uv add tidygraph
# With plot support
pip install "tidygraph[cairo]"
uv add tidygraph --optional cairoThe easiest way to get started with development is through nix and related ecosystem tools.
I recommend installing nix using either options:
Note
The nix installer provided by the official nix team (since writing, 2026-01-16) is experimental. As a general rule of thumb, choose to install from Determinate Nix if you prefer the additional functionalities provided by the Determinate Nix team, otherwise, use the experimental installer for upstream.
Additionally, you will need direnv and nix-direnv.
Most (if not all) nix development workflows use direnv to auto-load the nix shell environment.
The main editor of choice is VSCode. Recommended extensions are included in the workspace file.
The environment should just work if everything is setup correctly!
Unfortunately VSCode does not have a programmatic way to set which python interpreter to use. Because the python environment is managed by nix, and nix installs/builds packages in a non-standard location, VSCode cannot auto-detect where your packages are.
You will need to update the python interpreter path whenever your nix shell environment updates.
The easiest way to do this is the following:
# print the python interpreter you are currently tracking
which pythonThe path should look something like /nix/store/XXXXXXXXXXXXXXXXXX-venv/bin/python. This is the python virtual environment generated by pyproject-nix and uv2nix.
Update the interpreter path in VSCode's python language settings.
Tip
You can find the modal quickly using the command palette and searching Python: Select Interpreter.
No. Tidygraph is built on top of igraph, which the core C library is inherently not thread-safe.
See official response for details.
This library would not have been possible without existing work from dedicated teams:
- Consider adding more verbs available in R
tidygraph - Cleanup test code