mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
Fix mypy errors at even_tree algo (#4579)
This commit is contained in:
parent
40d85d5443
commit
a5bcf0f674
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user