Fix mypy errors at even_tree algo (#4579)

This commit is contained in:
Hasanul Islam 2021-07-29 19:14:35 +06:00 committed by GitHub
parent 40d85d5443
commit a5bcf0f674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: