FrankenNetworkX

Guide/Evidence

Performance

19 min readFrom the README

On this page 3
Running your own benchmarkHot-path design notesCost model: when fnx wins, by how much, and why

The performance doctrine in AGENTS.md is profile-first:

  1. Baseline: record p50/p95/p99 and memory.
  2. Profile: identify real hotspots.
  3. Implement one optimization lever.
  4. Prove behavior unchanged via conformance + invariant checks.
  5. Re-baseline and emit delta artifact.

Hot paths that have already landed through this loop:

  • Native-Rust nonfinite-weight scan for the Dijkstra / A* / PageRank +∞ gate.
  • Index-based BFS + direct PySet emission for connected_components.
  • Adjacency built from G.neighbors rather than G[u] for find_cliques.
  • square_clustering bypasses AtlasView via CachedNeighborSets.
  • core_number uses an O(|V|) self-loop guard rather than walking O(|E|) edges.
  • greedy_color default routes through Rust matching NetworkX's largest_first tie-breaking.
  • complement single-pass edge insertion via extend_edges_unrecorded / complement_edges.
  • GIL released at hundreds of py.allow_threads(...) sites in crates/fnx-python/src/algorithms.rs.
  • Sparse HashMap / HashSet adjacency replacing former O(n²) dense matrices in algorithm internals.

See docs/performance.md for guidance on benchmarking, and examples/benchmark_comparison.py for a runnable local A/B against NetworkX.

Running your own benchmark

import time, statistics, networkx as nx, franken_networkx as fnx

G_nx  = nx.barabasi_albert_graph(50_000, 5, seed=7)
G_fnx = fnx.barabasi_albert_graph(50_000, 5, seed=7)

def time_it(fn, *a, **kw):
    samples = []
    for _ in range(5):
        t0 = time.perf_counter()
        fn(*a, **kw)
        samples.append(time.perf_counter() - t0)
    return statistics.median(samples)

print("nx  pagerank:", time_it(nx.pagerank, G_nx))
print("fnx pagerank:", time_it(fnx.pagerank, G_fnx))

print("nx  cc:",       time_it(lambda g: list(nx.connected_components(g)),  G_nx))
print("fnx cc:",       time_it(lambda g: list(fnx.connected_components(g)), G_fnx))

The same script works in backend mode: leave nx.config.backend_priority = ["franken_networkx"] set and call only nx.*.

Hot-path design notes

  • Index-based working sets. Algorithm interiors operate on dense Vec<usize> node indices rather than chasing IndexMap lookups in tight loops. The index↔label map is built once at the start of a call via graph.nodes_ordered() + graph.get_node_index(name).
  • Byte-array visited tracking. BFS / DFS / SCC / matching kernels use a vec![false; n] byte array (≈45 sites), not HashSet<NodeId>, for visited tracking. One contiguous allocation per call, cache-friendly inner loops.
  • Min-heap without Reverse allocation. Dijkstra-family algorithms use a custom DijkstraState { dist: f64, seq: u64, node } struct whose Ord impl reverses the dist comparison; the standard BinaryHeap acts as a min-heap with no per-push Reverse(_) wrapper.
  • FIFO tie-break in the comparator. The seq insertion counter is the secondary key in DijkstraState's Ord impl, so equal-distance entries pop in the order they were pushed (matching NetworkX's heapq-with-counter behavior bit-exactly). No post-pass needed.
  • Borrowed PyO3 returns. connected_components emits a PySet per component directly from Rust instead of building a Vec first and converting in a second pass, which saves one full pass over the result.

Cost model: when fnx wins, by how much, and why

The cost of a fnx.algorithm(G) call decomposes into four chunks:

