FrankenNetworkX

Python graph libraryRust core0.4.1 on PyPI

NetworkX, rebuilt in Rust, tie-breaks and all.

FrankenNetworkX is a Rust port of NetworkX that you install from PyPI and switch on with one line. The NetworkX calls you already make run on native kernels and return what NetworkX returns: the same values in the same order, the same exceptions, the same error messages.

Star on GitHub

Run it on this graph

—ms in Rust, in this tab

Loading FrankenNetworkX…

Click or tap two nodes to route between them. Every answer comes from FrankenNetworkX's own Rust crates, compiled to a 358 KB WebAssembly module; the Python wheels are built from the same crates.

Switch

Turn it on with one line.

Install the wheel and tell NetworkX to prefer it. Calls FrankenNetworkX supports run in Rust, and everything else falls through to NetworkX unchanged. Nothing in your code has to know which library answered.

Two ways in

As a backend, or as the module itself.

As a backend, NetworkX's own dispatcher hands supported calls to FrankenNetworkX and converts the results back. Imported directly, it is a NetworkX-shaped module whose graphs are Rust from the start.

Backend protocol, in the guide

Pick how you want to switch.

Worked example
import networkx as nx

nx.config.backend_priority = ["franken_networkx"]

G = nx.read_edgelist("collaborations.txt")
nx.pagerank(G)            # runs in FrankenNetworkX
nx.connected_components(G)  # so does this

Nothing else in your code changes. NetworkX converts your graph once and keeps the copy in its cache, so repeated calls on the same graph skip the conversion.

Dispatch

What NetworkX does with each call.

NetworkX checks whether a backend implements a function before sending a call to it. 421 functions are registered in the 0.4.1 release (476 on main). The rest run in NetworkX exactly as before. These are NetworkX's own debug logs, recorded with networkx 3.6.1 and franken-networkx 0.4.1.

Pick a call and read what the dispatcher logged.

Recorded output

networkx DEBUG log

  1. asksCall to 'shortest_path' has inputs from {'networkx'} backends, and will try to use backends in the following order: ['franken_networkx', 'networkx']
  2. convertsConverting input graphs from 'networkx' backend to 'franken_networkx' backend for call to 'shortest_path'
  3. convertsCaching converted graph (from 'networkx' to 'franken_networkx' backend) in call to 'shortest_path' for 'G' argument
  4. Rust sideUsing backend 'franken_networkx' for call to 'shortest_path' with arguments: (G=Graph(nodes=2000, edges=5991), source=0, target=1999, weight='weight', method='dijkstra')

The first call converts the NetworkX graph and caches the copy on G. FrankenNetworkX answers.

To see this for your own code: logging.getLogger("networkx").setLevel(logging.DEBUG). Converting a NetworkX graph costs about 0.66 µs per edge, and NetworkX's cache pays it once per graph. With the cache off, cheap kernels lose to plain NetworkX; see where it's slower.

Same answers

NetworkX's answer, in NetworkX's order.

Many graph questions have more than one right answer, and NetworkX picks one by the order you built the graph in. Code downstream comes to depend on that pick. FrankenNetworkX makes the same pick, and treats iteration order, return types, exceptions and error text as part of the API.

Tie-breaks

Six equal routes. NetworkX's pick every time.

On a 3×3 grid every corner-to-corner route takes four steps. Which one Dijkstra returns depends on the order the edges went in, because NetworkX's heap pops equal distances first in, first out. Shuffle the order, and the Rust kernel running in this page returns the route NetworkX returned for that same order.

Shuffle the order the twelve edges are added in.

Interactive
············abcdefghi

Edge ordera–b first, then a–d, …

NetworkX 3.6.1recorded in CPython 3.13.9

—

FrankenNetworkXRust kernel, running here

—

Loading the engine…

A port that breaks ties by namefor contrast, computed in JavaScript

—

