Add GraphTopology::incident_vertices and tests

This commit is contained in:
2026-05-12 13:37:27 +02:00
parent 85e25ef0ca
commit f45fc98afc
4 changed files with 180 additions and 1 deletions
+1 -1
View File
@@ -2,7 +2,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: Add finding incident vertices for an edge.
// TODO: Split out GraphTopologyAddition trait.
pub trait GraphTopology {
type Vertex: Copy + Eq;
@@ -18,6 +17,7 @@ pub trait GraphTopology {
fn are_adjacent(&self, v1: Self::Vertex, v2: Self::Vertex) -> bool;
fn vertices(&self) -> impl Iterator<Item = Self::Vertex>;
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 incidences(&self, v: Self::Vertex) -> impl Iterator<Item = (Self::Vertex, Self::Edge)>;
fn add_vertex(&mut self) -> Self::Vertex;