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

Function dfs_paths

tests/test_directed_graph.rs:29–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27
28#[test]
29fn dfs_paths() {
30 let graph = create_digraph(TINY_DG);
31 let paths = DepthFirstPaths::new(graph.as_ref(), 3);
32 for (v, expect) in vec![
33 Some(vec![3usize, 5, 4, 2, 0]), // 0
34 Some(vec![3, 5, 4, 2, 0, 1]), // 1
35 Some(vec![3, 5, 4, 2]), // 2
36 Some(vec![3]), // 3
37 Some(vec![3, 5, 4]), // 4
38 Some(vec![3, 5]), // 5
39 None, // 6
40 None, // 7
41 None, // 8
42 None, // 9
43 None, // 10
44 None, // 11
45 None, // 12
46 ]
47 .iter()
48 .enumerate()
49 {
50 let paths: Option<Vec<usize>> = paths
51 .path_to(v)
52 .and_then(|paths| Some(paths.iter().map(|&v| v).collect()));
53 assert_eq!(expect, &paths);
54 }
55}
56
57#[test]
58fn bfs_paths() {

Callers

nothing calls this directly

Calls 3

create_digraphFunction · 0.85
iterMethod · 0.45
path_toMethod · 0.45

Tested by

no test coverage detected