Refactor tests: use MakeTestGraph in model-specific tests, deconstruct vertex arrays where useful, adjust local variable names

This commit is contained in:
2026-09-04 09:28:00 +02:00
parent 016d127bd1
commit 4c6a8a43e4
11 changed files with 153 additions and 195 deletions
+8 -8
View File
@@ -74,13 +74,13 @@ impl IncidenceCursor<FrozenGraph> for FrozenGraphIncidenceCursor {
///
/// // Constructs a FrozenGraph instance via AppendGraph.
/// let mut graph = AppendGraph::new();
/// let v1 = graph.add_vertex();
/// let v2 = graph.add_vertex();
/// let e = graph.add_edge(v1, v2);
/// let (graph, vertices, edges) = FrozenGraph::from_graph(&graph);
/// let u = graph.add_vertex();
/// let v = graph.add_vertex();
/// let e = graph.add_edge(u, v);
/// let (graph, vertex_map, edge_map) = FrozenGraph::from_graph(&graph);
///
/// // Queries the FrozenGraph instance.
/// assert!(graph.are_adjacent(vertices[v1], vertices[v2]));
/// // Queries the FrozenGraph instance via the returned map.
/// assert!(graph.are_adjacent(vertex_map[u], vertex_map[v]));
/// ```
///
/// # Time and space complexity
@@ -210,8 +210,8 @@ impl GraphTopology for FrozenGraph {
self.vertices[v.0 + 1] - self.vertices[v.0]
}
fn are_adjacent(&self, v1: Self::Vertex, v2: Self::Vertex) -> bool {
self.adjacent_vertices(v1).any(|x| x == v2)
fn are_adjacent(&self, u: Self::Vertex, v: Self::Vertex) -> bool {
self.adjacent_vertices(u).any(|x| x == v)
}
fn vertices(&self) -> impl Iterator<Item = Self::Vertex> {