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

    技术2022-05-19  24

    //打印出从顶点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


    最新回复(0)