A port that iterates a hash mapfor contrast, a fresh hash seed each run

—

0 of 0 orders: FrankenNetworkX agrees

0 of 0: the by-name port agrees

0 of 0: the hash-map port agrees

NetworkX's answers come from 400 seeded shuffles run in CPython 3.13.9 with networkx 3.6.1 (web/tools/reference.py). Building this page re-runs all 400 through the engine and stops on any disagreement. Over those orders NetworkX itself returns each of the six routes.

Parity, live

16 answers, checked in your browser.

Zachary's karate club (34 people, 78 weighted friendships) is the graph NetworkX ships for examples. Each row runs one of FrankenNetworkX's Rust kernels here and compares its answer with the one NetworkX gave in CPython, in order wherever NetworkX's answer has one.

Run the battery and read each verdict.

Interactive

Each row builds the karate graph in Rust, runs one kernel and compares the answer with NetworkX's.

NetworkX callCompared onVerdictWhat came backKernel
shortest_path(G, "16", "25", weight="weight")Same path, node for nodewaiting——
single_source_dijkstra(G, "0")Same distances, in the order Dijkstra settles themwaiting——
bfs_edges(G, "0")Same tree edges, in the same orderwaiting——
bfs_layers(G, "0")Same layers, same order within eachwaiting——
connected_components(G)Same groups of nodeswaiting——
betweenness_centrality(G)Same scores, same node orderwaiting——
closeness_centrality(G)Same scores, same node orderwaiting——
clustering(G)Same coefficients, same node orderwaiting——
pagerank(G, weight=None)Same ranks to within the solver tolerancewaiting——
triangles(G)Same counts, same node orderwaiting——
core_number(G)Same cores, same node orderwaiting——
louvain_communities(G, seed=7)Same communities for the same seedwaiting——
minimum_spanning_tree(G)Same tree edges and total weightwaiting——
articulation_points(G)Same nodes, same orderwaiting——
bridges(G)Same edges, same orderwaiting——
max_weight_matching(G)Same pairswaiting——
PageRank is compared to within the solver's tolerance: both libraries iterate until the change falls below 10⁻⁶, so agreement to the last digit isn't promised (here it agrees to about 10⁻¹⁷). Sets are compared as sets where NetworkX returns sets. Times are for the kernel alone, in WebAssembly, in this tab.

The contract

Same types, same errors, same words.

Code that catches NetworkXNoPath and reads its message, or consumes a generator lazily, keeps working. These outputs were recorded from networkx 3.6.1 and franken-networkx 0.4.1 on Python 3.13.9, running the same lines with nx bound to each.

Pick a snippet and compare the two outputs.

Recorded output
G = nx.Graph([("a", "b")])
G.add_node("z")
nx.shortest_path(G, "a", "z")

import networkx as nx

NetworkXNoPath: No path between a and z.

import franken_networkx as nx

NetworkXNoPath: No path between a and z.

identicalSame exception class, same message. Code that catches NetworkXNoPath and reads str(e) keeps working.

The evidence

NetworkX's own tests, run against it.

The strictest check is the one NetworkX wrote for itself. Its suite runs with FrankenNetworkX as the backend on every quality run, held to a ratchet that fails the run on any new failure.

The audit ledgers
  • 6,815NetworkX's own tests pass

    NetworkX 3.6.1's test suite with FrankenNetworkX as the backend: 0 failures, 0 errors (2026-09-24). Plain NetworkX passes 6,816; with the backend, 80 tests are skipped instead of 78.

    ratchet_v1.json
  • 4,129 / 4,129public paths present

    Every import and signature in NetworkX 3.6.1's public surface exists with the same shape: 0 partial, 0 missing, 796 excluded with a stated reason. Drift fails the quality run.

    docs/coverage.md
  • 68,318parity tests passed

    Call-by-call comparisons with NetworkX across 1,101 test files, 0 failed (2026-09-24). They check values, iteration order, exception classes and message wording.

    run_python_parity_suite.py
  • 33fuzz targets

    Parsers and algorithm families under cargo-fuzz. Every quality run replays the saved corpora and fuzzes each target for 10 seconds (4.76 million executions on 2026-09-24, no failures).

    fuzz/fuzz_targets

