Link State Routing Algorithm PDF
Link State Routing Algorithm PDF
Algorithm
- Abhishek Singh
Example Network
Source Node
A
4
8
7
B D E
3 4
C
Calculating Shortest Paths
1. We will start with source node always. Here, node A is the
source node.
2. Initially, we don’t know the weights or cost, so every
weight is infinity from source.
Nodes
A B C D E
Visited
A 0 ∞ ∞ ∞ ∞
Calculating Shortest Paths...
3. Now starting from node A, B and D are directly connected
with A.
Nodes
A B C D E
Visited
A 0 4 ∞ 8 ∞
Calculating Shortest Paths...
5. Next node will be B. With B, node A and C are connected.
Since, A is already visited, we will only check for node C. But
we will calculate from our source node A. The table will be
updated as follows:
Nodes
A B C D E
Visited
A 0 4 ∞ 8 ∞
A, B 0 4 4+3=7 8 ∞
Calculating Shortest Paths...
5. Next node will be C. With C, node B and D are connected.
Since, B is already visited, we will only check for node D. But
we will calculate from our source node A. The table will be
updated as follows:
Nodes
A B C D E
Visited
A 0 4 ∞ 8 ∞
A, B 0 4 4+3=7 8 ∞
A, B, C 4+3+4=
0 4 7 ∞
11
If we see cost from A to D has direct value of 8. Cost from A to D via B, C will be
11. So, the smaller value will be taken. The last row of table will be updated as,
A, B, C 0 4 7 8 ∞
6. Next node will be D. A, C and E nodes are connected with
D. Starting from source node A. The table will be updated as
follows:
Nodes
A B C D E
Visited
A 0 4 ∞ 8 ∞
A, B 0 4 7 8 ∞
A, B, C
0 4 7 8 ∞
A, B, C, D
0 4 7 8 18
7. Checking for the last node E, there are two paths. From A via B, C, D to E which
we see having cost of 18. Another path is from A via D to E having lower cost of
15. So, the final table will be,
Nodes Visited
A B C D E
A 0 4 ∞ 8 ∞
A, B 0 4 7 8 ∞
A, B, C
0 4 7 8 ∞
A, B, C, D
0 4 7 8 18
A, B, C, D, E
0 4 7 8 15
Dijkstra’s Algorithm
Nodes
A B C D E
Visited
A 0 ∞ ∞ ∞ ∞
New Destination Value = minimum (Old Destination Value, Marked Value + Edge
Weight)
Nodes
A B C D E
Visited
A 0 4 ∞ 8 ∞
Nodes
A B C D E
Visited
A, B 0 4 ∞ 8 ∞
New Destination Value = minimum (Old Destination Value, Marked Value + Edge
Weight)
Nodes
A B C D E
Visited
A, B 0 4 7 8 ∞
Nodes
A B C D E
Visited
A, B 0 4 7 8 ∞
New Destination Value = minimum (Old Destination Value, Marked Value + Edge
Weight)
Nodes
A B C D E
Visited
A, B, C 0 4 7 8 ∞
Nodes
A B C D E
Visited
A, B, C 0 4 7 8 ∞
New Destination Value = minimum (Old Destination Value, Marked Value + Edge
Weight)
Nodes
A B C D E
Visited
A, B, C, D 0 4 7 8 15
Nodes Visited A B C D E
A, B, C, D, E 0 4 7 8 15
Now, these are the shortest path from source A to all nodes respectively using
Dijkstra’s Algorithm.
Dijkstra’s Pseudocode