This is my first question, and for the first time I tried to do it, but I read the rules of the questions, and I hope that my question will correspond to all of them.
I have a project for my algorithm object, and it should create a gui for the shortest path dijkstra algorthim. I decided to use python because it is a language that I would like to learn. I have been trying for more than a week, and I always run into problems. But in any case, this is good fun :)!
I decided to present my oriented 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
therefore, the key is the top, and the value is the associated vets and weights. This is an example of a graph, but I planned to ask the user to enter their own graph data and study the shortest path between the two nodes [start β end]. However, the problem is that I donβt even know how to access the internal dictionary, so I can work with the internal parameters, and I tried many ways like these two:
for i in g: counter = 0 print g[i[counter]]
but both give me the same result as: (Please note that I cannot access and play with internal parameters)
{"B": 20, 'D': 80, 'G' :90} {'F' : 10} {'C':10,'D':40} {'D':10,'H':20,'F':50} {'G':20} {'A':20} {'G':30,'B':50} None
So my question is: could you help me access the internal dictionaries so that I can start working on the algorithm itself. Thanks a lot in advance and thanks for reading.