Dijkstra Routing Algorithm
Dijkstra Routing Algorithm
Definition:
Dijkstra's algorithm is a shortest path routing algorithm used in computer networks to find the
minimum cost path from the source node to all other nodes in the network. It is commonly used in
link-state routing protocols like OSPF (Open Shortest Path First).
1. Assign a tentative distance value to every node. Set the distance to the source node as 0 and all
others as infinity.
2. Mark all nodes as unvisited. Set the source node as the current node.
3. For the current node, update the tentative distances of its neighbors.
4. After considering all neighbors, mark the current node as visited.
5. Select the unvisited node with the smallest tentative distance as the new current node.
6. Repeat steps 3-5 until all nodes are visited.
Example:
2
A ------- B
|\ |
1| 4\ |1
| \ |
C ------- D
3
Source node: A
Step-by-Step Table:
- A to B: 2
- A to C: 1
- A to D: 3
Summary:
- Start at A
- Pick the node with the smallest distance next
- Keep updating neighbors until all nodes are visited