Add GraphTopology trait and use it to interface graph model with algorithm
This commit is contained in:
+3
-3
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user