notes23 - Shortest Path Alorithm Weighted Graphs - Graphs...

This preview shows pages 1–2. Sign up to view the full content.

Weighted Graphs - Graphs that contain weights on the edgesthat represent distances, cost etc (chicago) 1846/ | \740 (SF) |800 (NY) / \1464 | \ 337| (Dallas) |1090 \ /1235 \1121 / (LA) (Miami) \____________/ 2342 ____________________________________________________________________________ Dijkstra's Algorithm -finds the shortest path drom a starting vertex to all other vertices in the graph. +the weights have to be non-negative -The algorithm starts by storing in an array D[U] the distance estimated so far from vertex "S" (the starting vertex) to a vertex U. (S) D[U1]/ | \ D[U3] / | \ (U1) | (U3) |D[U2] (U2) -At each step, find the vertex U with minimum distance. (the minimum distance not | yet in shortest path graph). (S) V | \D[U] | \ D[z1]| (U) | / | \ (z1) | \ | \ (z2) (z3) we update the distance D[z1] as: D[z1] = min(D[z1], D[U] + w(U,z1)) new old Algorithm Shortest Path(G,S) Input: A weighted graph G and a starting vertex S. Output: An array D[] such that D[U] is the shortest length from S to U

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue University.

Page1 / 4

notes23 - Shortest Path Alorithm Weighted Graphs - Graphs...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online