Skip to content

Commit 630a3ee

Browse files
Update check_bipatrite.py
1 parent 6f59e2c commit 630a3ee

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

graphs/check_bipatrite.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections import defaultdict, deque
22

33

4-
def is_bipartite_dfs(graph: defaultdict[int, list[int]]) -> bool:
4+
def is_bipartite_dfs(graph: dict[int, list[int]]) -> bool:
55
"""
66
Check if a graph is bipartite using depth-first search (DFS).
77
@@ -16,9 +16,9 @@ def is_bipartite_dfs(graph: defaultdict[int, list[int]]) -> bool:
1616
1717
Examples:
1818
19-
>>> is_bipartite_dfs(defaultdict(list, {0: [1, 2], 1: [0, 3], 2: [0, 4]}))
19+
>>> is_bipartite_dfs({0: [1, 2], 1: [0, 3], 2: [0, 4]})
2020
True
21-
>>> is_bipartite_dfs(defaultdict(list, {0: [1, 2], 1: [0, 3], 2: [0, 1]}))
21+
>>> is_bipartite_dfs({0: [1, 2], 1: [0, 3], 2: [0, 1]})
2222
False
2323
>>> is_bipartite_dfs({})
2424
True
@@ -81,7 +81,7 @@ def depth_first_search(node: int, color: int) -> bool:
8181
return True
8282

8383

84-
def is_bipartite_bfs(graph: defaultdict[int, list[int]]) -> bool:
84+
def is_bipartite_bfs(graph: dict[int, list[int]]) -> bool:
8585
"""
8686
Check if a graph is bipartite using a breadth-first search (BFS).
8787
@@ -96,9 +96,9 @@ def is_bipartite_bfs(graph: defaultdict[int, list[int]]) -> bool:
9696
9797
Examples:
9898
99-
>>> is_bipartite_bfs(defaultdict(list, {0: [1, 2], 1: [0, 3], 2: [0, 4]}))
99+
>>> is_bipartite_bfs({0: [1, 2], 1: [0, 3], 2: [0, 4]})
100100
True
101-
>>> is_bipartite_bfs(defaultdict(list, {0: [1, 2], 1: [0, 2], 2: [0, 1]}))
101+
>>> is_bipartite_bfs({0: [1, 2], 1: [0, 2], 2: [0, 1]})
102102
False
103103
>>> is_bipartite_bfs({})
104104
True

0 commit comments

Comments
 (0)