Replace VertexMap and EdgeMap with now public EntityMap

This commit is contained in:
2026-07-22 13:30:09 +02:00
parent 8db7a86187
commit d711e68577
11 changed files with 90 additions and 300 deletions
+7 -7
View File
@@ -1,13 +1,13 @@
use typed_generational_arena::{Arena, Index};
use crate::maps::{EdgeMap, VertexMap};
use crate::maps::EntityMap;
use crate::traits::{GraphTopology, GraphTopologyDeletion, IncidenceCursor};
pub type Vertex = Index<VertexIncidenceHeader, usize, usize>;
pub type Edge = Index<IncidenceEntry, usize, usize>;
pub type GraphVertexMap<T> = VertexMap<Vertex, T>;
pub type GraphEdgeMap<T> = EdgeMap<Edge, T>;
pub type GraphVertexMap<T> = EntityMap<Vertex, T>;
pub type GraphEdgeMap<T> = EntityMap<Edge, T>;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct VertexSlot(usize);
@@ -163,8 +163,8 @@ impl GraphTopology for Graph {
self.vertices.capacity()
}
fn vertex_map<T: Clone>(&self, default: T) -> VertexMap<Self::Vertex, T> {
VertexMap::new(default, |v| v.arr_idx(), self.vertex_capacity())
fn vertex_map<T: Clone>(&self, default: T) -> EntityMap<Self::Vertex, T> {
EntityMap::new(default, |v| v.arr_idx(), self.vertex_capacity())
}
fn edge_count(&self) -> usize {
@@ -175,8 +175,8 @@ impl GraphTopology for Graph {
self.incidences.capacity() / 2
}
fn edge_map<T: Clone>(&self, default: T) -> EdgeMap<Self::Edge, T> {
EdgeMap::new(default, |e| e.arr_idx() / 2, self.edge_capacity())
fn edge_map<T: Clone>(&self, default: T) -> EntityMap<Self::Edge, T> {
EntityMap::new(default, |e| e.arr_idx() / 2, self.edge_capacity())
}
fn degree(&self, v: Self::Vertex) -> usize {