Architecture overview
This page summarizes the core design from architecture.md.
Core data model
- Incidence matrix (V×E) as the primary structure (sparse DOK in‑memory, stored as COO). Each edge is a column; direction uses sign (+ for head/source, − for tail/target). Undirected edges use + on all incident vertices.
- Unified entity system: vertex rows and edge‑entities (for vertex–edge relations) share the same row space with
entity_to_idx,idx_to_entity, andentity_types. - Edge system:
edge_to_idx,idx_to_edge,edge_definitions, per‑edgeweight, anddirectedflags. Parallel edges are separate columns.
Direction and hyperedges
- Direction control at three levels: graph default, per‑edge override, mixed mode.
- Hyperedges: undirected (set membership) or directed (head→tail) with explicit
hyperedge_definitionsandedge_kind. - SBML stoichiometry: per‑endpoint coefficients written directly into incidence columns.
Slices
- Named subgraph memberships with a current active slice for new elements.
- Set algebra (union/intersection/difference) and per‑slice edge attributes (e.g., weight overrides).
Multilayer networks (Kivelä)
- Aspects and elementary layers define the layer space (cartesian product). Vertex‑layer presence tracked in
V×Mset; edges can be intra‑layer, inter‑layer, or coupling. - Supra‑adjacency and supra‑Laplacian available; a 4‑index tensor view provides a higher‑order representation.
Attributes (Polars DataFrames)
- Separate, columnar tables for vertex, edge, slice, and edge‑slice attributes. Structural keys are filtered; only pure user attributes go into tables.
- Upsert semantics with automatic schema growth and type inference; read‑only views for quick inspection.
Interoperability
- Runtime backend adapters:
- NetworkX via
G.nxandto_nx/from_nx - igraph via
G.igandto_igraph/from_igraph - graph‑tool via
G.gtandto_graphtool(if installed) - Conversion options:
directed,hyperedge_mode(skip/expand), slice selection, and simple mode (collapse multiedges). Proxies may slim attributes to those required for algorithms. - Manifests: returned on conversion to improve round‑trip fidelity on import (hyperedges, slices, multigraph collapsing).
Storage layout (.annnet)
- Directory structure combines Zarr for arrays and Parquet for tables, plus JSON sidecars. Key paths:
manifest.jsonwith counts, versions, and slice metadatastructure/incidence.zarr/{row,col,data}and index maps as Parquettables/*for attributes;layers/andslices/for multilayer and slice dataaudit/for history; optionalcache/for CSR/CSC;uns/for unstructured results
History and diffs
- Automatic mutation logging with export to Parquet/JSON/CSV/NDJSON, named snapshots, and diffs between snapshots.
Spectral methods
- Supra adjacency/Laplacian, transition matrices, eigenvalue routines, diffusion and random walk helpers, and coupling regime sweeps.
For full details, see the top‑level architecture.md in the repository.