Add GraphTopology trait and use it to interface graph model with algorithm

This commit is contained in:
2026-04-22 14:26:35 +02:00
parent 489ed6d506
commit da9ba7b0ad
5 changed files with 79 additions and 53 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
use grapherity::algorithms;
use grapherity::models::Graph;
use grapherity::models::Vertex;
use grapherity::traits::GraphTopology;
#[test]
fn dijkstra_single_vertex() {
@@ -107,9 +107,9 @@ fn dijkstra() {
}
}
fn make_test_graph() -> (Graph, [Vertex; 10]) {
fn make_test_graph() -> (Graph, [<Graph as GraphTopology>::Vertex; 10]) {
let mut graph = Graph::new();
let vertices: [Vertex; 10] = core::array::from_fn(|_| graph.add_vertex());
let vertices = core::array::from_fn::<_, 10, _>(|_| graph.add_vertex());
graph.add_edge(vertices[0], vertices[1]);
graph.add_edge(vertices[1], vertices[2]);
graph.add_edge(vertices[1], vertices[3]);