Chunk Typical scale Notes
Python → Rust marshaling ~5–50 μs base + O(n + m) for graph conversion when a new graph is constructed Reusing an existing fnx graph: ~5 μs total per call (attribute lookup only). Constructing a fresh fnx graph from an nx graph at call time: O(n + m) plus a constant ~5 μs/node, ~3 μs/edge for dict→IndexMap conversion.
Native algorithm execution algorithm-dependent Performance varies by family and workload; see the dated per-family incumbent comparison and the loss table below for current ratios.
Rust → Python return marshaling O(output size) A PyDict::set_item per entry plus an arc-bumped node label string. Measured 2026-07-25: ~452 ns per edges(data=True) entry and ~27 ns per nodes(data=True) / adjacency() entry. NetworkX pays more per entry on the same shapes (758 ns/edge; 1690 ns/node for to_dict_of_lists), because it builds the same containers in interpreted code.
Wrapper-side post-processing (if any) O(output size) Wrapper-patched functions (enumerated in raw_vs_public_audit.md) add a single pass over the output for iteration-order normalization. Skipped for exports without a patch.

Real-world end-to-end performance — current 2026-07-29 gate. Five whole jobs start by loading and cleaning deterministic induced prefixes of the SNAP Astro Physics collaboration graph, run multiple analysis and subgraph stages, and finish by serializing the result. The inputs contain 1,000 / 13,410, 5,000 / 77,598, and 10,000 / 143,680 nodes/edges. NetworkX 3.6.1 and FNX run in one pinned invocation for 21 alternating-order rounds, with exact complete-output bytes, loaded-ELF identity, and separate NetworkX/NetworkX and FNX/FNX nulls. Ratios are NetworkX wall time divided by FNX wall time; values above 1 favor FNX. Reproduce with PYTHONHASHSEED=0 python3 scripts/perf_harness.py realistic-workloads.

Whole job n=1,000 n=5,000 n=10,000 What it means for a user
Collaboration cohesion: load → components/core → cohort subgraph → export 1.4898× 1.3232× 1.2039× FNX finishes this analysis/export pipeline sooner at all three sizes.
Hub routing: load → hub rank → SSSP/BFS tree → radius-2 subgraph → export 1.5457× 1.1885× 1.2159× FNX finishes this routing and two-graph export pipeline sooner at all three sizes.
Rich-club analysis: load → rich-club/onion layers → leader subgraph → export 2.1765× 1.8585× 1.8392× FNX roughly halves the wall time of this compute-heavy pipeline.
Link recommendations: load → core rank → Jaccard/preferential scores → export 1.0973× undecidable 1.2422× FNX wins at 1,000 and 10,000 nodes; the 5,000-node gate has no stable separation.
Community detection: load → label propagation → largest-community subgraph → assignments/export 1.6538× 1.3622× 1.4318× FNX completes community detection and result export sooner at all three sizes.

Per-family performance — current exact incumbent gates. The 2026-07-25 baseline uses an n=2000 / m=8000 random graph and is reproduced with python3 scripts/perf_harness.py marshaling. Rows whose notes carry another size are from the pure-Python-loop gates and are reproduced with python3 scripts/perf_harness.py class1-frontier. The n=50,000 rows use FNX_CLASS1_SIZES=10000,25000,50000, FNX_CLASS1_EDGE_MULTIPLIERS=16, and FNX_CLASS1_FRONTIER_JOBS=onion_layers,k_core; the average-degree-128 onion_layers row uses FNX_CLASS1_SIZES=1000,5000,10000, FNX_CLASS1_EDGE_MULTIPLIERS=64, and FNX_CLASS1_FRONTIER_JOBS=onion_layers. All gates run genuine unpatched NetworkX 3.6.1 in the same invocation, prove exact complete-output bytes before timing, record an adjacent A/A null, and decide only on the complete bootstrap median CI with a 2× log-space margin. The harness also fails closed unless every CPU in the effective host cpuset stays at or below 20% busy for five consecutive one-second pre-setup windows and five consecutive immediate pre-measurement windows, then continuously accounts for every non-affinity CPU in 300 ms windows throughout timing and rejects sustained two-window contention; a narrow taskset affinity cannot hide co-tenancy elsewhere on the host.

Family fnx vs nx Notes
closeness_centrality 194.3093× faster Native multi-source BFS; n=220 / m=900
rich_club_coefficient 117.3619× faster Native degree scan; n=10,000 / m=40,000
transitive_closure 92.3164× faster Native descendant closure; directed n=200 / m=800
k_core 127.6491× faster Native core filter; n=50,000 / m=800,000
clustering (all nodes) 36.1146× faster Native triangle counting
node_connectivity 30.1588× faster Native max-flow; n=220 / m=900
triadic_census 20.4715× faster Native census; directed n=200 / m=800
square_clustering 18.4067× faster Native neighbour-pair scan; n=10,000 / m=40,000
triangles 14.3397× faster Native triangle counting
onion_layers 122.7680× faster Native peeling; n=10,000 / m=640,000
faster_could_be_isomorphic 3.4961× faster Native degree/triangle sequence; n=1,200 / m=6,000
dfs_postorder_nodes 3.0811× faster Native traversal; n=1,200 / m=6,000
jaccard_coefficient 2.4536× faster Native neighbour-set intersection; 300 pairs
label_propagation_communities 2.1827× faster Native label counting; n=1,200 / m=6,000; re-measured 2026-07-31 vs live nx 3.6.1 (was 2.1485×)
minimum_spanning_tree 1.9947× faster Native Kruskal; n=1,200 / m=6,000
erdos_renyi_graph (n=1500) 12.87–13.15× faster Native generator; re-measured 2026-07-31 vs live nx 3.6.1 (was 14.1755×, not reproducible)
k_corona no current admissible ratio Complete-result incumbent gate awaiting an exclusive host window. Measured 8× on HEAD 2026-08-04 (br-r37-c1-p80x1.4) through the harness's own fixture, timing primitives and three-clause gate: 8 of 8 runs decidable at 7.7500–7.8425× (median 7.8154×, 1.2% spread), worst A/A null bias 0.0035 against a 0.0200 ceiling, complete-result parity 292 bytes SHA-256 1be0290d…. The nulls are clean, so the row is not measurement-limited — it is waiting only on the host-wide exclusivity proof, which a shared checkout cannot produce.
k_crust 13.2556× faster Native core filter; re-measured 2026-07-31 vs live nx 3.6.1 (was 5.8664×, understated)
kosaraju_strongly_connected_components 4.8474× faster Native SCC; re-measured 2026-07-31 vs live nx 3.6.1 (was 4.6519×)
minimum_branching no current admissible ratio Native branching; the 2026-07-31 re-measure gave 3.9978× but was vetoed by A/A null bias 0.0295 > 0.0200. Re-run 8× on HEAD 2026-08-04 (br-r37-c1-p80x1.14) against the same preregistered fixture, with input and complete-output SHA-256 both matching: the effect is stable at 4.2831–4.4494× (median 4.4119×, 3.9% spread) and 6 of 8 runs clear all three clauses. The 2 vetoes were clause 3 only, once from each arm's null — a single-draw null flake, not a property of the workload. Still not converted: those runs could not carry the host-wide exclusivity proof.
partition_spanning_tree 2.4612× faster Native Kruskal with partition constraints; CONFIRMED 2026-07-31 vs live nx 3.6.1 (measured 2.3794×, CI [2.3303, 2.5633] contains the published figure)
dfs_successors 2.3223× faster Native traversal; re-measured 2026-07-31 vs live nx 3.6.1 (was 2.1456×)
read_graph6 / read_sparse6 1.72× / 1.69× faster Native decoders; CONFIRMED 2026-07-31 vs live nx 3.6.1 (measured 1.7202× / 1.7069×, both CIs contain the published figures)
all_simple_edge_paths 1.3384× faster Native path enumeration; re-measured 2026-07-31 vs live nx 3.6.1 (was 1.3466×)
dijkstra_path (weighted) 7.6077× faster Native bidirectional kernel + persistent dense node ids
single_source_shortest_path_length 5.1868× faster Native BFS, dict returned from Rust; re-measured 2026-07-31 vs live nx 3.6.1 (was 5.5005×, overstated)
all_pairs_shortest_path_length (n=300) 4.5647× faster Algorithmic work dominates
single_source_shortest_path 3.8952× faster Native BFS
all_pairs_dijkstra_path_length (n=300) 3.6658× faster Algorithmic work dominates
subgraph(view) → edges 3.5212× faster Native induced-subgraph walk; re-measured 2026-07-31 vs live nx 3.6.1 (was 3.5719×)
dfs_tree 3.3439× faster Native traversal + native result construction
single_source_dijkstra_path_length 3.3325× faster Native Dijkstra
bfs_tree 3.2403× faster Native traversal + native result construction
single_pair_shortest_path 3.3313× faster Native BFS; re-measured 2026-07-31 vs live nx 3.6.1 (was 3.1614×)
pagerank 2.6361× faster Native CSR build + SciPy power iteration (the same iteration as nx.pagerank); CONFIRMED 2026-07-31 vs live nx 3.6.1 (measured 2.7275×, CI [2.5777, 2.8818] contains the published figure)
to_scipy_sparse_array 2.4758× faster Native CSR assembly; re-measured 2026-07-31 vs live nx 3.6.1 (was 2.4073×)
to_dict_of_lists 1.9662× faster Native row walk
bidirectional_dijkstra 1.7916× faster Native bidirectional kernel; re-measured 2026-07-31 vs live nx 3.6.1 (was 1.8125×)
shortest_path (weighted) 1.8343× faster Native weighted-path kernel; re-measured 2026-07-31 vs live nx 3.6.1 (was 1.7684×)
all_pairs_shortest_path (n=300) 1.7624× faster Result construction dilutes the kernel win
edges(data=True) 1.5555× faster re-measured 2026-07-31 vs live nx 3.6.1 (was 1.6085×)

