Update breadth-first search tests
This commit is contained in:
@@ -141,18 +141,21 @@ macro_rules! bfs_tests {
|
|||||||
use $crate::traits::GraphTopology;
|
use $crate::traits::GraphTopology;
|
||||||
let mut graph = <$T>::new();
|
let mut graph = <$T>::new();
|
||||||
let v = graph.add_vertex();
|
let v = graph.add_vertex();
|
||||||
let result = $crate::algorithms::bfs_find_where(&graph, v, |u| u == v);
|
assert_eq!(
|
||||||
assert_eq!(result, Some((v, 0)), "source should match with distance 0");
|
$crate::algorithms::bfs_find_where(&graph, v, |u| u == v),
|
||||||
|
Some((v, 0)),
|
||||||
|
"source should match with distance 0"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bfs_find_where_disconnected() {
|
fn bfs_find_where_disconnected() {
|
||||||
let (graph, vertices) = make_test_graph_disconnected();
|
let (graph, vertices) = make_test_graph_disconnected();
|
||||||
let target = vertices[1];
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
$crate::algorithms::bfs_find_where(&graph, vertices[0], |v| v == target),
|
$crate::algorithms::bfs_find_where(&graph, vertices[0], |v| v == vertices[1]),
|
||||||
None,
|
None,
|
||||||
"disconnected vertex should not be found"
|
"disconnected vertex {:?} should not be found",
|
||||||
|
vertices[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user