24 lines
965 B
Rust
24 lines
965 B
Rust
// 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;
|
|
type Edge: 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 edges(&self) -> impl Iterator<Item = Self::Edge>;
|
|
fn add_vertex(&mut self) -> Self::Vertex;
|
|
fn add_edge(&mut self, v1: Self::Vertex, v2: Self::Vertex) -> Self::Edge;
|
|
}
|
|
|
|
pub trait GraphTopologyDeletion: GraphTopology {
|
|
fn delete_vertex(&mut self, v: Self::Vertex);
|
|
fn delete_edge(&mut self, e: Self::Edge);
|
|
}
|