2021
09-24
09-24
c++ Bellman-Ford算法的具体实现
Bellman-Ford算法用于解决有边数限制的最短路问题,且可以应对有负边权的图其时间复杂度为O(nm),效率较低代码实现:#include<iostream>#include<cstring>#include<algorithm>#defineinf0x3f3f3f3fusingnamespacestd;constintN=1e4+10;constintM=510;intm,n,k,dis[M],backup[M];//m条边,n个点,在1号点到n号点之间找到一条经过小于等于k条边的通路//dis:各点到源点的距离,backup:备份structNode{intx,y,v;}edge[N...
继续阅读 >