Scalar multigraph degree access — measured 2026-07-27 (2,000 nodes / 1,999 path-shaped edges, 512 exact-string lookups per sample, genuine unpatched NetworkX 3.6.1 side-by-side in the same invocation, with an A/A null control and bootstrap median-CI gate; reproduce with FNX_PERF_ROUNDS=61 python3 scripts/perf_harness.py multigraph-degree-scalar):

Surface fnx vs nx Bootstrap 95% CI
MultiGraph.degree[node] 1.47× faster 1.4389–1.5295×
MultiDiGraph.degree[node] 2.20× faster 2.1125–2.2690×

Known remaining measured losses:

Where a row ran is part of the row. From 2026-08-15 every figure added here names the HARNESS that produced it and the machine both arms ran on, because neither is recoverable afterwards and both move ratios: two separately sanctioned harnesses read one primitive ~2x apart on the same build with both A/A nulls passing (br-r37-c1-y4r63), and elsewhere in the fleet worker identity alone moved a ratio 13.6x, also with passing nulls. A passing null certifies stationarity within one run; it does not certify that two runs are comparable. Rows below that predate this convention do not name their harness — that is a gap in those rows, not a verdict on them.

Surface fnx vs nx Cause
G.adj (bare accessor) 0.9009× Public descriptor access; re-measured 2026-08-04 vs live nx 3.6.1 (was 0.82×). 6/6 runs decidable, 0.8962–0.9079× (1.3% spread), A/A nulls within 0.0035 of 1.0, result parity 7,446,000 bytes. Reproduce with PYTHONHASHSEED=0 taskset -c 40-43 python3 scripts/perf_harness.py adj-descriptor. Figure status: stale — every lever bead (pc4hk, dyuzb, a5xrj, s3ctn, bmrbc/nic2n) closed and ey6ob refuted the descriptor-rebuild reading; the row awaits an admissible re-measure to convert or retire. Open.
len(G.adj) 1.65–1.71× Was a loss at 0.7901× (2026-08-04) and is now a win. G.adj returns a subclass of the native adjacency view, so __len__ resolves to a C slot instead of a Python frame — G.nodes and G.edges already did, on the same graph returning the same count (br-r37-c1-5gam7, landed 2026-08-08 f9e3173c3). Re-measured 2026-08-08 vs live nx 3.6.1 in the same invocation: 1.6548× CI 1.6447–1.6641×, dual A/A nulls 1.0004 and 1.0047, direction unanimous 4/4 (1.6021/1.6670/1.6625/1.6548). The identical script on the pre-change build read 0.7624–0.7892×, so this is measured against its own before. Re-confirmed 2026-08-08 at 1.7097× CI 1.7055–1.7135× (nulls within 0.0003 of 1.0); the range spans both admitted runs. Reproduce: balanced [A B B A A B B A] square, N=2000, 500 len() calls per timed unit, 25 rounds, taskset-pinned.
G.has_node(n) not decidable (present keys) The 1.23× win published here earlier on 2026-08-15 is RETRACTED (br-r37-c1-7x25w). It was measured on a harness that ran gc.collect() before every timed slot; re-measured on the corrected harness at a rep count where the nulls pass, three draws read 1.0008× (straddles 1.0), 1.0159× and 0.9799× — parity in both directions, so no verdict is claimed. The per-slot collect was worth only ~1% on THIS row (1.0811× corrected vs 1.0925× in defect mode at reps=400), and the ELF also moved under other agents' Rust landings, so the cause of the difference is unattributed rather than assigned. The LEVER is unaffected: the memo still removes the canonical rebuild that is 77.4% of this call's instructions, and its parity tests stand. What was a loss before that lever (0.7595×, 2026-08-08) is now parity. ABSENT keys remain a loss at 0.6610×. Earlier context, all superseded: 0.5199×, 0.4596×, 0.41×. Keys already proven present are remembered in a set, so a repeat probe reuses the hash CPython cached in the string object instead of rebuilding and rehashing a canonical "str:{len}:{s}" — 77.4% of this call's instructions, by toggle-collect profile. Measured vs live nx 3.6.1 in the same invocation, balanced [A B B A A B B A] square, 61 rounds: 1.2297× CI 1.2048–1.2574×, A/A nulls 1.0107/1.0037, ELF 1cfe8f2483a780e7. Prior published figures were correct for their builds: 0.7595× (2026-08-08), 0.5199×, 0.4596×, 0.41×. ABSENT keys are a loss and got slightly worse: 0.6610×, because a miss pays the set probe and then the canonical path anyway (bounded at ~1.19× of the un-memoised cost, measured). Reproduce: scripts/balanced_square_ab.py --workload view-reads --only "G.has_node". Two independently written harnesses agree on this row — 1.2205× CI 1.1861–1.2318× from the view sweep and 1.2297× from balanced_square_ab.py, overlapping CIs on the same ELF. harness=balanced_square_ab.py + ab_view_sweep2.py, same_host=thinkstation1, rch_worker=none (both arms in one process; no timing was dispatched to a worker).
n in G 1.49–1.68× faster (present keys) Was published at 1.2234×, corrected to a 0.3328× LOSS on 2026-08-14, and is a WIN again since 2026-08-15 — same lever as G.has_node above (br-r37-c1-6n9vm), which the 2026-08-14 row predates. Four admitted draws vs live nx 3.6.1 in the same invocation, 61 rounds, present string keys: 1.4917× CI 1.4475–1.5212×, 1.5622×, 1.6729×, 1.6841× CI 1.6443–1.7174×, A/A nulls within 0.019 of 1.0, ELF 1cfe8f2483a780e7. The range is the honest figure — the cross-run spread exceeds any single CI, and two of those draws were measured with the row's neighbours running in the same process, which is itself worth ~1.20× on this surface (br-r37-c1-y4r63). CONFIRMED after the substrate fix (br-r37-c1-7x25w): the draws above came from a harness that collected before every timed slot, and re-measuring on the corrected one gives 1.6113× CI 1.6025–1.6199×, nulls 1.0092/1.0018, ELF b6ccaee611a8ef67 — inside the published range, so this row survives a correction that retracted its sibling. ABSENT keys remain a loss at 0.8797×. harness=balanced_square_ab.py + ab_view_sweep2.py (kept at tests/artifacts/perf/20260815-dunder-wrapper-ablations-snowyvalley/), same_host=thinkstation1, rch_worker=none (both arms in one process; no timing was dispatched to a worker).
preferential_attachment 0.8635× Superseded figure: the old 0.5949× row predated the padm6 fix (91% of the gap); closed re-measure z00k8 reads 0.8635×. Residual loss is per-call boundary cost — nx's per-pair work is two degree lookups and a multiply.
Incremental add_edge, one call per edge Graph 0.90–1.02×, DiGraph 1.04–1.07× without attributes; 0.66× / 0.71× with weight= Fresh graph of 400 add_edge calls per timed op. Graph / DiGraph: a path on ints from empty 0.8974× / 1.0389×, shuffled Barabási–Albert edges on ints 0.9726× / 1.0477×, the same with str names 1.0150× / 1.0721×, and with weight=1.0 on every call 0.6568× / 0.7057×; every CI within ±0.005 of its median. Measured 2026-09-25, harness=scripts/balanced_square_ab.py --workload claim-add-edge --calls-per-slot 4, 41 rounds, live nx 3.6.1 in the same invocation, taskset -c 46, ELF 77b10b8813b8f549 (the lazy-mirror lever of 1e484d215), same_host=thinkstation1, 9/9 rows admitted, A/A nulls within 1.0 ± 0.012. The build before that lever, measured the same way, read 0.5828× / 0.6083× with weight=; before 677b5b977, 0.44× / 0.41×. The attributed calls still lose: each one converts its keyword dict into the native attribute map (br-r37-c1-olyn6). Batch constructors remain better per edge.
karate_club_graph 1.38–1.42× Was published as a 0.38× loss and is now a win. Re-measured 2026-08-08 vs live nx 3.6.1 in two admitted runs: 1.4232× CI 1.4150–1.4273× and 1.3812× CI 1.3745–1.3879×, dual A/A nulls within 0.0016 of 1.0. The range is the honest figure — the two runs' CIs do not overlap, which is this substrate's cross-run spread rather than either run being wrong.
tutte_graph not decidable Measured 2026-08-08 at 1.2860× but CI 0.9036–1.3563× STRADDLES 1.0, so no verdict is claimed despite clean A/A nulls (0.9997/0.9997). The published 0.76× is superseded but not replaced with a number. Split out of the old combined karate/tutte row precisely because the two no longer share a verdict.
read_multiline_adjlist 0.7981× Parser is not native; still a loss, re-measured 2026-07-31 vs live nx 3.6.1 (was 0.70×)
read_gml 0.92× GML parse path; CONFIRMED 2026-07-31 vs live nx 3.6.1 (measured 0.9234×, CI [0.9169, 0.9253] contains the published figure)
G.remove_node(n) 0.52× → 1.75× on Graph, 0.78× → 1.31× on DiGraph, 0.60× → 0.76× on MultiGraph, 0.32× → 0.45× on MultiDiGraph (n=1,600 → 25,600, non-tail node) Graph/DiGraph removal is O(degree), like nx's: the node's slot is tombstoned in O(1) and positions are ranks answered by a Fenwick tree until the next insertion compacts. The per-call cost is a flat ~2.5–3.5 µs, so it loses where nx's removal is cheaper (Graph 0.52× / 0.53× at 1.6k / 6.4k nodes, DiGraph 0.78× at 1.6k) and wins where nx's grows (Graph 1.75× at 25.6k, DiGraph 1.78× / 1.31× at 6.4k / 25.6k). MultiGraph removal is O(degree) as well (its insertion order tombstones apart from the slots, which are reused), but it loses at every size, 0.60× / 0.60× / 0.76× at 1.6k / 6.4k / 25.6k (median of 3 runs, loadavg ~5). Those graphs are built with add_edges_from, which leaves the Python attribute mirrors of the edges empty, and removal skips them when they are; a graph built one add_edge at a time fills them and loses more (0.27–0.30×). MultiDiGraph removal is O(degree) too (its node table tombstones and its row maps are unordered) and loses more, 0.32× / 0.51× / 0.45×: its String-keyed store frees about seven blocks per incident edge, and cutting its instruction count by 38% moved no wall-clock time; a slot-keyed store like MultiGraph's is the lever left. With an attribute on every edge a removal also updates the Python attribute mirrors of each incident edge (11–17 µs per removal at 1.6k–25.6k; 0.2–0.5× in read-then-remove loops). Measured 2026-09-24 (fresh graph per repetition, 200 removals, min of 3, same process, loaded host, harness=ad-hoc scaling probe, same_host=thinkstation1). Open: br-r37-c1-epic-storage-architecture-yr2oc.1.
MultiGraph/MultiDiGraph.get_edge_data(u, v) (unkeyed) 0.57–0.62× per call, flat from 1 to 16 parallel edges; consuming it (items + one attribute read) 0.73–0.89× Since 2026-09-24 it returns the pair's live keydict as a real dict kept in step with every edge mutation (was 0.2482× → 0.0274× when it rebuilt a dict per call, then a non-dict view whose consumption cost 0.16–0.40×). json/pickle/copy/`
Attributed-graph memory 3.4× nx's RSS (1.8× via set_edge_attributes) Edge attributes are stored twice (native AttrMap + Python dict); unattributed graphs use 0.63× of nx's memory. See "Memory considerations". Sanity measurement, 2026-09-24, no A/A null.
Backend mode on an nx graph, conversion cache off 0.026–0.40× for cheap kernels Every call converts the nx graph first (a few µs per edge): single_source_shortest_path_length 0.026×, connected_components 0.031×, pagerank 0.21×, weighted single_source_dijkstra 0.40× on a 20k-node BA graph. With NetworkX's default conversion cache on, the same calls win 1.7–17×. Same-process sanity probe, 2026-09-23, no A/A null. Tracked: br-r37-c1-rc0923-epic-perf-where-we-lose-sfq4w.2.
G.has_edge(u, v) / list(G.neighbors(n)) int nodes: 1.17–1.42× / 1.05–1.12×, except has_edge on present edges of a graph whose int nodes arrived out of order (0.975×); str nodes: 1.02–1.28× / 1.05–1.06×, except DiGraph.has_edge on present edges (0.975×) Graph and DiGraph, 20k-node BA graph, 400 calls per slot. Balanced-square A/B with A/A nulls (scripts/balanced_square_ab.py --workload claim-has-edge-neighbors --calls-per-slot 128), every row admitted, pinned to one CPU, thinkstation1, 2026-09-25: int rows ELF 476699fdfcd1, str rows ELF 73d0af80fbab from the same harness with str-named nodes. Tracked: br-r37-c1-rc0923-epic-perf-where-we-lose-sfq4w.3.
louvain_communities (weighted) 0.92× Runs NetworkX's own code on weighted input, plus the conversion. Same-process sanity probe, 2026-09-23, no A/A null.
G[u][v] Graph 1.09–1.24×, DiGraph 1.07–1.09×; MultiGraph 0.43–0.50×, MultiDiGraph 0.42–0.50× Measured 2026-09-25, harness=scripts/balanced_square_ab.py --workload row-subscript-family --reps 200 --rounds 41 --warmup 60 --calls-per-slot 128, live nx 3.6.1 in the same invocation, taskset -c 44, same_host=thinkstation1, node keys of 3 and 2,000 characters (flat in key length on every class). Admitted rows only; the ranges span four invocations, because the same binary moved about 13% between invocations on a loaded host while each CI is under 1%. Graph and DiGraph rows are the native AtlasView, whose __getitem__ is a C slot with a cached row index; the within-run DiGraph/Graph ratio went from 0.63–0.64 to 1.00–1.01 when DiGraph rows moved onto it (ELF 1c2cb2b1220f7da2), while the multigraph/Graph control held at 0.40–0.41. The multigraph rows still pay stacked Python view layers per subscript. Open for the multigraphs: br-r37-c1-ey6ob.

The add_edge row is one call per edge on a fresh graph, so each timed op is stationary: a graph that grew across timed slots would fail its own A/A null. The native method's own cost, in instructions per call (callgrind toggled on the method, fresh int graph, slope between 2,000 and 4,000 calls): about 4,200 for DiGraph and 4,500 for Graph without attributes, 7,000 and 7,200 with one. The CGSE decision ledger still files one record per call; its cost against the pre-br-r37-c1-wa1b9 counterfactual reproduces with env -u CARGO_TARGET_DIR taskset -c 40-47 cargo test -p fnx-classes --release ledger_record_cost_ab -- --ignored --nocapture.

Default simple-graph write_edgelist(data=False) writes directly from FNX edge iteration while preserving exact NetworkX bytes. Non-default and multigraph writer configurations retain their compatibility routes.