hacktoberfest icon indicating copy to clipboard operation
hacktoberfest copied to clipboard

Added a conditional check for unreachable vertices

Open simran0963 opened this issue 1 year ago • 0 comments

Problem

  • Problem with the condition checking for unreachable vertices

Solution

  • Added a conditional check for vertices that are not reachable

Changes proposed in this Pull Request :

  • 1.
  • added for vertex, distance in shortest_distances.items(): if distance == float('infinity'): print(f'Shortest distance from {start_vertex} to {vertex} is unreachable') else: print(f'Shortest distance from {start_vertex} to {vertex} is {distance}')

simran0963 avatar Oct 11 '24 07:10 simran0963