Guide/How it works
Architecture
2 min readFrom the README
On this page 1
┌──────────────────────────────────────────────────────────┐
│ Python package: franken_networkx │
│ __init__.py • backend.py • backend_info.py │
│ _fnx.pyi (stubs) • 476 algorithms in backend dispatch│
└────────────────────────────┬─────────────────────────────┘
│ PyO3 / ABI3-py310
▼
┌──────────────────────────────────────────────────────────────────────────┐
│ fnx-python (cdylib) │
│ lib.rs • algorithms.rs • digraph.rs • generators.rs │
│ readwrite.rs • views.rs • cgse.rs (releases GIL at hot paths) │
└────────┬───────────────────┬────────────────┬───────────────┬────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌────────────────┐ ┌─────────────────┐ ┌──────────┐ ┌──────────────┐
│ fnx-classes │ │ fnx-algorithms │ │ fnx-cgse │ │ fnx-readwrite│
│ Graph,DiGraph │ │ 650+ pub fns: │ │ TieBreak │ │ edgelist,GML │
│ Multi*Graph │ │ shortest path, │ │ Policy │ │ GraphML,JSON │
│ IndexMap adj │ │ centrality, etc │ │ Witness │ │ Pajek,GEXF,..│
└───────┬────────┘ └────────┬────────┘ │ Ledger │ └──────────────┘
│ │ └────┬─────┘
▼ ▼ ▼
┌────────────────┐ ┌──────────────────┐ ┌─────────────────────────────┐
│ fnx-views │ │ fnx-generators │ │ fnx-runtime │
│ GraphView │ │ classic, random, │ │ CompatibilityMode │
│ DiGraphView │ │ scale-free, │ │ (Strict | Hardened) │
│ CachedSnap- │ │ lattice, social │ │ CgsePolicyEngine │
│ cached │ │ SBM, WS, BA, GNP │ │ DecisionRecord / evidence │
└────────────────┘ └──────────────────┘ └─────────────────────────────┘
┌─────────────────────────────┐
│ fnx-dispatch fnx-convert │
│ fnx-conformance fnx-durability│
│ RaptorQ sidecars + scrub │
└─────────────────────────────┘
The 12 Rust Crates
| Crate | Purpose |
|---|---|
fnx-classes |
Core graph types and deterministic adjacency storage (IndexMap<Node, IndexMap<Neighbor, AttrMap>>). Attribute storage via BTreeMap. Node and edge insertion order is preserved, which matters for tie-break parity. |
fnx-views |
Borrowed snapshot wrappers (GraphView<'a>, DiGraphView<'a>) plus revision-tracking CachedSnapshotView / CachedDiGraphSnapshotView. Used by the conformance harness and snapshot round-trip layer. The Python-facing live views (NodeView, EdgeView, DegreeView, AdjacencyView, SubgraphView) are defined in crates/fnx-python/src/views.rs as PyO3 classes on top of these primitives. |
fnx-dispatch |
Backend registry, dispatch routing, fail-closed decision plumbing for the NetworkX backend protocol. |
fnx-convert |
Conversions between graph types, NumPy / SciPy / pandas interop, dict-of-dicts and dict-of-lists round-trips, node-label remapping. |
fnx-algorithms |
~94 KLOC (inline tests included) across 650+ public functions covering shortest path, centrality, connectivity, clustering, matching, flow, trees, community, isomorphism, planarity, polynomials, spectral, traversal, and DAG families. |
fnx-generators |
Classic, random, scale-free, lattice, and social graph generators. Deterministic seeded RNG with NetworkX-byte-compatible edge enumeration order where contracted. |
fnx-readwrite |
Native Rust parsers and writers for 7 formats: edgelist, adjlist, GraphML, GML, JSON (node-link), Pajek, GEXF. Cargo-fuzz hardened with 8 dedicated parser fuzzers. Format variants exposed at the Python layer (read_weighted_edgelist, read_multiline_adjlist, read_leda, read_graph6, read_sparse6) compose the native primitives or delegate to NetworkX for niche formats. |
fnx-cgse |
Canonical Graph Semantics Engine. 13-variant TieBreakPolicy sum type. ComplexityWitness { n, m, dominant_term, observed_count, policy, seed, decision_path_blake3 } with length-prefixed Blake3 hashing. WitnessSink, WitnessLedger, and a V1 policy registry mapping reference algorithms to canonical policies. |
fnx-runtime |
CompatibilityMode::{Strict, Hardened}, CgsePolicyEngine, structured DecisionRecords with evidence terms, fail-closed defaults. |
fnx-conformance |
Curated parity harness; fixture replay; differential report generation; structured logs and replay commands; artifact emitters writing to artifacts/conformance/latest/. |
fnx-durability |
RaptorQ sidecar generation, integrity scrub, decode-proof artifacts for conformance fixture bundles, benchmark baselines, migration manifests, reproducibility ledgers, and long-lived state snapshots. |
fnx-python |
PyO3/maturin bindings; the franken_networkx._fnx cdylib; ABI3-py310 (one wheel works on Python 3.10+). Releases the GIL via py.allow_threads(...) at hundreds of call sites. |