Add VertexMap to attach data to vertices

This commit is contained in:
2026-05-06 20:28:00 +02:00
parent 6e9867a65e
commit f40c03b113
6 changed files with 168 additions and 54 deletions
+9
View File
@@ -1,3 +1,4 @@
use crate::maps::VertexMap;
use crate::traits::GraphTopology;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
@@ -83,6 +84,14 @@ impl GraphTopology for AppendGraph {
self.incidences.len() / 2
}
fn vertex_capacity(&self) -> usize {
self.vertices.len()
}
fn vertex_map<T: Clone>(&self, default: T) -> VertexMap<Self::Vertex, T> {
VertexMap::new(default, |v| v.0, self.vertex_capacity())
}
fn degree(&self, v: Self::Vertex) -> usize {
self.vertices[v.0].incidence_count
}