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

Function dfs_paths

tests/test_undirected_graph.rs:69–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67
68#[test]
69fn dfs_paths() {
70 let graph = create_graph(TINY_CG);
71 let paths = DepthFirstPaths::new(graph.as_ref(), 0);
72 for (v, expect) in vec![
73 Some(vec![0usize]), // 0
74 Some(vec![0, 2, 1]), // 1
75 Some(vec![0, 2]), // 2
76 Some(vec![0, 2, 3]), // 3
77 Some(vec![0, 2, 3, 4]), // 4
78 Some(vec![0, 2, 3, 5]), // 5
79 ]
80 .iter()
81 .enumerate()
82 {
83 let paths: Option<Vec<usize>> = paths
84 .path_to(v)
85 .and_then(|paths| Some(paths.iter().map(|&v| v).collect()));
86 assert_eq!(expect, &paths);
87 }
88}
89
90#[test]
91fn bfs_paths() {

Callers

nothing calls this directly

Calls 3

create_graphFunction · 0.70
iterMethod · 0.45
path_toMethod · 0.45

Tested by

no test coverage detected