Bellman-Ford algorithm.pptx which a very usefull ppt to learn this algorithm

hiremathprerana 18 views 36 slides Jul 07, 2024
Slide 1
Slide 1 of 36
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
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36

About This Presentation

algorithm


Slide Content

Bellman-Ford algorithm

Bellman-Ford algorithm   The  Bellman-Ford algorithm  is an extension of  Dijkstra’s algorithm  which calculates the shortest distance from the source point to all of the vertices. While Dijkstra’s algorithm just works for edges with positive distances, the Bellman-Ford algorithm works for negative distances as well.

List down all the edges of the graph. This can be done easily if the graph is represented by an adjacency list. Calculate the number of iterations with “V - 1”. The number of iterations will be equal to the number of vertices because the shortest distance to an edge can be adjusted V - 1 times at maximum. Start with an arbitrary vertex and assign it the minimum distance of zero. All other nodes should be assigned infinity since we are exaggerating the actual distances. In each iteration, update the distance for each edge if the new distance is smaller than the one assigned before. The distance to each node will be the cumulative distance from the starting node to this particular node. We need to consider all the iterations to make sure that all ​possible paths are considered. If we do this, we will end up with the shortest distance. Algorithm

Uses of the Bellman-Ford algorithm The Bellman-Ford algorithm has several real-world use cases, including: Finding negative weight cycles. Calculating the smallest possible heat gain/loss in a chemical reaction. Finding the most efficient way to convert currencies.

Pass-1

Pass-2

Weight of the graph is equal to the weight of its edges. So, weight = 3 + 2 + (-6) = -1 Negative value, so we have a negative cycle
Tags