petgraph-live
Status: coming soon. Implementation in progress. API not yet stable.
Graph cache, snapshot, and algorithms for petgraph 0.8.
Purpose
petgraph is excellent for building and traversing graphs. petgraph-live adds
the operational layer missing for long-running processes:
-
Hot-reload cache — generic
GenerationCache<G>that reuses a built graph until an external counter (e.g. an index generation, a file watch event) signals a change. No redundant rebuilds in serve mode. -
Disk snapshot — persist and restore the cached graph across process restarts. Atomic writes, commit-keyed validity check, silent fallback to rebuild on mismatch or corruption.
-
Graph algorithms — unweighted metrics and connectivity analysis on
petgraph 0.8graphs, with no heavy dependencies (nalgebra,rand, etc.):metrics: diameter, radius, eccentricity, center, peripheryconnect: articulation points, bridges
All algorithms work on any DiGraph<N, E> — no wiki or domain concepts inside
this crate.
Planned API
use GenerationCache;
use metrics;
use connect;
// Cache a graph, rebuild only when generation changes
let cache = new;
let graph = cache.get_or_build?;
// Graph health metrics
let d = diameter; // longest shortest path
let c = center; // most central nodes
// Connectivity analysis
let ap = articulation_points; // removal disconnects graph
let br = find_bridges; // edge removal disconnects graph
Motivation
Built as a companion to llm-wiki,
a git-backed wiki engine with MCP server. The graph cache and algorithm needs
there are generic enough to live in a standalone crate on petgraph 0.8.
The only available alternative (graphalgs) is pinned to petgraph ^0.6.5 and
appears unmaintained (last release 2023). petgraph-live targets petgraph 0.8
only and has no plans to support older versions.
Roadmap
-
cache::GenerationCache<G>with read-write lock, hit/miss semantics -
metrics— diameter, radius, eccentricity, center, periphery (BFS, O(n·(n+e))) -
connect— articulation points, bridges (DFS, O(n+e)) -
snapshot— serde-based disk persistence (petgraph serde-1feature) - Docs and examples
License
MIT OR Apache-2.0