Skip to content

Commit 5699f55

Browse files
Fixes#8098
1 parent 9cfa90e commit 5699f55

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: graphs/check_bipartite_graph_all.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from collections import defaultdict
2+
from queue import Queue
3+
14
""" Check whether Graph is Bipartite or Not using BFS
25
https://www.geeksforgeeks.org/bipartite-graph/
36
Args:
@@ -13,10 +16,8 @@
1316
False
1417
>>> is_bipartite(defaultdict(list, {0: [1, 2], 1: [0, 2], 2: [0, 1]}))
1518
True"""
16-
from queue import Queue
1719

18-
19-
def check_bipartite(graph:Dict[int, List[int]]) -> bool:
20+
def check_bipartite(graph:any) -> bool:
2021
queue = Queue()
2122
visited = [False] * len(graph)
2223
color = [-1] * len(graph)
@@ -54,7 +55,7 @@ def bfs() -> bool:
5455
print(check_bipartite({0: [1, 3], 1: [0, 2], 2: [1, 3], 3: [0, 2]}))
5556

5657

57-
from collections import defaultdict
58+
5859

5960

6061
def is_bipartite(graph: defaultdict[int, list[int]]) -> bool:

0 commit comments

Comments
 (0)