nbsp;initialvector();
intfrom,to;
doublew;
while(in>>from>>to>>w){
weight[from][to]=w;
path[from][to]=from;\/\/to的前继是from
weight[from][from]=0;\/\/自身到自身的权重为0
path[from][from]=from;
weight[to][to]=0;
path[to][to]=to;
}
}
voidfloyd(){
for(intk=0;k<vertexnum;k++)
for(inti=0;i<vertexnum;i++)
for(intj=0;j<vertexnum;j++){
if((weight[i][k]>0weight[k][j]weight[i][k]<intmaxweight[k][j]<intmax)(weight[i][k]+weight[k][j]<weight[i][j])){\/\/前面一部分是防止加法溢出
weight[i][j]=weight[i][k]+weight[k][j];
path[i][j]=path[k][j];
}
}
}
voiddisplaypath(intsource,intdest){
stack<int>sh
记录三百六十八 不小心落水了[2/2页]