struct skt{
int from,to;
double cost;
}edges[1100];
int cnt,n;
bool find_(int s){
int i,j;
double d[110];
for(i=0;i<=100;i++)
d[i]=0;
d[s]=1;
for(i=0;i<n;i++){
for(j=0;j<cnt;j++){
skt e=edges[j];
if(d[e.to]>d[e.from]+e.cost){
d[e.to]=d[e.from]+e.cost;
if(i==n-1)
return true;
}
}
}
return false;
}
Bellman-Ford 算法判是否有负权环
最新推荐文章于 2022-12-11 11:25:01 发布