Speed

Native kernels, timed against NetworkX.

In the project's gated benchmarks, graph kernels run 1.3× to 194× faster than NetworkX 3.6.1, and whole jobs from loading a file to writing results finish 1.1× to 2.2× sooner. Some single operations on the graph object are slower, and this chapter lists those too.

Kernels

Faster where the work is.

Each bar is NetworkX's time divided by FrankenNetworkX's for the same call on the same graph, after both outputs were checked to be identical. The scale is logarithmic. Workloads differ from row to row; the note on each bar says what was measured.

Performance, in the guide

Filter by family, then show the losses too.

Measured
  1. closeness_centrality194×Native multi-source BFS. n = 220, m = 900.
  2. k_core128×Native core filter. n = 50,000, m = 800,000.
  3. onion_layers123×Native peeling. n = 10,000, m = 640,000.
  4. rich_club_coefficient117×Native degree scan. n = 10,000, m = 40,000.
  5. transitive_closure92.3×Native descendant closure. Directed, n = 200, m = 800.
  6. clustering36.1×Native triangle counting, all nodes. n = 2,000, m = 8,000.
  7. node_connectivity30.2×Native max-flow. n = 220, m = 900.
  8. triadic_census20.5×Native census. Directed, n = 200, m = 800.
  9. square_clustering18.4×Native neighbour-pair scan. n = 10,000, m = 40,000.
  10. triangles14.3×Native triangle counting. n = 2,000, m = 8,000.
  11. k_crust13.3×Native core filter. Re-measured 2026-07-31.
  12. erdos_renyi_graph12.9–13.2×Native generator, n = 1,500. Re-measured 2026-07-31.
  13. dijkstra_path7.61×Weighted. Native bidirectional kernel with persistent dense node ids.
  14. single_source_shortest_path_length5.19×Native BFS, dict built in Rust. Re-measured 2026-07-31.
  15. kosaraju_strongly_connected_components4.85×Native SCC. Re-measured 2026-07-31.
  16. all_pairs_shortest_path_length4.56×n = 300. The algorithm dominates the cost.
  17. single_source_shortest_path3.90×Native BFS.
  18. all_pairs_dijkstra_path_length3.67×n = 300. The algorithm dominates the cost.
  19. subgraph(view) → edges3.52×Native induced-subgraph walk.
  20. faster_could_be_isomorphic3.50×Native degree and triangle sequence. n = 1,200, m = 6,000.
  21. dfs_tree3.34×Native traversal and result construction.
  22. single_source_dijkstra_path_length3.33×Native Dijkstra.
  23. single_pair_shortest_path3.33×Native BFS. Re-measured 2026-07-31.
  24. bfs_tree3.24×Native traversal and result construction.
  25. dfs_postorder_nodes3.08×Native traversal. n = 1,200, m = 6,000.
  26. pagerank2.64×Native CSR build, then SciPy runs the same power iteration nx.pagerank runs.
  27. to_scipy_sparse_array2.48×Native CSR assembly.
  28. partition_spanning_tree2.46×Native Kruskal with partition constraints.
  29. jaccard_coefficient2.45×Native neighbour-set intersection, 300 pairs.
  30. dfs_successors2.32×Native traversal.
  31. MultiDiGraph.degree[node]2.20×2,000 nodes, 512 lookups per sample. 95% CI 2.11–2.27×.
  32. label_propagation_communities2.18×Native label counting. n = 1,200, m = 6,000.
  33. minimum_spanning_tree1.99×Native Kruskal. n = 1,200, m = 6,000.
  34. to_dict_of_lists1.97×Native row walk.
  35. shortest_path1.83×Weighted. Native weighted-path kernel.
  36. bidirectional_dijkstra1.79×Native bidirectional kernel.
  37. all_pairs_shortest_path1.76×n = 300. Building the result dilutes the kernel's win.
  38. read_graph61.72×Native decoder. read_sparse6: 1.69×.
  39. edges(data=True)1.56×Re-measured 2026-07-31.
  40. MultiGraph.degree[node]1.47×2,000 nodes, 512 lookups per sample. 95% CI 1.44–1.53×.
  41. all_simple_edge_paths1.34×Native path enumeration.
  42. G.adj0.90×Descriptor access from Python. The README marks this figure stale, awaiting a fresh measurement.
  43. read_gml0.92×The GML parse path.
  44. louvain_communities, weighted0.92×Weighted input takes a slower route than the native kernel.
  45. n in G, absent key0.88×A miss pays a set probe, then the canonical key path.
  46. preferential_attachment0.86×Per-call boundary cost; NetworkX's work per pair is two degree lookups.
  47. read_multiline_adjlist0.80×The parser is not native.
  48. G.add_edge(u, v, weight=w)0.66–0.71×Each call converts its keyword dict into the native attribute map.
  49. G.has_node(n), absent key0.66×A miss falls through to rebuilding the canonical key.
  50. MultiGraph.get_edge_data(u, v)0.57–0.62×A registry lookup per call where NetworkX does two dict lookups.
  51. MultiGraph G[u][v]0.42–0.50×Stacked Python view layers per subscript.
  52. MultiDiGraph.remove_node0.32–0.51×A String-keyed store that frees about seven blocks per incident edge.
