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

Function bfs_paths

tests/test_undirected_graph.rs:91–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90#[test]
91fn bfs_paths() {
92 let graph = create_graph(TINY_CG);
93 let paths = BreadthFirstPaths::new(graph.as_ref(), 0);
94 for (v, expect) in vec![
95 Some(vec![0usize]), // 0
96 Some(vec![0, 1]), // 1
97 Some(vec![0, 2]), // 2
98 Some(vec![0, 2, 3]), // 3
99 Some(vec![0, 2, 4]), // 4
100 Some(vec![0, 5]), // 5
101 ]
102 .iter()
103 .enumerate()
104 {
105 {
106 let paths: Option<Vec<usize>> = paths
107 .path_to(v)
108 .and_then(|paths| Some(paths.iter().map(|&v| v).collect()));
109 assert_eq!(expect, &paths);
110 }
111 let expect_dist = expect.as_ref().map_or(usize::MAX, |v| v.len() - 1);
112 assert_eq!(expect_dist, paths.dist_to(v));
113 }
114}
115
116#[test]
117fn cc() {

Callers

nothing calls this directly

Calls 4

create_graphFunction · 0.70
iterMethod · 0.45
path_toMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected