Skip to content

Commit 541eec8

Browse files
Update check_bipatrite.py
1 parent 8552594 commit 541eec8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

graphs/check_bipatrite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def is_bipartite_bfs(graph: defaultdict[int, list[int]]) -> bool:
160160
visited[node] = 0
161161
while queue:
162162
curr_node = queue.popleft()
163+
if curr_node not in graph:
164+
continue
163165
for neighbor in graph[curr_node]:
164166
if visited[neighbor] == -1:
165167
visited[neighbor] = 1 - visited[curr_node]

0 commit comments

Comments
 (0)