After finding the shortest path, starting with a single SOURCE, we need to start with DESTINATION to undo its predecessor in order to print the path.
Print-Path(G,s,v) { if(v==s) print s; else if (pi[v]==NULL) print "no path from "+s+" to "+v; else{ Print-Path(G,s,pi[v]) print v; } }
the codes above are kindly provided for introduction to the algorithm, MIT press
Daniel
source share