Registry / data / retworkx

retworkx

JSON →
library0.17.1pypypi✓ verified 87d ago

A high-performance graph library for Python, written in Rust, providing directed and undirected graph data structures with efficient algorithms. Current version 0.17.1, release cadence irregular.

pip install retworkx
INSTALL
IMPORT
SIG · RETWORKX
R
retworkx
datapythonv0.17.1
Install
4.1s avg
Import
59ms
Disk
96MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.17.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.062s · 96.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.1s · import 0.056s · 92MB
96MB installed
● package 96MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PyGraph
import retworkx as rx; g = rx.PyGraph()
from retworkx import PyGraph
Direct import is fine, but idiomatic usage is `import retworkx as rx`
PyDiGraph
import retworkx as rx; g = rx.PyDiGraph()
from retworkx import PyDiGraph as DiGraph
Avoid aliasing to avoid confusion with other graph libraries

Create a directed acyclic graph, add nodes and edges, and print them.

import retworkx as rx dag = rx.PyDiGraph() node_a = dag.add_node('A') node_b = dag.add_child(node_a, 'B', None) print(dag.nodes()) print(dag.edges())
Debug
Known issues
breakingVersion 0.14.0 replaced the original function-based API with the class-based API (PyGraph, PyDiGraph). Code using `from retworkx import *` or older function names will break.
fix
Migrate to using PyGraph and PyDiGraph classes. See migration guide at https://qiskit.org/documentation/retworkx/
affects: <0.14.0
deprecatedThe `digraph` and `graph` constructor functions are deprecated and removed in 0.14.0.
fix
Replace `retworkx.digraph()` with `retworkx.PyDiGraph()` and similarly for undirected graphs.
affects: >=0.10.0, <0.14.0
gotchaNode indices are integers returned by add_node/add_child; do not rely on them being sequential or stable after deletions.
fix
Assign custom node data or use node indices immediately; do not assume order.
affects: all
gotchaEdge weights are optional but must be passed as the third argument to add_child; passing None is acceptable but can lead to type confusion.
fix
Always provide an explicit weight (or None) to avoid unexpected behavior.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'retworkx'
retworkx not installed or environment not activated
fix
Run `pip install retworkx` in the correct environment (Python >=3.9).
TypeError: add_child() missing 1 required positional argument: 'obj'
Missing the edge weight argument in add_child
fix
Provide a third argument, e.g., `dag.add_child(parent, child, None)`.
AttributeError: module 'retworkx' has no attribute 'digraph'
Using the deprecated function name from old versions (<0.14.0)
fix
Use `retworkx.PyDiGraph()` instead of `retworkx.digraph()`.
Upgrade
Version history
0.17.1latest on PyPI · released Sep 15, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
6
OpenAI (training)
1
Resources
retworkx — pip install retworkx · libregistry