Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dijkstra’s Algorithm Notation:  c(x,y): link cost from node x to y; = ∞ if not direct neighbors  D(v): current value of cost of path from source to dest.

Similar presentations


Presentation on theme: "Dijkstra’s Algorithm Notation:  c(x,y): link cost from node x to y; = ∞ if not direct neighbors  D(v): current value of cost of path from source to dest."— Presentation transcript:

1 Dijkstra’s Algorithm Notation:  c(x,y): link cost from node x to y; = ∞ if not direct neighbors  D(v): current value of cost of path from source to dest. v  p(v): predecessor node along path from source to v  N': set of nodes whose least cost path definitively known Data structures: r Path m An ordered sequence of nodes m a cost to reach the end of the path The sum of each lonk cost along the path r Candidate paths (CP)  Shortest paths (SP)

2 Dijsktra’s Algorithm Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop

3 Dijsktra’s Algorithm from Router A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Least costs paths Cost Candidate paths Cost A 0 Initialization (Steps 2-3) Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop

4 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 Step 5 Entry with least cost Dijsktra’s Algorithm from Router A

5 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 6 Move entry A 0 A 0 Dijsktra’s Algorithm from Router A

6 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 7: Extend newly found least cost path A’s neighbors are B and D A 0 Dijsktra’s Algorithm from Router A

7 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 7: Extend newly found least cost path A’s neighbors are B and D A 0 A,B 0+C(A,B) Dijsktra’s Algorithm from Router A

8 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 7: Extend newly found least cost path A’s neighbors are B and D A 0 A,B 0+C(A,B) A,D 0+C(A,D) Dijsktra’s Algorithm from Router A

9 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 7: Extend newly found least cost path A’s neighbors are B and D A 0 A,B 0+1=1 A,D 0+12=12 0+C(A,B) 0+C(A,D) Dijsktra’s Algorithm from Router A

10 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 8: Nothing to do A 0 A,B 1 A,D 12 Dijsktra’s Algorithm from Router A

11 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 9: Nothing to do A 0 A,B 1 A,D 12 Dijsktra’s Algorithm from Router A

12 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 10: Keep on going A 0 A,B 1 A,D 12 Dijsktra’s Algorithm from Router A

13 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 5: A,B has the least cost A 0 A,B 1 A,D 12 Dijsktra’s Algorithm from Router A

14 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost Step 6: Move to shortest paths A 0 A,D 12 A,B 1 Dijsktra’s Algorithm from Router A

15 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, D, and E Dijsktra’s Algorithm from Router A

16 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, and E A,B,A 1+C(B,A) Dijsktra’s Algorithm from Router A

17 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, and E A,B,A 1+C(B,A) A,B,C 1+C(B,C)

18 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, and E A,B,A 1+C(B,A) A,B,C 1+C(B,C) A,B,E 1+C(B,E)

19 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have te same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, and E A,B,A 1+C(B,A) A,B,C 1+C(B,C) A,B,E 1+C(B,E) 2 3 7

20 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 Step 8: Clean up candidate list 1: remove candidate paths with the same end Nothing to do A,B,A 2 A,B,C 3 A,B,E 7

21 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,A A,B,A 2 A,B,C 3 A,B,E 7

22 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,A A,B,C 3 A,B,E 7

23 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,C 3 A,B,E 7 Step 10: Keep on going

24 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,C 3 A,B,E 7 Step 5: A,B,C has the lowest costc

25 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,C 3 A,B,E 7 Step 6: Move path to least costs path A,B,C 3

26 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,E 7 Step 6: Move path to least costs path A,B,C 3

27 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,E 7 A,B,C 3 Step 7: Extend newly found least cost path C’s neighbors are B, D, and F A,B,C, B 3+C(C,B)

28 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,E 7 A,B,C 3 Step 7: Extend newly found least cost path C’s neighbors are B, D, and F A,B,C, B 3+C(C,B) A,B,C, D 3+C(C,D)

29 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,E 7 A,B,C 3 Step 7: Extend newly found least cost path C’s neighbors are B, D, and F A,B,C, B 3+C(C,B) A,B,C, D 3+C(C,D) A,B,C, F 3+C(C,F)

30 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,E 7 A,B,C 3 Step 7: Extend newly found least cost path C’s neighbors are B, D, and F A,B,C, B 3+C(C,B) A,B,C, D 3+C(C,D) A,B,C, F 3+C(C,F) 5 9 4

31 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop. Least costs paths Cost Candidate paths Cost A 0 A,D 12 A,B 1 A,B,E 7 A,B,C 3 A,B,C, B A,B,C, D A,B,C, F 5 9 4 Step 8: Clean up candidate list 1: remove candidate paths with the same end A,B,C,D has lower cost than A,D

32 Dijsktra’s Algorithm from A A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, B A,B,C, D A,B,C, F 5 9 4 Step 8: Clean up candidate list 1: remove candidate paths with the same end A,B,C,D has lower cost than A,D

33 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, B A,B,C, D A,B,C, F 5 9 4 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,B Dijsktra’s Algorithm from Router A

34 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D A,B,C, F 9 4 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,B Dijsktra’s Algorithm from Router A

35 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D A,B,C, F 9 4 Step 10: Keep on going Dijsktra’s Algorithm from Router A

36 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B1 A,B,E 7 A,B,C3 A,B,C, D A,B,C, F 9 4 Step 5: A,B,C,F has the least cost Dijsktra’s Algorithm from Router A

37 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D A,B,C, F 9 4 Step 5: A,B,C,F has the least cost A,B,C, F 4 Dijsktra’s Algorithm from Router A

38 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D9 Step 5: A,B,C,F has the least cost A,B,C, F 4 Dijsktra’s Algorithm from Router A

39 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D9 A,B,C, F 4 Step 7: Extend newly found least cost path F’s neighbors are C, and E Dijsktra’s Algorithm from Router A

40 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D 9 A,B,C, F 4 Step 7: Extend newly found least cost path F’s neighbors are C, and E A,B,C, F, C 4+C(F,C) Dijsktra’s Algorithm from Router A

41 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D 9 A,B,C, F 4 Step 7: Extend newly found least cost path F’s neighbors are C, and E A,B,C, F, C 4+C(F,C) A,B,C, F, E 4+C(F,E) Dijsktra’s Algorithm from Router A

42 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D 9 A,B,C, F 4 Step 7: Extend newly found least cost path F’s neighbors are C, and E A,B,C, F, C 4+C(F,C) A,B,C, F, E 4+C(F,E) 5 6 Dijsktra’s Algorithm from Router A

43 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,E 7 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, C A,B,C, F, E 5 6 Step 8: Clean up candidate list 1: remove candidate paths with the same end A,B,C,F,E has lower cost than A,B,E Dijsktra’s Algorithm from Router A

44 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, C A,B,C, F, E 5 6 Step 8: Clean up candidate list 1: remove candidate paths with the same end A,B,C,F,E has lower cost than A,B,E Dijsktra’s Algorithm from Router A

45 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, C A,B,C, F, E 5 6 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,F,C Dijsktra’s Algorithm from Router A

46 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,F,C Dijsktra’s Algorithm from Router A

47 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 10: Keep on going Dijsktra’s Algorithm from Router A

48 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 5: A, B, C, F, E has the least cost Dijsktra’s Algorithm from Router A

49 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 6: Move the newly found least cost path A,B,C, F, E 6 Dijsktra’s Algorithm from Router A

50 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 Step 6: Move the newly found least cost path A,B,C, F, E 6 Dijsktra’s Algorithm from Router A

51 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 7: Extend newly found least cost path F’s neighbors are B, D and F Dijsktra’s Algorithm from Router A

52 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 7: Extend newly found least cost path F’s neighbors are B, D and F A,B,C, F, E, B 6+C(E,B) Dijsktra’s Algorithm from Router A

53 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 7: Extend newly found least cost path F’s neighbors are B, D and F A,B,C, F, E, B 6+C(E,B) A,B,C, F, E, D 6+C(E,D) Dijsktra’s Algorithm from Router A

54 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 7: Extend newly found least cost path F’s neighbors are B, D and F A,B,C, F, E, B 6+C(E,B) A,B,C, F, E, D 6+C(E,D) A,B,C, F, E, F 6+C(E,F) Dijsktra’s Algorithm from Router A

