关键路径 求vl
fill(vl,vl+n,ve[n-1]);
while(!toporder.empty()) {
int u=toporder.top();
toporder.pop();
for(int i=0; i<G[u].size(); i++) {
if(vl[G[u][i].v]-G[u][i].w<vl[u]) {
vl[u]=vl[G[u][i].v]-G[u][i].w;
}
}
}
fill(vl,vl+n,ve[n-1]);
while(!toporder.empty()) {
int u=toporder.top();
toporder.pop();
for(int i=0; i<G[u].size(); i++) {
if(vl[G[u][i].v]-G[u][i].w<vl[u]) {
vl[u]=vl[G[u][i].v]-G[u][i].w;
}
}
}
相关推荐