Add GraphTopology::incident_edges() and tests

This commit is contained in:
2026-05-13 10:59:38 +02:00
parent 384dca2d20
commit f862ac55ec
4 changed files with 185 additions and 1 deletions
+1 -1
View File
@@ -1,7 +1,6 @@
use crate::maps::{EdgeMap, VertexMap};
// TODO: Add functions to reserve memory for vertices and edges.
// TODO: Add iterator of incident edges for a vertex.
// TODO: Split out GraphTopologyAddition trait.
pub trait GraphTopology {
type Vertex: Copy + Eq;
@@ -19,6 +18,7 @@ pub trait GraphTopology {
fn adjacent_vertices(&self, v: Self::Vertex) -> impl Iterator<Item = Self::Vertex>;
fn incident_vertices(&self, e: Self::Edge) -> (Self::Vertex, Self::Vertex);
fn edges(&self) -> impl Iterator<Item = Self::Edge>;
fn incident_edges(&self, v: Self::Vertex) -> impl Iterator<Item = Self::Edge>;
fn incidences(&self, v: Self::Vertex) -> impl Iterator<Item = (Self::Vertex, Self::Edge)>;
fn add_vertex(&mut self) -> Self::Vertex;
fn add_edge(&mut self, v1: Self::Vertex, v2: Self::Vertex) -> Self::Edge;