Move edge_count() in method order

This commit is contained in:
2026-05-07 11:38:15 +02:00
parent 016cece626
commit e074fdf944
3 changed files with 9 additions and 9 deletions
+4 -4
View File
@@ -80,10 +80,6 @@ impl GraphTopology for AppendGraph {
self.vertices.len()
}
fn edge_count(&self) -> usize {
self.incidences.len() / 2
}
fn vertex_capacity(&self) -> usize {
self.vertices.len()
}
@@ -92,6 +88,10 @@ impl GraphTopology for AppendGraph {
VertexMap::new(default, |v| v.0, self.vertex_capacity())
}
fn edge_count(&self) -> usize {
self.incidences.len() / 2
}
fn degree(&self, v: Self::Vertex) -> usize {
self.vertices[v.0].incidence_count
}
+4 -4
View File
@@ -159,10 +159,6 @@ impl GraphTopology for Graph {
self.vertices.len()
}
fn edge_count(&self) -> usize {
self.incidences.len() / 2
}
fn vertex_capacity(&self) -> usize {
self.vertices.capacity()
}
@@ -171,6 +167,10 @@ impl GraphTopology for Graph {
VertexMap::new(default, |v| v.arr_idx(), self.vertex_capacity())
}
fn edge_count(&self) -> usize {
self.incidences.len() / 2
}
fn degree(&self, v: Self::Vertex) -> usize {
self.vertices[v].incidence_count
}
+1 -1
View File
@@ -9,9 +9,9 @@ pub trait GraphTopology {
type Edge: Copy + Eq;
fn vertex_count(&self) -> usize;
fn edge_count(&self) -> usize;
fn vertex_capacity(&self) -> usize;
fn vertex_map<T: Clone>(&self, default: T) -> VertexMap<Self::Vertex, T>;
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>;