NetworkX graph a b c d e your node IDs dispatch remap rustworkx kernel 0 1 2 3 4 integer indices NetworkX graph a b c d e your node IDs dispatch remap rustworkx kernel 0 1 2 3 4 integer indices

nx-rustworkx

A NetworkX 3.x backend that runs selected graph algorithms through rustworkx. Keep import networkx as nx, keep your original node IDs, and let NetworkX dispatch the work.

Real projects, application code unchanged
Workload NetworkX nx-rustworkx Speedup
City street network (OSMnx MultiDiGraph), weighted closeness centrality358 s2.6 s136×
Same network, betweenness centrality115 s1.5 s78×
Same network, 200 point-to-point travel-time routes8.0 s2.3 s3.4×

Best for CPU-heavy whole-graph algorithms on graphs from a few hundred nodes up; deliberately not for tiny graphs or one-off linear-time calls, which stay on NetworkX. Method and full numbers: benchmarks.

Beta. Graphs, digraphs, multigraphs and directed multigraphs dispatch; the graph objects do not support drawing or I/O.

Current state
Release0.2.1
Python3.10 or newer
NetworkX3.4 or newer
Supported algorithms111
LicenseBSD-3-Clause

Quick start

pip install nx-rustworkx

Set rustworkx as a preferred backend:

NETWORKX_BACKEND_PRIORITY=rustworkx python your_script.py

Or configure it after importing NetworkX:

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)

NetworkX sees a normal nx.Graph. For large enough supported calls, nx-rustworkx converts it, runs the rustworkx kernel, and remaps the answer. Small or unsupported calls remain on NetworkX.

Choose a mode

Automatic dispatch
Best default. NetworkX asks the backend whether each call is worth running.
Explicit backend
Use backend="rustworkx" on one call to try the kernel directly.
Native backend graph
Build a RustworkxGraph once when repeated conversion is the bottleneck.

Continue with usage and configuration, or see the full algorithm list and caveats.