您的位置:首页 > 大数据 > 人工智能

2011-02-28 CLRS Chapter25 All-Pairs Shortest Paths 每对顶点间的最短路径

2011-03-05 15:31 537 查看
//打印出从顶点i到顶点j的一条最短路径,Π是前驱矩阵πij表示从i到顶点j的一条最短路径上j的前驱

PRINT-ALL-PAIRS-SHORTEST-PATH(Π, i, j)
1  if i = j
2    then print i
3    else if πij = NIL
4         then print "no path from" i "to" j "exists"
5         else PRINT-ALL-PAIRS-SHORTEST-PATH(Π, i, πij)
6                     print j



 

The Floyd-Warshall algorithm





Transitive closure of a directed graph





Johnson's algorithm for sparse graphs


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  algorithm path