c++ - Modifying Dijkstra's algorithm to print the nodes in the shortest path -


I'm thinking how can I modify this function to save the last small path of nodes. This is with minor modifications from my textbook.

  template & lt; Class vType, int size & gt; Zero-weighted GraphType & lt; VType, Size & gt; :: short path (vType vertex) {int i, j; Double Minveite; For (J = 0; J & L; GSIAZ; J ++) {Smallest paneling [J] = weight [top] [J]; } Bool weight pounds [size]; For (j = 0; j & lt; gcise; j ++) {weight [j] = wrong; } (I = 0; i & lt; gSize; i ++) {int v; Cout & lt; & Lt; Header & lt; & Lt; "From" & lt; & Lt; I & lt; & Lt; Endl; MinWeight = INFINITY; For (J = 0; J & LT; GSIAZ; J ++) {if (!!!! ([!] (If the (the smallest [J]    

Here is an indication: for each node, you know that You have the smallest weight to reach. You may also know that "the smallest way to reach this node" came before killing this node.

Comments