Cyber Expr1
Cyber Expr1
OBJECTIVE:- Program to find shortest path for the most efficient route for data travel.
THEORY:- In networking, shortest path algorithms help in determining the most efficient path
for data packets from one node (or device) to another in a network. These algorithms are crucial
for routing in both small and large networks.
(1) Dijkstra's Algorithm:-Dijkstra's algorithm finds the shortest path from a single source vertex
to all other vertices in a graph with non-negative edge weights.
} return min_index;
dist[i] = INT_MAX;
sptSet[i] = 0;
graph[u][v] && dist[u] != INT_MAX && dist[u] + graph[u][v] < dist[v]) { dist[v]
= dist[u] + graph[u][v];
graph[V][V] = {
};
dijkstra(graph, 0);
return 0;
0 0
1 10
2 20
3 40
4 5