on-internet
← Community

Shortest path algorithm using dictionaries

Stack Overflow ·

I have a project for my algorithm subject to design a GUI for Dijkstra's shortest path algorithm. I chose to use Python because it is a language that I would like to master. I have been trying for more than a week actually and am facing troubles all the way. I chose to represent my directed graph as a dictionary in this way: g= {'A': {"B": 20, 'D': 80, 'G' :90}, # A can direct to B, D and G 'B': {'F' : 10}, 'F':{'C':10,'D':40}, 'C':{'D':10,'H':20,'F':50}, 'D':{'G':20}, 'G':{'A':20}, 'E':{'G':30,'B':50}, 'H':None} # H is not directed to anything, but can accessed through C The key is the vertic

Comments

Sign in or sign up to comment and upvote.

No comments yet.