SlideShare uma empresa Scribd logo
1 de 14
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
0
-1
5
6
4
-2
-2
3 3
-1
A B C D E F
0 ∞ ∞ ∞ ∞ ∞
Step - 1
1st Iteration
Selected
Vertices
Example of Bellman Ford : 5
A
D
C
B
E
F
0
-1
5
6
4
-2
-2
3 3
-1
A B C D E F
A 0 ∞ ∞ ∞ ∞ ∞
0 6 4 5 ∞ ∞
Step - 2
Selected
Vertices 1st Iteration
Example of Bellman Ford : 6
A
D
C
B
E
F
0
-1
5
6
4
-2
-2
3 3
-1
A B C D E F
A 0 ∞ ∞ ∞ ∞ ∞
B 0 6 4 5 ∞ ∞
0 6 4 5 5 ∞
Step - 3
Selected
Vertices 1st Iteration
Example of Bellman Ford : 7
A
D
C
B
E
F
0
-1
5
6
4
-2
-2
3 3
-1
A B C D E F
A 0 ∞ ∞ ∞ ∞ ∞
B 0 6 4 5 ∞ ∞
C 0 6 4 5 5 ∞
0 2 4 5 5 ∞
Step - 4
Selected
Vertices 1st Iteration
Example of Bellman Ford : 8
A
D
C
B
E
F
0
-1
5
6
4
-2
-2
3 3
-1
A B C D E F
A 0 ∞ ∞ ∞ ∞ ∞
B 0 6 4 5 ∞ ∞
C 0 6 4 5 5 ∞
D 0 2 4 5 5 ∞
0 2 3 5 5 4
Step - 5
Selected
Vertices 1st Iteration
Example of Bellman Ford : 9
A
D
C
B
E
F
0
-1
5
6
4
-2
-2
3 3
-1
A B C D E F
A 0 ∞ ∞ ∞ ∞ ∞
B 0 6 4 5 ∞ ∞
C 0 6 4 5 5 ∞
D 0 2 4 5 5 ∞
E 0 2 3 5 5 4
0 2 3 5 5 4
Step - 6
Selected
Vertices 1st Iteration
Example of Bellman Ford : 10
A
D
C
B
E
F
0
-1
5
6
4
-2
-2
3 3
-1
A B C D E F
A 0 ∞ ∞ ∞ ∞ ∞
B 0 6 4 5 ∞ ∞
C 0 6 4 5 5 ∞
D 0 2 4 5 5 ∞
E 0 2 3 5 5 4
F 0 2 3 5 5 4
Step - 7
Final
Value
Selected
Vertices 1st Iteration
After 4th iteration we will get:
11
A B C D E F
A 0 1 3 5 0 3
B 0 1 3 5 0 3
C 0 1 3 5 0 3
D 0 1 3 5 0 3
E 0 1 3 5 0 3
F 0 1 3 5 0 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 0 1 3 5 0 3
B 0 1 3 5 0 3
C 0 1 3 5 0 3
D 0 1 3 5 0 3
E 0 1 3 5 0 3
F 0 1 3 5 0 3 Final
Value
THANKS EVERYONE!
14

Mais conteúdo relacionado

Mais procurados

Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithmtaimurkhan803
 
Bellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraqBellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraqmontaser185
 
Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network TalkImane Haf
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]DEEPIKA T
 
Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1SURBHI SAROHA
 
Ant colony opitimization numerical example
Ant colony opitimization numerical exampleAnt colony opitimization numerical example
Ant colony opitimization numerical exampleHarish Kant Soni
 
AI_Session 8 A searching algorithm .pptx
AI_Session 8 A searching algorithm .pptxAI_Session 8 A searching algorithm .pptx
AI_Session 8 A searching algorithm .pptxAsst.prof M.Gokilavani
 
Minimum cost maximum flow
Minimum cost maximum flowMinimum cost maximum flow
Minimum cost maximum flowSaruarChowdhury
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's AlgorithmTanmay Baranwal
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentationAlizay Khan
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic ProgrammingFenil Shah
 
91277687 solution-manual-for-mathematical-modelling-with-case-studies-taylor-...
91277687 solution-manual-for-mathematical-modelling-with-case-studies-taylor-...91277687 solution-manual-for-mathematical-modelling-with-case-studies-taylor-...
91277687 solution-manual-for-mathematical-modelling-with-case-studies-taylor-...Akul Bansal
 

Mais procurados (20)

Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Kruskal’s Algorithm
Kruskal’s AlgorithmKruskal’s Algorithm
Kruskal’s Algorithm
 
Bellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraqBellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraq
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network Talk
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]
 
Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Ant colony opitimization numerical example
Ant colony opitimization numerical exampleAnt colony opitimization numerical example
Ant colony opitimization numerical example
 
AI_Session 8 A searching algorithm .pptx
AI_Session 8 A searching algorithm .pptxAI_Session 8 A searching algorithm .pptx
AI_Session 8 A searching algorithm .pptx
 
12-greedy.ppt
12-greedy.ppt12-greedy.ppt
12-greedy.ppt
 
BFS
BFSBFS
BFS
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
 
Minimum cost maximum flow
Minimum cost maximum flowMinimum cost maximum flow
Minimum cost maximum flow
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
 
Dfs
DfsDfs
Dfs
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
 
91277687 solution-manual-for-mathematical-modelling-with-case-studies-taylor-...
91277687 solution-manual-for-mathematical-modelling-with-case-studies-taylor-...91277687 solution-manual-for-mathematical-modelling-with-case-studies-taylor-...
91277687 solution-manual-for-mathematical-modelling-with-case-studies-taylor-...
 

Bellman-Ford Algorithm.pptx

  • 1. Eastern University Presentation on Bellman-Ford Algorithm  Presented TO  Tanzim Tamanna Shitu  Presented By  Ashik Ahammed Hridoy  ID: 203400003 1
  • 2. 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
  • 3. 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
  • 4. Example of Bellman Ford : 4 A D C B E F 0 -1 5 6 4 -2 -2 3 3 -1 A B C D E F 0 ∞ ∞ ∞ ∞ ∞ Step - 1 1st Iteration Selected Vertices
  • 5. Example of Bellman Ford : 5 A D C B E F 0 -1 5 6 4 -2 -2 3 3 -1 A B C D E F A 0 ∞ ∞ ∞ ∞ ∞ 0 6 4 5 ∞ ∞ Step - 2 Selected Vertices 1st Iteration
  • 6. Example of Bellman Ford : 6 A D C B E F 0 -1 5 6 4 -2 -2 3 3 -1 A B C D E F A 0 ∞ ∞ ∞ ∞ ∞ B 0 6 4 5 ∞ ∞ 0 6 4 5 5 ∞ Step - 3 Selected Vertices 1st Iteration
  • 7. Example of Bellman Ford : 7 A D C B E F 0 -1 5 6 4 -2 -2 3 3 -1 A B C D E F A 0 ∞ ∞ ∞ ∞ ∞ B 0 6 4 5 ∞ ∞ C 0 6 4 5 5 ∞ 0 2 4 5 5 ∞ Step - 4 Selected Vertices 1st Iteration
  • 8. Example of Bellman Ford : 8 A D C B E F 0 -1 5 6 4 -2 -2 3 3 -1 A B C D E F A 0 ∞ ∞ ∞ ∞ ∞ B 0 6 4 5 ∞ ∞ C 0 6 4 5 5 ∞ D 0 2 4 5 5 ∞ 0 2 3 5 5 4 Step - 5 Selected Vertices 1st Iteration
  • 9. Example of Bellman Ford : 9 A D C B E F 0 -1 5 6 4 -2 -2 3 3 -1 A B C D E F A 0 ∞ ∞ ∞ ∞ ∞ B 0 6 4 5 ∞ ∞ C 0 6 4 5 5 ∞ D 0 2 4 5 5 ∞ E 0 2 3 5 5 4 0 2 3 5 5 4 Step - 6 Selected Vertices 1st Iteration
  • 10. Example of Bellman Ford : 10 A D C B E F 0 -1 5 6 4 -2 -2 3 3 -1 A B C D E F A 0 ∞ ∞ ∞ ∞ ∞ B 0 6 4 5 ∞ ∞ C 0 6 4 5 5 ∞ D 0 2 4 5 5 ∞ E 0 2 3 5 5 4 F 0 2 3 5 5 4 Step - 7 Final Value Selected Vertices 1st Iteration
  • 11. After 4th iteration we will get: 11 A B C D E F A 0 1 3 5 0 3 B 0 1 3 5 0 3 C 0 1 3 5 0 3 D 0 1 3 5 0 3 E 0 1 3 5 0 3 F 0 1 3 5 0 3 Final Value Selected Vertices Example of Bellman Ford :
  • 12. Bellman Ford Using JavaScript: 12
  • 13. Bellman Ford Using JavaScript: 13 A B C D E F A 0 1 3 5 0 3 B 0 1 3 5 0 3 C 0 1 3 5 0 3 D 0 1 3 5 0 3 E 0 1 3 5 0 3 F 0 1 3 5 0 3 Final Value