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: s A directed graph G = (V, E), each edge e is associated with a positive weight (length), denoted w(e). s 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 5 3 1 1 d(v) = 2 d(u) = 4 d(x) = 6 d(w) =6 (t) = 7 5 s v t x 6 2 2 6 5 4 2 d(t) = 7

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. Initialize
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 03/01/2010 for the course CS 1234 taught by Professor Chan during the Spring '10 term at University of the Bío-Bío.

### Page1 / 14

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

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

View Full Document
Ask a homework question - tutors are online