2017年5月2日

bellman-ford(可判负权回路+记录路径)

摘要: 4 6 11 2 201 3 54 1 -2002 4 44 2 43 4 2 和: 4 6 11 2 21 3 54 1 102 4 44 2 43 4 2 阅读全文

posted @ 2017-05-02 21:11 远搏 阅读(169) 评论(0) 推荐(0) 编辑

拓扑排序(dfs)

摘要: int c[N];//c[u]=0表示从来没有访问过;c[u]=1表示已经访问过,并且还递归访问过它的所有子;c[u]=-1表示正在访问。 int topo[N],t; int G[N][N]; bool dfs(int u) { c[u]=-1; for(int v=0;v<n;v++) if(G[u][v]) { if(c[v]<0) retu... 阅读全文

posted @ 2017-05-02 20:55 远搏 阅读(115) 评论(0) 推荐(0) 编辑

Dijkstra+优先队列

摘要: /* Dijkstra的算法思想: 在所有没有访问过的结点中选出dis(s,x)值最小的x 对从x出发的所有边(x,y),更新 dis(s,y)=min(dis(s,y),dis(s,x)+dis(x,y)) */ #include #include #include #include using namespace std; const int Ni = 10000; const in... 阅读全文

posted @ 2017-05-02 20:17 远搏 阅读(178) 评论(0) 推荐(0) 编辑

导航