MCPcopy Create free account
hub / github.com/douchuan/algorithm / Dijkstra_sp

Function Dijkstra_sp

tests/test_shortest_paths.rs:55–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53#[allow(non_snake_case)]
54#[test]
55fn Dijkstra_sp() {
56 let i = TINY_EWD;
57 let graph = create_graph(i);
58 let sp = DijkstraSP::new(graph.as_ref(), 0);
59 for (i, (weight, size)) in vec![
60 (0.0, 0), // (dist_to(i), path_to(i).len())
61 (1.05, 3),
62 (0.26, 1),
63 (0.99, 3),
64 (0.38, 1),
65 (0.73, 2),
66 (1.51, 4),
67 (0.6, 2),
68 ]
69 .iter()
70 .enumerate()
71 {
72 assert_eq!(*size, sp.path_to(i).map_or(0, |path| path.len()));
73 assert_relative_eq!(*weight, sp.dist_to(i));
74 }
75
76 assert!(sp.check(graph.as_ref(), 0).is_ok());
77}
78
79#[allow(non_snake_case)]
80#[test]

Callers

nothing calls this directly

Calls 2

create_graphFunction · 0.70
iterMethod · 0.45

Tested by

no test coverage detected