摘要:
今天介绍一种计算单源最短路径的算法Bellman-Ford算法,对于图G=(V,E)来说,该算法的时间复杂度为O(VE),其中V是顶点数,E是边数。Bellman-Ford算法适用于任何有向图,并能报告图中存在负环路(边的权重之和为负数的环路,这使得图中所有经过该环路的路径的长度都可以通过反复行走该 阅读全文
摘要:
1 //program 2-1 2 #include 3 #include 4 const int N=1000005; 5 using namespace std; 6 7 double w[N]; //古董的重量数组 8 int main() 9 { 10 double c; 11 int n; 12 cout>c>>n; 14 cou... 阅读全文
摘要:
1 // 2 // Created by alim on 2017/12/23. 3 // 4 5 #include 6 #include //求绝对值函数需要引入该头文件 7 using namespace std; 8 const int M=1000+5; 9 double c[M][M],w[M][M],p[M],q[M]; 10 int s[... 阅读全文