# 03 - Dijkstras Algorithm Design and Analysis of Algorithms...

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

Dijkstra’s Algorithm Design and Analysis of Algorithms Andrei Bulatov

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

View Full Document
Algorithms – Dijkstra’s Algorithm 3-2 Shortest Path Suppose that every arc e of a digraph G has length (or cost, or weight, or …) len(e) Then we can naturally define the length of a directed path in G, and the distance between any two nodes The s-t-Shortest Path Problem Instance : Digraph G with lengths of arcs, and nodes s,t Objective : Find a shortest path between s and t
Algorithms – Dijkstra’s Algorithm 3-3 Single Source Shortest Path The Single Source Shortest Path Problem Instance : Digraph G with lengths of arcs, and node s Objective : Find shortest paths from s to all nodes of G Greedy algorithm: Attempts to build an optimal solution by small steps, optimizing locally, on each step

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

View Full Document
Algorithms – Dijkstra’s Algorithm 3-4 Dijkstra’s Algorithm Input : digraph G with lengths len, and node s Output : distance d(u) from s to every node u Method : let S be the set of explored nodes for each v S let d(v) be the distance from s to v set S:={s} and d(s):=0 while S V do pick a node v not from S such that the value is minimal set S:=S {v}, and d(v):=d’(v) endwhile )} ( ) ( { min : ) ( ' ), , ( e len u d v d S u v u e + = =
Algorithms – Dijkstra’s Algorithm 3-5 Example s b a e g c 1 2 4 3 2 2 1 1 3

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

View Full Document
Algorithms – Dijkstra’s Algorithm 3-6 Questions What if G is not connected? there are vertices unreachable from s? How can we find shortest paths from s to nodes of G?
Algorithms – Dijkstra’s Algorithm 3-7 Dijkstra’s Algorithm Input : digraph G with lengths len, node s Output : distance d(u) from s to every node u and predecessor P(u) in the shortest path Method : set S:={s}, d(s):=0, and P(s):=null while S V do pick a node v not from S such that the value is minimal set S:=S {v} and d(v):=d’(v) set P(v):= u (providing the minimum) endwhile )} ( ) ( { min : ) ( ' ), , ( e len u d v d S u v u e + = =

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

View Full Document
Algorithms – Dijkstra’s Algorithm 3-8 Dijkstra’s Algorithm Analysis: Soundness Theorem For any node v the path s, … P(P(P(v))), P(P(v)), P(v), v is a shortest s – v path Method: Algorithm stays ahead
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 28

03 - Dijkstras Algorithm Design and Analysis of Algorithms...

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

View Full Document
Ask a homework question - tutors are online