shortest path algorithm
Post on 11-Apr-2017
516 Views
Preview:
TRANSCRIPT
Shortest Path Problem
• Given: network topology with link costs– c(x , y): link cost from node x to node y– Infinity if x and y are not direct neighbors
• Compute: least-cost paths to all nodes– From a given source u to all other nodes.
3
2
1
14
1
4
5
3
2
A
B
C
D E
F
G
H
Subrata paul
Roll No :- 13015411. Department Of Computer Science & Engineering ,
University Of Rajshahi.
Shortest Path Routing
What Is Routing ?? •A famous quotation from RFC 791
“A name indicates what we seek.An address indicates where it is.A route indicates how we get there.” -- Jon Postel
• Routing is the process of selecting best paths.
Goals Of Routing Algorithm
• We want any several properties of any routing schema.
Property Meaning
Correctness Finds paths that work
Efficient Paths Use network bandwidth well
Fair Paths Doesn’t starve any nodes
Fast Convergence Recovers quickly after changes
Salability Works well as network grows large
What Are The Best Paths ??
• Many Possibilities :- - Latency, avoid circuitous paths.- Bandwidth, avoid slow links .- Money, avoid expensive links .- Hops, reduce switching .
A
BC
DE
F
G
Shortest Paths (1)
• Find the shortest path from A E.• All links are bidirectional , with equal cost in
both direction.
Shortest Path(2)
• ABCE is a shortest path• Dist(ABCE) = 4 + 2 + 1 = 7• This is less than : - Dist(ABE) = 8 - Dist(ABFE) = 9 - Dist(AE) = 10 - Dist(ABCDE) = 10
How To Compute ??
• Using Dijkstra’s Algorithm :- - Given a network topology . We are about to
compute shortest path from a source to all other nodes of the network.
Dijkstra’s Algorithm
• Algorithm :- - Mark all nodes tentative , set distances from source to 0(Zero)
for source and ∞(infinity) for all other nodes
- While tentative nodes remain : a ) Extract N , a node with lowest distance b) Add link to N to the shortest path tree C) Relax the distances of neighbors of N by lowering any
better distance estimates
Dijkstra’s AlgorithmA B C D E F G H
0 ∞ ∞ ∞ ∞ ∞ ∞ ∞
Dijkstra’s AlgorithmA B C D E F G H
0 4 ∞ ∞ 10 ∞ ∞ ∞
Dijkstra’s AlgorithmA B C D E F G H
0 4 6 ∞ 8 7 7 ∞
Dijkstra’s AlgorithmA B C D E F G H
0 4 6 8 7 7 7 9
Dijkstra’s AlgorithmA B C D E F G H0 ∞ ∞ ∞ ∞ ∞ ∞ ∞A B C D E F G H
0 4 6 8 7 7 7 9
Dijkstra’s AlgorithmA B C D E F G H0 ∞ ∞ ∞ ∞ ∞ ∞ ∞A B C D E F G H
0 4 6 8 7 7 7 9
Dijkstra’s AlgorithmA B C D E F G H0 ∞ ∞ ∞ ∞ ∞ ∞ ∞A B C D E F G H
0 4 6 8 7 7 7 9
Dijkstra’s AlgorithmA B C D E F G H0 ∞ ∞ ∞ ∞ ∞ ∞ ∞A B C D E F G H
0 4 6 8 7 7 7 9
Dijkstra’s AlgorithmA B C D E F G H0 ∞ ∞ ∞ ∞ ∞ ∞ ∞A B C D E F G H
0 4 6 8 7 7 7 9
All nodes are done now.
Dijkstra’s Algorithm • So , the shortest path from source node A to all
other nodes are –A – B = 4A – C = 6A – D = 8A – E = 7A – F = 7A – G = 7A – H = 9
Conclusion • Routing is a distributed algorithm
– React to changes in the topology– Compute the shortest paths
• Two main shortest-path algorithms– Dijkstra– Bellman-Ford
• Convergence process– Changing from one topology to another– Transient periods of inconsistency across routers
top related