Skip to content

Commit e4f02df

Browse files
Fix visited-node initialization in BFS shortest distance
1 parent 6e03a48 commit e4f02df

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎graphs/breadth_first_search_shortest_path_2.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def bfs_shortest_path_distance(graph: dict, start, target) -> int:
9191
if start == target:
9292
return 0
9393
queue = deque([start])
94-
visited = set(start)
94+
visited = {start}
9595
# Keep tab on distances from `start` node.
9696
dist = {start: 0, target: -1}
9797
while queue:

0 commit comments

Comments
 (0)