python实现Dijkstra法
1.图:
2.代码:
初始条件: start= 1 S= [{'index': 1, 'val': 0}] dist= [0, 30, 15, 10000, 10000, 10000]结果: S= [{'index': 1, 'val': 0}, {'index': 3, 'val': 15}, {'index': 2, 'val': 25}, {'index': 6, 'val': 30}, {'index': 5, 'val': 40}, {'index': 4, 'val': 50}] dist= [0, 25, 15, 50, 40, 30]