Skip to content

Commit c9ae6f1

Browse files
poyeacclauss
andauthored
Change to get() from dictionary
Co-Authored-By: Christian Clauss <[email protected]>
1 parent 53a49d7 commit c9ae6f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

graphs/breadth_first_search_shortest_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def shortest_path(self, target_vertex):
3636
"""
3737
if target_vertex == self.source_vertex:
3838
return f"{self.source_vertex}"
39-
elif target_vertex not in self.parent or not self.parent[target_vertex]:
39+
elif not self.parent.get(target_vertex):
4040
return f"No path from vertex:{self.source_vertex} to vertex:{target_vertex}"
4141
else:
4242
return self.shortest_path(self.parent[target_vertex]) + f"->{target_vertex}"

0 commit comments

Comments
 (0)