55 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 Step 7: Extend newly found least cost path F’s neighbors are B, D and F A,B,C, F, E, B 6+C(E,B) A,B,C, F, E, D 6+C(E,D) A,B,C, F, E, F6+C(E,F) 12 7 8 Dijsktra’s Algorithm from Router A

56 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, D 9 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, B A,B,C, F, E, D A,B,C, F, E, F 12 7 8 Step 8: Clean up candidate list 1: remove candidate paths with the same end A,B,C,F,E,D has lower cost than A,B, C, D Dijsktra’s Algorithm from Router A

57 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, B A,B,C, F, E, D A,B,C, F, E, F 12 7 8 Step 8: Clean up candidate list 1: remove candidate paths with the same end A,B,C,F,E,D has lower cost than A,B, C, D Dijsktra’s Algorithm from Router A

58 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, B A,B,C, F, E, D A,B,C, F, E, F 12 7 8 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,F,E,B and A, B, C, F,E,F Dijsktra’s Algorithm from Router A

59 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,F,E,B and A, B, C, F,E,F Dijsktra’s Algorithm from Router A

60 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 Step 10: keep on going Dijsktra’s Algorithm from Router A

61 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 Step 5: A,B,C,F,E,D has the least cost Dijsktra’s Algorithm from Router A

62 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 Step 6: move newly found least cost path Dijsktra’s Algorithm from Router A

63 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 Step 6: move newly found least cost path A,B,C, F, E, D 7 Dijsktra’s Algorithm from Router A

64 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 Step 6: move newly found least cost path A,B,C, F, E, D 7 Dijsktra’s Algorithm from Router A

65 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 Step 7: Extend newly found least cost path D’s neighbors are A, C and E A,B,C, F, E, D,A 19 A,B,C, F, E, D,C 13 A,B,C, F, E, D,E 8 Dijsktra’s Algorithm from Router A

66 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 A,B,C, F, E, D,A 19 A,B,C, F, E, D,C 13 A,B,C, F, E, D,E 8 Step 8: Clean up candidate list 1: Nothing to do Dijsktra’s Algorithm from Router A

67 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 A,B,C, F, E, D,A 19 A,B,C, F, E, D,C 13 A,B,C, F, E, D,E 8 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,F,E,D,A, A, B, C, F,E,D,C and A,B,C,F,E,D,E Dijsktra’s Algorithm from Router A

68 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,F,E,D,A, A, B, C, F,E,D,C and A,B,C,F,E,D,E Dijsktra’s Algorithm from Router A

69 A B E C D F 1 2 2 1 6 12 1 6 Link Costs C(A,B)=1 C(A,D)=12 C(B,E)=6 C(B,C)=2 C(C,F)=1 C(C,D)=6 C(D,E)=1 C(E,F)=2 Let u be the router running this algorithm 1 Initialization: 2Candidate paths CP = [0, {u}] 3Least cost paths = empty 4Loop 5find path [a, {u, …, w}] in CP with the least cost 6Move [a, {u, …, w}] to shortest paths 7Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] 8Clean up candidate paths 1: if there are multiple entries in the list of candidate paths with the same destination, remove the ones with higher cost. If two have the same cost, remove one with more hops, if two have the same number of hops, remove the one with higher next hop IP address 9Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths 10If candidate paths is empty, then stop Least costs paths Cost Candidate paths Cost A 0 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7 Step 10: DONE! Dijsktra’s Algorithm from Router A

70 Dijkstra’s algorithm, discussion Algorithm complexity: n nodes r each iteration: m Need to check all entries in candidate list, at most N comparisons m Need to extend best path, at most N extensions m Need to compare each entry to all entries in the candidate list (at most N) m Need to compare each entry in candidate list to each entry in shortest paths (N/2) r 3.5N each iteration, so 3.5N^2 ~ O(N^2) r more efficient implementations possible: O(nlogn) Oscillations possible: r e.g., link cost = amount of carried traffic A D C B 1 1+e e 0 e 1 1 0 0 A D C B 2+e 0 0 0 1+e 1 A D C B 0 2+e 1+e 1 0 0 A D C B 2+e 0 e 0 1+e 1 initially … recompute routing … recompute


Download ppt "Dijkstra’s Algorithm Notation:  c(x,y): link cost from node x to y; = ∞ if not direct neighbors  D(v): current value of cost of path from source to dest."

Similar presentations


Ads by Google