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

Function parser

tests/test_undirected_graph.rs:11–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10#[test]
11fn parser() {
12 //test strip
13 assert_eq!("abc".strip_suffix("\n"), None);
14 assert_eq!("abc\n".strip_suffix("\n"), Some("abc"));
15
16 //test parser
17 let i = TINY_G;
18 let i = i.strip_suffix("\n").unwrap_or(i);
19 let graph = Graph::from(i);
20 assert_eq!(graph.V(), 13);
21 assert_eq!(graph.E(), 13);
22
23 let expect = vec![6, 2, 1, 5];
24 let adj0 = graph.adj(0);
25 for (i, w) in adj0.enumerate() {
26 assert_eq!(*w, expect[i]);
27 }
28
29 assert_eq!(graph.degree(0), 4);
30 assert_eq!(graph.degree(1), 1);
31
32 /*
33 13 vertices, 13 edges
34 0: 6 2 1 5
35 1: 0
36 2: 0
37 3: 5 4
38 4: 5 6 3
39 5: 3 4 0
40 6: 0 4
41 7: 8
42 8: 7
43 9: 11 10 12
44 10: 9
45 11: 9 12
46 12: 11 9
47 */
48 // println!("{}", graph.to_string());
49}
50
51#[test]
52fn dfs() {

Callers

nothing calls this directly

Calls 1

adjMethod · 0.45

Tested by

no test coverage detected