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:
+5
-2
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user