Add edge return type to GraphTopology::add_edge()

There is currently no use for the return type, but it will come.
This commit is contained in:
2026-04-22 14:28:21 +02:00
parent da9ba7b0ad
commit 9088dd4683
2 changed files with 7 additions and 3 deletions
+5 -2
View File
@@ -10,7 +10,7 @@ impl From<Vertex> for usize {
}
#[derive(Copy, Clone, PartialEq, Eq)]
struct Incidence(usize);
pub struct Incidence(usize);
struct VertexIncidenceHeader {
incidence_count: usize,
@@ -69,6 +69,8 @@ impl Graph {
impl GraphTopology for Graph {
type Vertex = Vertex;
type Edge = Incidence;
fn vertex_count(&self) -> usize {
self.vertices.len()
}
@@ -104,9 +106,10 @@ impl GraphTopology for Graph {
Vertex(self.vertices.len() - 1)
}
fn add_edge(&mut self, v1: Self::Vertex, v2: Self::Vertex) {
fn add_edge(&mut self, v1: Self::Vertex, v2: Self::Vertex) -> Self::Edge {
self.add_incidence(v1, v2);
self.add_incidence(v2, v1);
Incidence(self.incidences.len() - 2)
}
}