MCPcopy Index your code
hub / github.com/douchuan/algorithm / bfs_paths

Function bfs_paths

tests/test_directed_graph.rs:58–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56
57#[test]
58fn bfs_paths() {
59 let graph = create_digraph(TINY_DG);
60 let paths = BreadthFirstPaths::new(graph.as_ref(), 3);
61 for (v, expect) in vec![
62 Some(vec![3, 2, 0]), // 0
63 Some(vec![3, 2, 0, 1]), // 1
64 Some(vec![3, 2]), // 2
65 Some(vec![3]), // 3
66 Some(vec![3, 5, 4]), // 4
67 Some(vec![3, 5]), // 5
68 None, // 6
69 None, // 7
70 None, // 8
71 None, // 9
72 None, // 10
73 None, // 11
74 None, // 12
75 ]
76 .iter()
77 .enumerate()
78 {
79 {
80 let paths: Option<Vec<usize>> = paths
81 .path_to(v)
82 .and_then(|paths| Some(paths.iter().map(|&v| v).collect()));
83 assert_eq!(expect, &paths);
84 }
85 let expect_dist = expect.as_ref().map_or(usize::MAX, |v| v.len() - 1);
86 assert_eq!(expect_dist, paths.dist_to(v));
87 }
88}
89
90#[test]
91fn search() {

Callers

nothing calls this directly

Calls 4

create_digraphFunction · 0.85
iterMethod · 0.45
path_toMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected