Add GraphTopology trait and use it to interface graph model with algorithm
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
pub trait GraphTopology {
|
||||
type Vertex: Copy + Eq;
|
||||
|
||||
fn vertex_count(&self) -> usize;
|
||||
fn edge_count(&self) -> usize;
|
||||
fn degree(&self, v: Self::Vertex) -> usize;
|
||||
fn are_adjacent(&self, v1: Self::Vertex, v2: Self::Vertex) -> bool;
|
||||
fn vertices(&self) -> impl Iterator<Item = Self::Vertex>;
|
||||
fn neighbors(&self, v: Self::Vertex) -> impl Iterator<Item = Self::Vertex>;
|
||||
fn add_vertex(&mut self) -> Self::Vertex;
|
||||
fn add_edge(&mut self, v1: Self::Vertex, v2: Self::Vertex);
|
||||
}
|
||||
Reference in New Issue
Block a user