Skip to content

Commit 6f59e2c

Browse files
Update check_bipatrite.py
1 parent f943bdd commit 6f59e2c

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

graphs/check_bipatrite.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def is_bipartite_dfs(graph: defaultdict[int, list[int]]) -> bool:
5050
>>> is_bipartite_dfs({"a": [1, 3], "b": [0, 2], "c": [1, 3], "d": [0, 2]})
5151
True
5252
>>> is_bipartite_dfs({0: ["b", "d"], 1: ["a", "c"], 2: ["b", "d"], 3: ["a", "c"]})
53-
Traceback (most recent call last):
54-
...
55-
KeyError: 'b'
53+
True
5654
"""
5755

5856
def depth_first_search(node: int, color: int) -> bool:
@@ -132,9 +130,7 @@ def is_bipartite_bfs(graph: defaultdict[int, list[int]]) -> bool:
132130
>>> is_bipartite_bfs({"a": [1, 3], "b": [0, 2], "c": [1, 3], "d": [0, 2]})
133131
True
134132
>>> is_bipartite_bfs({0: ["b", "d"], 1: ["a", "c"], 2: ["b", "d"], 3: ["a", "c"]})
135-
Traceback (most recent call last):
136-
...
137-
KeyError: 'b'
133+
True
138134
"""
139135
visited: defaultdict[int, int] = defaultdict(lambda: -1)
140136
for node in graph:

0 commit comments

Comments
 (0)