(
node_count: int, edge_count: int
)
| 19 | |
| 20 | |
| 21 | def initialize_unweighted_undirected_graph( |
| 22 | node_count: int, edge_count: int |
| 23 | ) -> dict[int, list[int]]: |
| 24 | graph: dict[int, list[int]] = {} |
| 25 | for i in range(node_count): |
| 26 | graph[i + 1] = [] |
| 27 | |
| 28 | for e in range(edge_count): |
| 29 | x, y = (int(i) for i in _input(f"Edge {e + 1}: <node1> <node2> ")) |
| 30 | graph[x].append(y) |
| 31 | graph[y].append(x) |
| 32 | return graph |
| 33 | |
| 34 | |
| 35 | def initialize_weighted_undirected_graph( |