Dijkstra’s Algorithm
Dijkstra’s Algorithm is a graph traversal algorithm used to find the shortest path from a single source vertex to all other vertices in a weighted graph (non-negative edge weights). It is widely used in network routing and mapping applications and Artificial Intelligence (AI) for pathfinding and optimization problems, providing an efficient way to determine the shortest path in various AI-driven applications.
How Dijkstra's Algorithm Works
- Initialize distances: Set the source node's distance to 0 and all others to ∞.
- Use a priority queue: Pick the node with the smallest known distance.
- Update neighbors: For each neighboring node, update its distance if a shorter path is found.
- Mark node as visited: Once a node's shortest distance is determined, mark it as "processed."
- Repeat until all nodes are processed or the target node is reached.