From 6c6902dc25b8b1efdf0f63803d5af8ac5b0d0172 Mon Sep 17 00:00:00 2001 From: tanishqraikwar54-blip Date: Sun, 6 Sep 2026 22:39:16 +0530 Subject: [PATCH] fix: Remove defensive checks in bipartite graph functions --- graphs/check_bipatrite.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/graphs/check_bipatrite.py b/graphs/check_bipatrite.py index 897c78850d58..34bbedfa59fa 100644 --- a/graphs/check_bipatrite.py +++ b/graphs/check_bipatrite.py @@ -67,8 +67,6 @@ def depth_first_search(node: int, color: int) -> bool: """ if visited[node] == -1: visited[node] = color - if node not in graph: - return True for neighbor in graph[node]: if not depth_first_search(neighbor, 1 - color): return False @@ -140,8 +138,6 @@ def is_bipartite_bfs(graph: dict[int, list[int]]) -> bool: visited[node] = 0 while queue: curr_node = queue.popleft() - if curr_node not in graph: - continue for neighbor in graph[curr_node]: if visited[neighbor] == -1: visited[neighbor] = 1 - visited[curr_node]