Sections


Main-Menu

header image

Shortest Path Problem


Shortest Path Problem

Given a connected graph G=(V,E), a weight d:E R+ and a fixed vertex s in V, find a shortest path from s to each vertex v in V.

Dijkstra’s Algorithm:

Dijkstra’s algorithm is known to be a good algorithm to find a shortest path.

1.    Set i=0, S0= {u0=s}, L(u0)=0, and L(v)=infinity for v <> u0. If |V| = 1 then stop, otherwise go to step 2.
2.    For each v in V\Si, replace L(v) by min{L(v), L(ui)+dvui}. If L(v) is replaced, put a label (L(v), ui) on v.
3.    Find a vertex v which minimizes {L(v): v in V\Si}, say ui+1.
4.    Let Si+1 = Si cup {ui+1}.
5.    Replace i by i+1. If i=|V|-1 then stop, otherwise go to step 2.
The time required by Dijkstra’s algorithm is O(|V|2). It will be reduced to O(|E|log|V|) if heap is used to keep {v in V\Si : L(v) < infinity}.


Related Articles :



One Response

  1. michigancarinsurance.info Says:

    michigancarinsurance.info…

    I saw this blog come up on Google reader today, have you……

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.


Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/koolkamp/public_html/engineering-notes-1/wp-content/themes/ankur/footer.php on line 6

Warning: include(http://www.koolkampus.com/commoncode.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/koolkamp/public_html/engineering-notes-1/wp-content/themes/ankur/footer.php on line 6

Warning: include() [function.include]: Failed opening 'http://www.koolkampus.com/commoncode.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/koolkamp/public_html/engineering-notes-1/wp-content/themes/ankur/footer.php on line 6