From e4f02dfbc619f08682730a2e11c79fc49e81dfce Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Fri, 23 Oct 2026 21:46:20 +0530 Subject: [PATCH] Fix visited-node initialization in BFS shortest distance --- graphs/breadth_first_search_shortest_path_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/breadth_first_search_shortest_path_2.py b/graphs/breadth_first_search_shortest_path_2.py index efba9b7b6ae6..973256bae1e7 100644 --- a/graphs/breadth_first_search_shortest_path_2.py +++ b/graphs/breadth_first_search_shortest_path_2.py @@ -91,7 +91,7 @@ def bfs_shortest_path_distance(graph: dict, start, target) -> int: if start == target: return 0 queue = deque([start]) - visited = set(start) + visited = {start} # Keep tab on distances from `start` node. dist = {start: 0, target: -1} while queue: