Add FrozenGraph (without tests)

This commit is contained in:
2026-08-17 10:25:52 +02:00
parent 5085b7795b
commit a89086253a
5 changed files with 270 additions and 9 deletions
+12 -5
View File
@@ -5,8 +5,8 @@
//!
//! Currently supported are:
//!
//! * Undirected graph types [`Graph`] and [`AppendGraph`] built on a flat, index-based adjacency
//! list,
//! * Undirected graph types [`Graph`], [`AppendGraph`], and [`FrozenGraph`] built on a flat,
//! index-based adjacency list,
//! * [`ElementMap`] to freely associate custom data with vertices and edges,
//! * Connectivity and pathing algorithms: [Dijkstra's algorithm], [DFS], and [BFS] in different
//! variants,
@@ -62,9 +62,11 @@
//!
//! # Graph types
//!
//! [`Graph`] and [`AppendGraph`] both implement [`GraphTopology`] using a flat, index-based adjacency
//! list to store edges, which means that vertex and edge insertions happen in `O(1)`. Degree
//! lookups are also `O(1)`.
//! [`Graph`], [`AppendGraph`], and [`FrozenGraph`] all implement [`GraphTopology`] using a flat,
//! index-based adjacency list to store edges. Degree lookups run in `O(1)`.
//!
//! [`Graph`] and [`AppendGraph`] implement [`GraphTopologyAddition`], which provides functionality
//! for iterative graph construction. Vertex and edge insertions happen in `O(1)`.
//!
//! [`Graph`] additionally implements [`GraphTopologyDeletion`], thereby supporting deletion of
//! vertices and edges.
@@ -73,6 +75,10 @@
//! be smaller and more performant compared to [`Graph`] by not requiring the per-element generation
//! tracking needed for stable handles after deletion.
//!
//! [`FrozenGraph`] uses a memory layout that is more cache-friendly for traversals than
//! [`AppendGraph`], but the trade-off is that its topology must be constructed during its
//! initialization. It cannot be modified afterward.
//!
//! # Vertices and edges
//!
//! Graphs in this library use stable indices [`GraphTopology::Vertex`] and [`GraphTopology::Edge`]
@@ -119,6 +125,7 @@
//! [DFS]: crate::algorithms::dfs
//! [`ElementMap`]: crate::maps::ElementMap
//! [`AppendGraph`]: crate::models::AppendGraph
//! [`FrozenGraph`]: crate::models::FrozenGraph
//! [`Graph`]: crate::models::Graph
//! [`traits`]: crate::traits
//! [`GraphTopology`]: crate::traits::GraphTopology