nx-rustworkx
A NetworkX 3.x backend that accelerates selected graph algorithms with rustworkx.
Keep import networkx as nx. nx-rustworkx converts an nx.Graph, runs the
rustworkx kernel, and remaps the result to the original node IDs. Unsupported
calls stay on NetworkX.
How much faster?
Real NetworkX projects with the backend switched on, application code
unchanged — measured by the runners in
benches/external/ on one 4-CPU machine:
| workload | NetworkX | nx-rustworkx | speedup |
|---|---|---|---|
| City street network (OSMnx MultiDiGraph), weighted closeness centrality | 358 s | 2.6 s | 136× |
| Same network, betweenness centrality | 115 s | 1.5 s | 78× |
| Same network, 200 point-to-point travel-time routes | 8.0 s | 2.3 s | 3.4× |
| nx-parallel's benchmark suite, all-pairs Bellman–Ford lengths (n=400) | 18.7 s | 0.44 s | 42× |
| NetworkX's own benchmark suite, strongly connected components (n=10,000) | 32 ms | 4 ms | 8× |
Good fit: CPU-heavy whole-graph algorithms on graphs from a few hundred nodes up — centralities, all-pairs shortest paths, components, isomorphism — and repeat-call pipelines, where the one-time conversion is cached across calls. Street networks work as-is: MultiDiGraphs with parallel ways dispatch with NetworkX's parallel-edge semantics.
Not the tool: tiny graphs (auto-dispatch declines below 200 nodes or 400
edges on purpose), one-off calls to linear-time functions where conversion
costs more than NetworkX's answer, algorithms NetworkX already runs on
C-backed SciPy (pagerank), custom weight callables, and code that walks
G.adj itself instead of calling nx.* functions — a backend can only
accelerate the NetworkX API.
Install
pip install nx-rustworkx
Requires Python 3.10+, NetworkX 3.4+, and rustworkx 0.18+.
Use
Set rustworkx as a preferred backend:
NETWORKX_BACKEND_PRIORITY=rustworkx python your_script.py
Or configure it in Python:
import networkx as nx
G = nx.erdos_renyi_graph(2_000, 0.01, seed=1)
nx.config.backend_priority = ["rustworkx"]
scores = nx.betweenness_centrality(G)
The backend implements 111 algorithms. Its measured cutoffs keep small or
conversion-heavy calls on NetworkX; backend="rustworkx" explicitly tries the
rustworkx implementation.
Generators such as nx.path_graph and nx.gnp_random_graph can construct
rustworkx-backed graphs directly, so whole pipelines skip conversion; the
usage guide covers enabling
generator dispatch.
Documentation
Usage, configuration, supported algorithms, caveats, and benchmarks: ville.dev/nx-rustworkx
Limits
MultiGraphandMultiDiGraphdispatch with NetworkX's parallel-edge semantics (minimum weight for paths, summed weights for PageRank, collapsed bundles for betweenness and bridges, keyed results for spanning trees). The 14 functions NetworkX itself refuses on multigraphs, pluscomplement, the graph products andvf2pp_all_isomorphisms, fall back to NetworkX; so do the native generators whencreate_usingis a multigraph class.- No custom weight callables.
- The rustworkx-backed graph object does not implement drawing or I/O.
- Some valid results may differ in ordering or floating-point rounding.
- Seeded random generators reproduce NetworkX's graphs unless
native_seeded_generatorsis enabled; the opt-in draws from rustworkx's RNG, so the same seed gives a different, equally valid graph.
The algorithm reference lists the exact behavior and fallback conditions.
Development
uv sync --extra test
uv run pytest tests
See the development guide for the full test, lint, benchmark, and architecture notes.
License
BSD-3-Clause.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nx_rustworkx-0.2.1.tar.gz.
File metadata
- Download URL: nx_rustworkx-0.2.1.tar.gz
- Upload date:
- Size: 92.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a02b2c32d6f25ec4345e7040a34602057704cf1fde49eaa4ce1ff23556d93a11
|
|
| MD5 |
cae6a39144ee8b22e7505a4d6ede994a
|
|
| BLAKE2b-256 |
3a20230fcf685356d7aaec82e8a390aba6f9d3e316d095f48d5344e3881719f6
|
Provenance
The following attestation bundles were made for nx_rustworkx-0.2.1.tar.gz:
Publisher:
publish.yml on thevilledev/nx-rustworkx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nx_rustworkx-0.2.1.tar.gz -
Subject digest:
a02b2c32d6f25ec4345e7040a34602057704cf1fde49eaa4ce1ff23556d93a11 - Sigstore transparency entry: 2581515854
- Sigstore integration time:
-
Permalink:
thevilledev/nx-rustworkx@b8ee049870397a8ff2f7e94d97b7f61a9bbf38ec -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/thevilledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8ee049870397a8ff2f7e94d97b7f61a9bbf38ec -
Trigger Event:
push
-
Statement type:
File details
Details for the file nx_rustworkx-0.2.1-py3-none-any.whl.
File metadata
- Download URL: nx_rustworkx-0.2.1-py3-none-any.whl
- Upload date:
- Size: 68.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0b39e260b5474bf3694e0d6d7433c80eb59435e87ed7e02c5df1acefe421547
|
|
| MD5 |
902aa552e0a429551934c9fe2a5de41d
|
|
| BLAKE2b-256 |
6c99a82e965200e2690462125acfc858843614ee9d0c447d3303129aa8501d15
|
Provenance
The following attestation bundles were made for nx_rustworkx-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on thevilledev/nx-rustworkx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nx_rustworkx-0.2.1-py3-none-any.whl -
Subject digest:
c0b39e260b5474bf3694e0d6d7433c80eb59435e87ed7e02c5df1acefe421547 - Sigstore transparency entry: 2581515875
- Sigstore integration time:
-
Permalink:
thevilledev/nx-rustworkx@b8ee049870397a8ff2f7e94d97b7f61a9bbf38ec -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/thevilledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8ee049870397a8ff2f7e94d97b7f61a9bbf38ec -
Trigger Event:
push
-
Statement type: