diff --git a/graphs/even_tree.py b/graphs/even_tree.py index c9aef6e78..92ffb4b23 100644 --- a/graphs/even_tree.py +++ b/graphs/even_tree.py @@ -16,12 +16,12 @@ components containing an even number of nodes. from collections import defaultdict -def dfs(start): +def dfs(start: int) -> int: """DFS traversal""" # pylint: disable=redefined-outer-name ret = 1 visited[start] = True - for v in tree.get(start): + for v in tree[start]: if v not in visited: ret += dfs(v) if ret % 2 == 0: @@ -48,8 +48,8 @@ def even_tree(): if __name__ == "__main__": n, m = 10, 9 tree = defaultdict(list) - visited = {} - cuts = [] + visited: dict[int, bool] = {} + cuts: list[int] = [] count = 0 edges = [(2, 1), (3, 1), (4, 3), (5, 2), (6, 1), (7, 2), (8, 6), (9, 8), (10, 8)] for u, v in edges: