The document discusses shortest path algorithms. It describes Bellman-Ford algorithm, which finds the shortest path from a source vertex to all other vertices in a weighted graph. It also discusses single-source shortest path problems, which aim to find the shortest path between two vertices in a graph where the total edge weight is minimized. Finally, it describes all-pairs shortest path problems, which determine the shortest distance between every pair of vertices in a graph.
2. SHORTEST –PATH ALGORITHS
Bellmen ford’s algorithms is used to find the
shortest from the source vertex to all other vertices
in a weighted graph it depences
The shortest path problem is about finding a
path between 2 vertices in a graph such that
total sum
the edge weight is minimum
the problem could be solued easily using (BFS)
if all edge
wegihts wer 1 but can takes any values 3
different algroithms
4. SINGEL SOURCE SHORTEST PROBLEM
The shortest weighted path from v1 to v6 has & cost of 6 and v1to v4 to v7
to v6 the shortest unweight path vertices is 2 .
EXMPLE:
path from vertex A to B has minimum cost of 4 the route is
[A->E->B]
vertex A to vertex c has route is
[A->E->B->C]
path from vertex A to vertex D has minimum cost of 5 & the route is
[A->E->D]
Path form vertex cost of 3 the route is
[A->E]
6. SINGLE PATH
• INPUT: A weighted directed graph
G=(V,E)
OUTPUT: A N XN matrix of shortest distance
&&(i) the weight shortest path
1
3
5 4
2
1 2 3 4 5
1 0 1 -3 2 2
2 3 0 -4 2 4
3 3 4 0 3
4 2 -1 -5 4
5 8 5 1 0
7. UNWEIGHT SHORTEST PATH
• Unweight path some shortest problem all edges
have the length for example we may be triying to
find the shortest input ,output of maze
• each cell in the maze in a noode and an edge
connect s to w noodes is move single
• DIFINITION: The single source shortest path
problem is task of finding for graph G=(V,E) and
vertix
• v₤v the shortest path v all other
9. NEGATIVE EDGE IS AN EDGE
• A negative edge is an edge having a negative
weight it could be an any context pertaining
to the graph and edge floydwareshall works by
minizing the weidht
•
1
2
0
6
3
5
4 0 1 2 3 4 5 6
1 0 6 5 5 0 0 0
2 0 3 3 5 5 4 4
3 0 3 3 5 2 4 5
4 0 2 3 5 0 4 2
5 0 2 3 5 0 4 3
6 0 2 0 5 0 4 0
10. THE All PAIR SHOTREST PATH
• The all pair shortest path problem is the determination of
the shortest graph distance better every pair of vertices in
a graph vertices
min {w(p)} there is path p from {w(p)} p there path
shortest put verter u
the all pair shortest p is a determination a matrix
A matrix A such the l(i) is length of shortest I and j
Input given a matrix
wg= {0,iji-j} w(i)j if (i,j)₤E ∞ 𝑖𝑓 𝑖, 𝑗 £
output is an min matrix D
d[ij]where dil is the shortest path from