Suppose there is any graph.
According to the result, I write it into the dictionary and comes out something like that, for example:
{0: {1, 3}, 1: {0, 2}, 2: {1, 3}, 3: {0, 2}}
Point: {Available paths} – respectively.
How to organize the search for the shortest path?
With this feature, I have implemented simply searching the way, but not brief:
def int_path (graph, start, end, path = []):
Path = Path + [Start]
IF Start == End:
Return Path.
IF Not Start In Graph.keys ():
Return none
For Node in Graph [Start]:
If Node Not in Path:
Newpath = Find_Path (Graph, Node, End, Path)
If NEWPath: Return Newpath
Return none
Answer 1, Authority 100%
Looking for the shortest path on the column must be implemented not on the Nativity, but to first familiarize yourself with the relevant theory.
https://ru.wikipedia.org/wiki/zadach_O_Kratchay_Puta
Well, if lazy to learn, then at least on the Internet find how this task is offered to solve others, who was not laziness: