The Dijsktra shortest path algorithm (python)

definition:

Starting position: A

End position: F

Persistent collections: permanent = set ()

Temporarily set: temporary = set ()

 

 

 

 

 

 

 

 

 

A starting position is first added to the permanent collection, and the distance A is set to 0, then A traversing adjacent node [B, C, E], found that the shortest distance A Node B, and B is inserted into the permanent collection , and updates the distance B is 10, the node B is the precursor A.

He did not finish. . First put it, it is a little ignorant.

Guess you like

Origin www.cnblogs.com/xiximayou/p/12075242.html
Recommended