0% found this document useful (0 votes)
11 views

Bell Man ford algorithm[2]

The Bellman-Ford algorithm is designed to find the shortest path from a single source vertex to all other vertices in a weighted, directed graph, and it can handle negative weight edges. The algorithm operates with a time complexity of O(V×E) and includes steps for initialization, relaxation of edges, and detection of negative weight cycles. An example illustrates the initialization of distances from the source vertex, with the source set to 0 and all other vertices set to infinity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Bell Man ford algorithm[2]

The Bellman-Ford algorithm is designed to find the shortest path from a single source vertex to all other vertices in a weighted, directed graph, and it can handle negative weight edges. The algorithm operates with a time complexity of O(V×E) and includes steps for initialization, relaxation of edges, and detection of negative weight cycles. An example illustrates the initialization of distances from the source vertex, with the source set to 0 and all other vertices set to infinity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

BELL MAN FORD

ALGORITHM
MADE BY:- SAPTARSHI GHOSH
PRESENTED BY:- ABHAY PANDEY
WHAT IS BELL MAN FORD ALGORITHM

•The Bellman-Ford algorithm finds the shortest path from a single source
vertex to all other vertices in a weighted, directed graph.

•Unlike Dijkstra’s algorithm, Bellman-Ford can handle graphs with negative


weight edges.

•The algorithm can also detect negative weight cycles.


PROBLEM STATEMENT

•Shortest Path Problem:

- Given a graph with vertices and weighted edges, the task is to find the shortest path from
a source vertex to all other vertices.
ALGORITHM OVERVIEW

•Input: A graph G=(V,E)G = (V, E)G=(V,E) with a source vertex S, and edge
weights w(u,v).

•Output: Shortest path from the source vertex S to all other vertices.

•Properties:
•Can detect negative weight cycles.

•Runs in O(V×E) time complexity (where V is the number of vertices and E is


the number of edges).
ALGORITHM STEPS

•Initialization:
-Set the distance to the source vertex S as 0:
dist[s]=0.

-Set the distance to all other vertices as infinity:


dist[v] =∞ for all V≠S .
•Relaxation:

- For each edge (u,v) in the graph, update the distance to v if a shorter path is found via
u:
dist [v]=min⁡( dist[v], dist [u] + w(u,v) )

-Repeat this process for V−1 iterations (where V is the number of vertices in the graph).
•Check for Negative Weight Cycles:

-After V−1 iterations, iterate over all edges again. If any distance can still be updated, a
negative weight cycle exists in the graph.
EXAMPLE:-
Let's consider the source vertex as 'A'; therefore, the
distance value at vertex A is 0 and the distance value at
all the other vertices as infinity shown as below:
THANK YOU

You might also like