Guide/Evidence
Compatibility Doctrine
3 min readFrom the README
On this page 2
FrankenNetworkX's compatibility contract is not "best-effort similarity." It is a machine-checked guarantee policed by five auto-generated audit ledgers under docs/:
| Ledger | Purpose |
|---|---|
coverage.md |
NetworkX 3.6.1 FeatureUniverse: 4,926 qualified paths classified as present, partial, missing, n/a, or reasoned excluded; per-family strict coverage is reported. A separate appendix classifies the 843 franken_networkx.__all__ implementation routes. Drift fails the DSR quality run. |
raw_vs_public_audit.md |
Every _raw_X Rust kernel cross-checked against its public wrapper. Documents the 24 wrapper-patched parity repairs where the public wrapper post-processes raw output to match NetworkX. |
delegation_ledger.md |
AST classification of how each public name reaches NetworkX (nx-fallback / mixed-route / py-wrapper / rust-native / rust-reexport). It currently recognises delegation helpers by name, so NetworkX calls made through renamed helpers are under-counted; it is being rebuilt to classify by call-graph reachability plus a runtime frame census (br-r37-c1-rc0923-epic-honest-measurement-vbneu.2). |
upstream_divergence_ledger.md |
Unified ledger of native-parity, wrapper-patched, intentionally-delegated, raw-known-gap, and owner-acknowledged-limitation rows. |
api_ergonomics_audit.md |
Signature-level drift detection: parameter names, defaults, and keyword-only contracts compared against NetworkX. |
If you find a behavior that doesn't match NetworkX and isn't listed in upstream_divergence_ledger.md, that's a bug, not a feature.
Exception class hierarchy
FrankenNetworkX re-exports NetworkX's exception classes verbatim so except nx.NetworkXError: and except fnx.NetworkXError: catch the same instances. 14 of these classes are explicitly listed in fnx.__all__ and show up as public CLASS exports in docs/coverage.md. The remaining two (AmbiguousSolution, ExceededMaxIterations) are not in __all__ but are still reachable as fnx.AmbiguousSolution / fnx.ExceededMaxIterations via the package's __getattr__ fallback to networkx (the identity is preserved: fnx.AmbiguousSolution is nx.AmbiguousSolution). The actual hierarchy (matches networkx.exception):
Exception
└── NetworkXException (base for everything below)
├── NetworkXError (general "wrong shape of input")
├── NetworkXPointlessConcept (e.g. centrality on the empty graph)
├── NetworkXAlgorithmError (algorithm-specific precondition violated)
│ ├── NetworkXUnfeasible (no feasible solution exists)
│ │ ├── NetworkXNoPath (no path between s and t)
│ │ └── NetworkXNoCycle (cycle expected but none found)
│ └── NetworkXUnbounded (objective unbounded)
├── HasACycle (cycle present where one is forbidden)
├── NetworkXNotImplemented (also inherits NotImplementedError)
├── NodeNotFound (node missing from graph)
├── AmbiguousSolution (multiple valid answers)
├── ExceededMaxIterations (loop hit its iteration cap)
│ └── PowerIterationFailedConvergence (specifically eigenvector/PageRank failed)
├── NetworkXTreewidthBoundExceeded (chordal — treewidth above the requested bound)
└── NotATree (tree-only algorithm given a non-tree)
Important nuances to know about:
NetworkXAlgorithmErroris not underNetworkXError. Both are direct children ofNetworkXException. If you writeexcept nx.NetworkXError:, you will not catchNetworkXNoPath. UseNetworkXException(the broadest catch) orNetworkXAlgorithmError(the broadest algorithm catch).NetworkXNoPathandNetworkXNoCycleare siblings underNetworkXUnfeasible, not direct children ofNetworkXAlgorithmError.except nx.NetworkXUnfeasible:catches both.NodeNotFoundis underNetworkXExceptiondirectly. It is not a subclass ofNetworkXError.
The exception-class and error-message parity is part of the DSR quality run (test_error_messages.py). If nx.shortest_path(G, "a", "z") raises NetworkXNoPath with message "No path between a and z.", fnx.shortest_path(G, "a", "z") must raise the same class with the same wording. Bead cycles like br-r37-c1-hpeix and br-r37-c1-jxvsu were dedicated to locking missing-source/target wording across 30+ functions.
Why the strict parity: existing NetworkX code routinely does except nx.NetworkXNoPath: and inspects str(e). Drifting an exception class or wording subtly breaks downstream pipelines that depend on it.
Parity coverage today
- Runtime census (2026-09-23, NetworkX frames counted with
sys.monitoringon the default call path): 35 of 41 commonly used functions execute no NetworkX code — shortest paths, the main centralities (pagerank, betweenness, closeness, harmonic, katz, hits, eigenvector), components, cuts, connectivity, flow, min-cost flow, MST, coloring, isomorphism, planarity, distance measures, cliques, cores, transitive closure. - Always-NetworkX today: weighted/self-loop
louvain_communities,simple_cycles,k_components. (max_weight_matching,min_weight_matching,maximum_branchingwith its family, andgreedy_modularity_communitiesnow run networkx's algorithms natively, results identical including order and, for matchings, pair direction.) Several other functions reach NetworkX only for specific argument shapes (customflow_func, user callables, somek/seedcombinations), and 112 submodule callables are NetworkX's own function objects re-exported. - Wrapper-patched exports — the Rust kernel runs the algorithm but the Python wrapper post-processes output ordering to match NetworkX's iteration semantics — are enumerated with exact counts in
raw_vs_public_audit.md. - 1 raw-known-gap row and 1 owner-acknowledged limitation in
upstream_divergence_ledger.md; the public wrappers hide both behind fallbacks.