{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture_06

# lecture_06 - Shortest paths Dasgupta et al 4.1-4.5 Cormen...

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

Shortest paths Dasgupta et al. 4.1-4.5 Cormen et al. 24.2-24.3

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

View Full Document
Shortest Paths in a Graph Input: square4 A directed graph G = (V, E), each edge e is associated with a positive weight (length), denoted w(e). square4 Source s , destination t . 2 Shortest path problem : Find a shortest (total length) directed path from s to t . NB. The total length of this path is called the shortest distance from s to t .
Shortest Paths: simple case Simple case. Assume that w(e) = 1 for all edges e. Use breath first search . u w 1 1 3 s u v w x t Shortest distance from s to t = 2. s v t x 1 1 1 1 1 1 1 1 1

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

View Full Document
Arbitrary edge weights. For any node u, let d(u) be the shortest distance from s to u. The appraoch . Step 1. Find the node u such that d(u) is the smallest. 4 Step 2. Find the node w such that d(w) is the next smallest. Step 3. Repeat the steps until we encounter the node t .
Example u w t 5 3 6 1 1 d(v) = 2 d(u) = 4 d(x) = 6 d(w) =6 d(t) = 7 5 s v x 6 2 2 5 4 2

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

View Full Document
Dijkstra's algorithm Maintain a set of visited nodes S for which we have determined the shortest distance d(u) from s to u.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}