[go: up one dir, main page]

0% found this document useful (0 votes)
128 views17 pages

Link State Routing Algorithm PDF

The document describes the Dijkstra's algorithm for calculating shortest paths in a graph. It provides an example network with nodes A through E and edge weights. It then walks through the steps of the algorithm, starting at the source node A and calculating the shortest path to each neighboring node. The distance values are updated in a table until the shortest paths from A to all other nodes have been determined.

Uploaded by

Abhishek Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views17 pages

Link State Routing Algorithm PDF

The document describes the Dijkstra's algorithm for calculating shortest paths in a graph. It provides an example network with nodes A through E and edge weights. It then walks through the steps of the algorithm, starting at the source node A and calculating the shortest path to each neighboring node. The distance values are updated in a table until the shortest paths from A to all other nodes have been determined.

Uploaded by

Abhishek Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Link State Routing

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.

4. So cost of node A to A will be zero and B and D are given.


The table will be updated as follows:

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)

Node B = minimum (∞, 0 + 4) = minimum (∞, 4) = 4

Node D = minimum (∞, 0 + 8) = minimum (∞, 8) = 8

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)

Node C = minimum (∞, 4 + 3) = minimum (∞, 7) = 7

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)

Node D = minimum (8, 7 + 4) = minimum (8, 11) = 8

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)

Node E = minimum (∞, 8 + 7) = minimum (∞, 15) = 15

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

You might also like