Source: the README's per-family table, measured 2026-07-25 to 2026-07-31 against live NetworkX 3.6.1 on Linux. Two kernels that measured well but still lack the host-wide exclusivity proof (k_corona at about 7.8×, minimum_branching at about 4.4×) are left off until they pass.

Whole jobs

File to result, 1.1× to 2.2× sooner.

Each of these five jobs loads a slice of a real co-authorship network (SNAP's Astro Physics collaboration graph), cleans it, analyses it and writes the result, so the ratio includes parsing, conversion and output as well as the kernels.

Read across a row to see how each job scales.

Measured
Job1,000 nodes13,410 edges5,000 nodes77,598 edges10,000 nodes143,680 edges
Collaboration cohesionload → components and cores → cohort subgraph → export1.49×33% less time1.32×24% less time1.20×17% less time
Hub routingload → hub rank → shortest paths and BFS tree → radius-2 subgraph → export1.55×35% less time1.19×16% less time1.22×18% less time
Rich-club analysisload → rich club and onion layers → leader subgraph → export2.18×54% less time1.86×46% less time1.84×46% less time
Link recommendationsload → core rank → Jaccard and preferential scores → export1.10×9% less timeno stable differencethe gate could not separate them1.24×19% less time
Community detectionload → label propagation → largest community → assignments and export1.65×40% less time1.36×27% less time1.43×30% less time
NetworkX's wall time over FrankenNetworkX's, 21 alternating rounds in one process, outputs byte-identical (2026-07-29). Reproduce with PYTHONHASHSEED=0 python3 scripts/perf_harness.py realistic-workloads.

Method

How a number gets on this page.

Every ratio in this chapter passed the same gate. The README keeps its retractions too: a figure that later failed a corrected harness stays on the page, marked withdrawn.

  1. 01
    One process, both libraries

    NetworkX 3.6.1 and FrankenNetworkX run in the same Python process, in alternating order, for 21 or more rounds.

  2. 02
    Outputs first

    Before anything is timed, the complete outputs of the two are compared byte for byte. A row whose outputs differ is not timed.

  3. 03
    A/A nulls

    Each library is also timed against itself. If either null drifts more than 2% from 1.0, the run is thrown out.

  4. 04
    Confidence, with margin

    The verdict comes from a bootstrap confidence interval on the median ratio, with a 2× margin in log space. A row that can't clear it is published as undecidable.

  5. 05
    A quiet machine

    Every CPU must stay under 20% busy before and during timing. A harness that can't prove that doesn't produce a number.

Where it's slower

Per-call costs it still pays.

A single operation on the graph object crosses from Python into Rust, and that crossing costs more than a Python dict lookup. Analytics win; tiny lookups in a tight loop can lose. These are the measured losses and their causes, each tracked as open work.

Know these before you benchmark a hot loop.

Measured
OperationFrankenNetworkX vs NetworkXWhy
G.adj0.90×Descriptor access from Python. The README marks this figure stale, awaiting a fresh measurement.
read_gml0.92×The GML parse path.
louvain_communities, weighted0.92×Weighted input takes a slower route than the native kernel.
n in G, absent key0.88×A miss pays a set probe, then the canonical key path.
preferential_attachment0.86×Per-call boundary cost; NetworkX's work per pair is two degree lookups.
read_multiline_adjlist0.80×The parser is not native.
G.add_edge(u, v, weight=w)0.66–0.71×Each call converts its keyword dict into the native attribute map.
G.has_node(n), absent key0.66×A miss falls through to rebuilding the canonical key.
MultiGraph.get_edge_data(u, v)0.57–0.62×A registry lookup per call where NetworkX does two dict lookups.
MultiGraph G[u][v]0.42–0.50×Stacked Python view layers per subscript.
MultiDiGraph.remove_node0.32–0.51×A String-keyed store that frees about seven blocks per incident edge.
Memory, attributed graphs3.4× NetworkX's RSSEdge attributes are stored twice, natively and as the Python dict you see. Unattributed graphs use 0.63× NetworkX's memory.
copy.copy(G), 10,000 nodes0.0031×FrankenNetworkX copies the structure where NetworkX's shallow copy aliases it.
Backend mode, conversion cache off0.026–0.40×Every call converts the NetworkX graph first. With NetworkX's default cache on, the same calls win 1.7–17×.
Graph.remove_node, 1,600 nodes0.52×A flat 2.5–3.5 µs per call. It wins 1.75× at 25,600 nodes, where NetworkX's removal grows.

Receipts

Every tie-break, on the record.

Twelve reference algorithms hash each tie-break decision they make into a Blake3 fingerprint, count their operations, and check that count against a closed-form bound. The same graph built in the same order gives the same fingerprint on any machine. A different fingerprint means the algorithm took a different path.

Witness, live

Run it twice. Same hash.

Pick an algorithm and a seeded random graph. The graph comes from FrankenNetworkX's own generator, which draws exactly the edges NetworkX draws for that seed. Run again and the fingerprint repeats. Shuffle the order the edges went in and it changes, because the algorithm met its ties in a different order.

CGSE, in the guide

Run it again, then shuffle the edge order.

Interactive

Algorithm

Graph

ComplexityWitness—

policy
—
dominant term
—
n, m
—
operations
—
bound —

decision_path_blake3—

    The bound is the registry's closed form for the algorithm's dominant term; the gate allows twice it for constant factors. A passing bound and a matching hash show the run was deterministic and within its complexity class. They don't prove the answer is right; the parity tests do that.

    The registry

    Twelve algorithms, each with a pinned policy.

    The policy names the rule each reference kernel uses when several choices are equally good. Dijkstra's is NetworkX's own: equal-distance entries pop in the order they were pushed, because NetworkX's heap carries a counter as its second key. The registry describes these twelve reference kernels; the README notes where a public sibling, such as Prim, orders its ties differently.

    Reference algorithmFamilyTie-break policyBound
    dijkstrashortest_pathweight_then_insertion_orderLightest first; equal weights in the order they were pushed, as NetworkX's heap counter does.O(n + m·log n)
    bellman_fordshortest_pathinsertion_orderNeighbours in the order the edges were added.O(n·m)
    bfstraversalinsertion_orderNeighbours in the order the edges were added.O(n + m)
    dfstraversalinsertion_orderNeighbours in the order the edges were added.O(n + m)
    max_weight_matchingmatchingweight_then_lexLightest first; equal weights by the smaller label.O(n·m·α(n, m))
    min_weight_matchingmatchingweight_then_lexLightest first; equal weights by the smaller label.O(n·m·α(n, m))
    connected_componentsconnectivitylex_minThe smallest label first.O(n + m)
    strongly_connected_componentsconnectivityinsertion_orderNeighbours in the order the edges were added.O(n + m)
    kruskaltreesweight_then_lexLightest first; equal weights by the smaller label.O(m·log m)
    primtreesweight_then_lexLightest first; equal weights by the smaller label.O(m·log n)
    eulerian_circuiteulerinsertion_orderNeighbours in the order the edges were added.O(m)
    topological_sortdaginsertion_orderNeighbours in the order the edges were added.O(n + m)

    Safety

    Bad input fails closed.

    Graphs often arrive from places you don't control. In strict mode FrankenNetworkX refuses malformed input and says exactly what was wrong. In hardened mode it repairs what it can within fixed limits and writes a decision record for every repair. Neither mode guesses silently.

    Two policies

    The same file, two answers.

    These are FrankenNetworkX's GraphML and GML readers, compiled to WebAssembly. Pick a damaged file, then switch modes. Edit the text to try your own.

    Security doctrine, in the guide

    Pick a damaged file, then switch modes.

    Interactive

    A file

    Mode

    Result

    Loading the reader…

    Decision records

      The decision rule

      Allow, validate or refuse, by expected loss.

      Graph operations are admitted by a small decision rule in fnx-runtime: given an estimated probability p that an operation is incompatible, take the action with the lowest expected loss. A plain add_edge enters at p = 0.08, a self-loop at 0.22. Hardened mode prices every mistake higher.

      Slide p and watch the cheapest action change.

      Interactive

      Lowest expected loss

      allow

      Allowing costs p × 100 = 8. Validating costs 25. Refusing costs (1 − p) × 60 = 55.2.

      The same arithmetic as RuntimePolicy::action_for in crates/fnx-runtime: strict prices a wrong allow at 100, validation at 25 and a wrong refusal at 60; hardened at 120, 30 and 70. An unknown incompatible feature, or a p that isn't a number, refuses outright.

      Hardening

      Built for input you didn't write.

      • No unsafe code

        #![forbid(unsafe_code)] in every crate of the workspace.

      • 33 fuzz targets

        Parsers and algorithm families under cargo-fuzz, with corpora replayed and 10 seconds of fresh fuzzing on every quality run. Treat the parsers as fuzz-exercised, not proven, and still set your own limits for a public service.

      • Typed attributes

        Values come in as a closed set of types. GraphML booleans accept only the forms the format allows, so 0/1 never turns into an integer downstream.

      • NaN and infinity

        Non-finite weights go down NetworkX-exact paths, in every mode, so NaN behaves as it does in NetworkX.

      • Bounded generators

        In hardened mode, generator sizes are clamped (100,000 nodes; 20,000 for G(n, p) models) with a warning naming the clamp. Strict mode builds every size NetworkX builds.

      • No unbounded recursion

        Traversal-heavy algorithms (DFS, planarity, transitive closure) avoid unbounded recursion, so a very long path can't overflow the stack.

      Inside

      Twelve crates, one contract.

      A call enters through a Python wrapper, crosses into Rust through PyO3 with the GIL released, runs on an insertion-ordered graph, and comes back as the Python type NetworkX would have returned.

      One call

      connected_components, down and back.

      Six steps from your call to a Python set, through two Python layers and two Rust crates. The GIL is released at 826 call sites in the bindings, so other Python threads keep running while a kernel works.

      Internals walkthrough

      Step through one call.

      Worked example
      1. fnx.connected_components(G), or nx.connected_components(G) with the backend switched on. In backend mode NetworkX first converts G (once, if its cache is on).

      2. It validates the arguments with NetworkX's exceptions and wording. A call shape the native path doesn't take, such as a user callable, goes to an exact NetworkX-compatible route instead.

      3. The binding borrows the Rust graph inside the Python object, so nothing is copied, and releases the GIL. Other Python threads keep running.

      4. It works on dense node indices taken from the insertion-ordered adjacency, so it meets nodes in NetworkX's order. Reference kernels record each tie-break into a witness.

      5. With the GIL back, each component goes out as a Python set straight from Rust, in the order Rust found it. No intermediate list.

      6. A generator stays a generator. For the 24 wrapper-patched functions listed in docs/raw_vs_public_audit.md, the wrapper fixes up ordering here.

      Storage

      Insertion order is the index.

      The adjacency is built so that matching NetworkX's iteration order costs nothing: nodes get slots in the order they arrive, and every neighbour row is appended in order.

      Memory model, in the guide
      pub struct Graph {
          node_order:  FxIndexMap<String, usize>,  // name → slot, in insertion order
          slot_names:  Vec<Option<String>>,        // slot → name; None once removed
          adj_indices: Vec<Vec<usize>>,            // slot → neighbour slots, in insertion order
          edges:       FxIndexMap<(usize, usize), AttrMap>,  // (min, max) slot pair → attributes
          // plus revision-keyed caches
      }
      • Insertion order is the index. Iteration follows the order you built the graph, which is how NetworkX's dicts behave, with no sorting step.
      • Adjacency and attributes live apart. Walking neighbours never touches attribute payloads; setting a weight never disturbs neighbour order.
      • Two tiers of attributes. Kernels read a typed native copy; your code reads real Python dicts, so G.edges[u, v] returns the objects you stored.
      • The memory cost, stated. Without attributes a graph takes 0.63× NetworkX's memory. With one attribute per edge it takes 3.4×, because attributes are stored twice. A single store is on the roadmap.

      Version 0.4.1, Python 3.10 and up

      Get started.

      Three lines from here to your existing code running on Rust kernels. If a result ever differs from NetworkX and the difference isn't documented, that's a bug: file it with a snippet that calls both.

      Read the guideStar on GitHub
      1. Step 1

        Install

        Prebuilt wheels for Linux (x86_64, aarch64, musl), macOS (Intel and Apple silicon) and Windows. No Rust toolchain.

        pip install franken-networkx
        # with SciPy, for pagerank
        pip install 'franken-networkx[all]'
      2. Step 2

        Switch on the backend

        Once, at startup. Supported calls go to Rust; the rest stay in NetworkX.

        import networkx as nx
        nx.config.backend_priority = ["franken_networkx"]
      3. Step 3

        Or import it directly

        No conversion on any call. The same names as NetworkX.

        import franken_networkx as fnx
        G = fnx.karate_club_graph()
        fnx.betweenness_centrality(G)

      Use it when

      • You have NetworkX code and per-call time dominates. Switch on the backend and leave the code alone.
      • You need the same output on every run and every machine: same input, same version, same answer.
      • Your pipeline is long-lived, and a change in iteration order would be a silent bug downstream.
      • You parse graphs from sources you don't trust and want a parser that refuses or records, never guesses.

      Skip it when

      • Your graphs are small (under about 10,000 nodes) and you run each analysis once. NetworkX is excellent there.
      • You need a GPU. Look at cuGraph.
      • You want a different model, such as igraph's integer vertex indices, and aren't tied to NetworkX's behaviour.
      • You're on Python older than 3.10, or need a graph database rather than in-memory graphs.