Hi all,
Really appreciate your help if my function on dijkstra algorithm is correct or wrong? Many thanks...

Function Dijkstra(Graph, source):
Graph randomGraphGenerator = new Graph:
Source V0 = new Source:
for each vertex n in randomGraphGenerator:  // initializations
    weight[n] := infinity                   // Unknown path
                                            // function from source to source
Previous[n] := undefined
        weight[V0] := 0                     // Distance from source to source
    T := copy(randomGraphGenerator)         // All vertices in the graph
                                            // are unoptimized – thus are in T
    While T is not empty:                   // The main Loop

        u := extract_min(T)                 // Remove and return best vertex
                                            // from vertices in two given vertices.
                                            // we would use a path finding algorithm.
                                            // on the new graph, such as depth-first search.

            For each neighbour n of u:      // where n has not yet been removed from T.
alt = weight [u] + length(u, n)
    If alt < weight [n]                      // Relax (u, n)
weight [n] := alt
previous[n] := u
Return previous[]
5 Years
Discussion Span
Last Post by JamesCherrill

Thanks for the reply. That is dijkstra algorithm function (pseudocode). I'm gonna implement java lang code for this algorithm once this function is proper.
Hope this answer to your question.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.