{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
Shortest paths Dasgupta et al. 4.1-4.5 Cormen et al. 24.2-24.3
Background image of page 1

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

View Full Document Right Arrow Icon
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 .
Background image of page 2
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
Background image of page 3

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

View Full Document Right Arrow Icon
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 .
Background image of page 4
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
Background image of page 5

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

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

{[ snackBarMessage ]}