Add GraphTopology.incidence_cursor() for certain use-cases where the iterator is problematic
Also add raw_incidences() and step_incidence() to AppendGraph analogously to Graph, which allows to remove RawIncidenceIterator and simplify its call sites.
This commit is contained in:
@@ -5,6 +5,7 @@ use crate::maps::{EdgeMap, VertexMap};
|
||||
pub trait GraphTopology {
|
||||
type Vertex: Copy + Eq;
|
||||
type Edge: Copy + Eq;
|
||||
type IncidenceCursor: IncidenceCursor<Self> + Copy;
|
||||
|
||||
fn vertex_count(&self) -> usize;
|
||||
fn vertex_capacity(&self) -> usize;
|
||||
@@ -20,6 +21,7 @@ pub trait GraphTopology {
|
||||
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 incidence_cursor(&self, v: Self::Vertex) -> Self::IncidenceCursor;
|
||||
fn add_vertex(&mut self) -> Self::Vertex;
|
||||
fn add_edge(&mut self, v1: Self::Vertex, v2: Self::Vertex) -> Self::Edge;
|
||||
}
|
||||
@@ -28,3 +30,7 @@ pub trait GraphTopologyDeletion: GraphTopology {
|
||||
fn delete_vertex(&mut self, v: Self::Vertex);
|
||||
fn delete_edge(&mut self, e: Self::Edge);
|
||||
}
|
||||
|
||||
pub trait IncidenceCursor<G: GraphTopology + ?Sized> {
|
||||
fn next(&mut self, graph: &G) -> Option<(G::Vertex, G::Edge)>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user