Nowitlookslike15

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: twork. – Directed graph G = (V, E). – Source s, destination t. – Length we = length of edge e. s Applications: • GIS routing • Google Maps, Mapquest • Routing in communication networks Shortest path problem: find shortest directed path from s to t. cost of path = sum of edge costs in path 23 2 9 3 18 14 5 30 11 5 5 16 20 7 6 2 6 44 19 4 6 t Cost of path s­2­3­5­t = 9 + 23 + 2 + 16 = 48. Greedy Approach Greedy Approach 100 A B 1 10 C F 1 1 5 s 10 E 1 D 6 100 G Fails Miserably t 1 Let’s be careful… Let 1 A 1 0 s t 10 C The shortest path to s has weight 0. The shortest path to A must have weight 1 (why)? The shortest path to C must have weight 10 ?? NO! could have A­­>C of cost 1 Let’s be careful… Let 1 A 100 101 B 1 0 s t 10 C 10 NOW LOOK AT EDGES COMING OUT OF {s, A} CONCLUDE: shortest path to C must be 10 Let’s be careful… Let 1 100 A 101 15 B 1 0 5 s 10 C 10 t 1 D 11 NOW LOOK AT EDGES COMING OUT OF {s, A, C} A moment ago we thought path to B cost 101. Now it looks like 15… But ­ is that the smallest?? Might not be. Note “15”, but don’t circle B yet Let’s be careful… Let 1 100 A 15 B 1 0 5 s 10 C 10 t 1 D 11 If all edges coming out of {s, A, C } are shown, can we write down the shortest distance to S...
View Full Document

This document was uploaded on 04/02/2014.

Ask a homework question - tutors are online