dijkstra graph search algorithm

Post on 14-Jun-2015

131 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Graph Search Algorithm

TRANSCRIPT

PASSAPORN KANCHANASRINANYANG TECHNOLOGICAL UNIVERSITY

Dijkstra Graph Search Algorithm

SHORTEST PATH?

Lesson Outline

Topic: Dijkstra's Graph Search AlgorithmInstructor: Passaporn Kanchanasri

Aim:The aim of this course is to develop students’ abilities to solve the shortest path problem by using Dijkstra's Graph Search Algorithm. The method of Dijkstra's Graph Search Algorithm is to be examined and demonstrated through an example.

Outcomes:If you successfully complete this course you will be able to:- Explain Dijkstra’s algorithm about its methodology, how it works and how it is used to find the shortest path. - Solve the shortest path problem.

Outline Time (minutes)

Introducing Dijkstra's Graph Search AlgorithmDijkstra’s Graph Search Algorithm fundamental concept is introduced by instructor.  

3

Solving the shortest path problem Students are randomly assigned a number either A or B. A student who get A will be paired up with a student who get B. They in pairs then solve the given single source shortest path problem on the whiteboard.  

3

Explaining methodologyStudents explain the methodology how to find an answer.  

3

Concluding a lessonStudents conclude what they learn. Finally the instructor does a wrap up.  

1

QI:Find the shortest path from A to F

A

F

B

C

DE

12

3

1

3

7

6

Dijkstra Graph Search Algorithm

Dijkstra(Graph,source){dist[source] = 0;for each vertex v in Graph

if v !=sourcedist[v] = infinity;previous[v] = undefined;

end ifadd v to Q;

end forwhile Q is not empty

u = vertex in Q with minimum dist[u];remove u from Q;

for each neighbor v of ualt = dist[u] + length(u,v);if alt < dist[v]

dist[v] = alt;previous[v] = u;

enf ifend for

end whilereturn dist[], previous[];

}

QI:Find the shortest path from A to F

A

F

B

C

DE

12

3

1

3

7

6

QII:Find the shortest path from A to F

A

F

B

C

DE

42

3

2

6

3

8

15

3

3

top related