mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +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
|
from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
def dfs(start):
|
def dfs(start: int) -> int:
|
||||||
"""DFS traversal"""
|
"""DFS traversal"""
|
||||||
# pylint: disable=redefined-outer-name
|
# pylint: disable=redefined-outer-name
|
||||||
ret = 1
|
ret = 1
|
||||||
visited[start] = True
|
visited[start] = True
|
||||||
for v in tree.get(start):
|
for v in tree[start]:
|
||||||
if v not in visited:
|
if v not in visited:
|
||||||
ret += dfs(v)
|
ret += dfs(v)
|
||||||
if ret % 2 == 0:
|
if ret % 2 == 0:
|
||||||
|
@ -48,8 +48,8 @@ def even_tree():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
n, m = 10, 9
|
n, m = 10, 9
|
||||||
tree = defaultdict(list)
|
tree = defaultdict(list)
|
||||||
visited = {}
|
visited: dict[int, bool] = {}
|
||||||
cuts = []
|
cuts: list[int] = []
|
||||||
count = 0
|
count = 0
|
||||||
edges = [(2, 1), (3, 1), (4, 3), (5, 2), (6, 1), (7, 2), (8, 6), (9, 8), (10, 8)]
|
edges = [(2, 1), (3, 1), (4, 3), (5, 2), (6, 1), (7, 2), (8, 6), (9, 8), (10, 8)]
|
||||||
for u, v in edges:
|
for u, v in edges:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user