C ++中的dijkstra算法 [英] dijkstra algorithm in C++
本文介绍了C ++中的dijkstra算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个dijkstra算法,用于加权无向图.如何重新排列它以计算加权和有向图的最短路径?它在C ++中.参见 http://en.wikipedia.org/wiki/Dijkstra''s_algorithm [ 解决方案
You have more than enough information on this well-known algorithm to implement it in C++. See http://en.wikipedia.org/wiki/Dijkstra''s_algorithm[^].
Now, this article does not mention arcweights
. You can easily modify the algorithm if you need to take it into account. Look at the distance calculation in the pseudocode (seedist
,dist_between
). When you calculate them, multiply each arc''s distance with its weight, that''s all you need.
—SA
这篇关于C ++中的dijkstra算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文