根据 data 构建图
(data: [[usize;2];20])
| 71 | |
| 72 | // 根据 data 构建图 |
| 73 | fn build_graph(data: [[usize;2];20]) -> Vec<(Graph, usize)> { |
| 74 | let mut graphs: Vec<(Graph, usize)> = Vec::new(); |
| 75 | |
| 76 | for _ in 0..9 { |
| 77 | graphs.push((Graph::new(), 0)); |
| 78 | } |
| 79 | |
| 80 | for i in 1..9 { |
| 81 | for j in 0..data.len() { |
| 82 | if data[j][0] == i { |
| 83 | graphs[i].0.insert(data[j][1]); |
| 84 | } |
| 85 | } |
| 86 | print!("[{i}]->"); |
| 87 | graphs[i].0.print_node(); |
| 88 | } |
| 89 | |
| 90 | graphs |
| 91 | } |
| 92 | |
| 93 | fn bfs(graph: Vec<(Graph, usize)>) { |
| 94 | let mut gp = graph; |
no test coverage detected