Bellman-Ford Algorithm.pptx

92 views 14 slides Jan 07, 2023
Slide 1
Slide 1 of 14
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14

About This Presentation

Bellman ford Algorithm


Slide Content

Eastern University Presentation on Bellman-Ford Algorithm Presented TO Tanzim Tamanna Shitu Presented By Ashik Ahammed Hridoy ID: 203400003 1

What is Bellman-Ford? Bellman Ford algorithm helps us find the shortest path from a vertex to all other vertices of a weighted graph. It is similar to Dijkstra's algorithm but it can work with graphs in which edges can have negative weights. 2

Example of Bellman Ford : 3 Relaxation: If {d(u) + c(u , v) < d(u)} d(v) = d(u) + c (u , v) Iteration: (n – 1) [n : no. of vertices] (6 – 1) = 5 times A D C B E F

Example of Bellman Ford : 4 A D C B E F -1 5 6 4 -2 -2 3 3 -1 A B C D E F ∞ ∞ ∞ ∞ ∞ Step - 1 1 st Iteration Selected Vertices

Example of Bellman Ford : 5 A D C B E F -1 5 6 4 -2 -2 3 3 -1 A B C D E F A ∞ ∞ ∞ ∞ ∞ 6 4 5 ∞ ∞ Step - 2 Selected Vertices 1 st Iteration

Example of Bellman Ford : 6 A D C B E F -1 5 6 4 -2 -2 3 3 -1 A B C D E F A ∞ ∞ ∞ ∞ ∞ B 6 4 5 ∞ ∞ 6 4 5 5 ∞ Step - 3 Selected Vertices 1 st Iteration

Example of Bellman Ford : 7 A D C B E F -1 5 6 4 -2 -2 3 3 -1 A B C D E F A ∞ ∞ ∞ ∞ ∞ B 6 4 5 ∞ ∞ C 6 4 5 5 ∞ 2 4 5 5 ∞ Step - 4 Selected Vertices 1 st Iteration

Example of Bellman Ford : 8 A D C B E F -1 5 6 4 -2 -2 3 3 -1 A B C D E F A ∞ ∞ ∞ ∞ ∞ B 6 4 5 ∞ ∞ C 6 4 5 5 ∞ D 2 4 5 5 ∞ 2 3 5 5 4 Step - 5 Selected Vertices 1 st Iteration

Example of Bellman Ford : 9 A D C B E F -1 5 6 4 -2 -2 3 3 -1 A B C D E F A ∞ ∞ ∞ ∞ ∞ B 6 4 5 ∞ ∞ C 6 4 5 5 ∞ D 2 4 5 5 ∞ E 2 3 5 5 4 2 3 5 5 4 Step - 6 Selected Vertices 1 st Iteration

Example of Bellman Ford : 10 A D C B E F -1 5 6 4 -2 -2 3 3 -1 A B C D E F A ∞ ∞ ∞ ∞ ∞ B 6 4 5 ∞ ∞ C 6 4 5 5 ∞ D 2 4 5 5 ∞ E 2 3 5 5 4 F 2 3 5 5 4 Step - 7 Final Value Selected Vertices 1 st Iteration

After 4 th iteration we will get: 11 A B C D E F A 1 3 5 3 B 1 3 5 3 C 1 3 5 3 D 1 3 5 3 E 1 3 5 3 F 1 3 5 3 Final Value Selected Vertices Example of Bellman Ford :

Bellman Ford Using JavaScript: 12

Bellman Ford Using JavaScript: 13 A B C D E F A 1 3 5 3 B 1 3 5 3 C 1 3 5 3 D 1 3 5 3 E 1 3 5 3 F 1 3 5 3 Final Value

THANKS EVERYONE! 14