Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dijkstra’s Algorithm Data structures: Notation: Path

Similar presentations


Presentation on theme: "Dijkstra’s Algorithm Data structures: Notation: Path"— Presentation transcript:

1 Dijkstra’s Algorithm Data structures: Notation: Path
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: Path An ordered sequence of nodes a cost to reach the end of the path The sum of each lonk cost along the path Candidate paths (CP) Shortest paths (SP)

2 Dijsktra’s Algorithm Let u be the router running this algorithm
1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop

3 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Initialization (Steps 2-3) Least costs paths Cost Candidate paths Cost A

4 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 5 Least costs paths Cost Candidate paths Cost A Entry with least cost

5 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 6 Least costs paths Cost Candidate paths Cost A A Move entry

6 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path A’s neighbors are B and D Least costs paths Cost Candidate paths Cost A

7 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path A’s neighbors are B and D Least costs paths Cost Candidate paths Cost A A,B 0+C(A,B)

8 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path A’s neighbors are B and D Least costs paths Cost Candidate paths Cost A A,B 0+C(A,B) A,D 0+C(A,D)

9 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path A’s neighbors are B and D Least costs paths Cost Candidate paths Cost A A,B 0+1=1 0+C(A,B) A,D 0+12=12 0+C(A,D)

10 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 8: Nothing to do Least costs paths Cost Candidate paths Cost A A,B 1 A,D 12

11 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 9: Nothing to do Least costs paths Cost Candidate paths Cost A A,B 1 A,D 12

12 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 10: Keep on going Least costs paths Cost Candidate paths Cost A A,B 1 A,D 12

13 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 5: A,B has the least cost Least costs paths Cost Candidate paths Cost A A,B 1 A,D 12

14 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 6: Move to shortest paths Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1

15 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, D, and E Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1

16 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, and E Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,A 1+C(B,A)

17 Step 7: Extend newly found least cost path
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, and E Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,A 1+C(B,A) A,B,C 1+C(B,C)

18 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, and E Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 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
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path B’s neighbors are A, C, and E Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,A 1+C(B,A) 2 A,B,C 3 1+C(B,C) A,B,E 7 1+C(B,E)

20 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 8: Clean up candidate list 1: remove candidate paths with the same end Nothing to do Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,A 2 A,B,C 3 A,B,E 7

21 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,A Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,A 2 A,B,C 3 A,B,E 7

22 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,A Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,C 3 A,B,E 7

23 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 10: Keep on going Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,C 3 A,B,E 7

24 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 5: A,B,C has the lowest costc Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,C 3 A,B,E 7

25 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 6: Move path to least costs path Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,C 3 A,B,C 3 A,B,E 7

26 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 6: Move path to least costs path Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,E 7 A,B,C 3

27 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 7: Extend newly found least cost path C’s neighbors are B, D, and F Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,E 7 A,B,C 3 A,B,C, B 3+C(C,B)

28 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 7: Extend newly found least cost path C’s neighbors are B, D, and F Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,E 7 A,B,C 3 A,B,C, B 3+C(C,B) A,B,C, D 3+C(C,D)

29 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path C’s neighbors are B, D, and F Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,E 7 A,B,C 3 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
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 7: Extend newly found least cost path C’s neighbors are B, D, and F Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,E 7 A,B,C 3 A,B,C, B 5 3+C(C,B) A,B,C, D 9 3+C(C,D) A,B,C, F 3+C(C,F) 4

31 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop. A F 2 12 D E 1 Step 8: Clean up candidate list 1: remove candidate paths with the same end A,B,C,D has lower cost than A,D Least costs paths Cost Candidate paths Cost A A,D 12 A,B 1 A,B,E 7 A,B,C 3 A,B,C, B 5 A,B,C, D 9 A,B,C, F 4

32 Dijsktra’s Algorithm from A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 8: Clean up candidate list 1: remove candidate paths with the same end A,B,C,D has lower cost than A,D Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B 1 A,B,C, B 5 A,B,C 3 A,B,C, D 9 A,B,C, F 4

33 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,B Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B 1 A,B,C, B 5 A,B,C 3 A,B,C, D 9 A,B,C, F 4

34 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths Remove A,B,C,B Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B 1 A,B,C, D 9 A,B,C 3 A,B,C, F 4

35 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 10: Keep on going Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B,C, D A,B 1 9 A,B,C 3 A,B,C, F 4

36 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 5: A,B,C,F has the least cost Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B 1 A,B,C, D 9 A,B,C 3 A,B,C, F 4

37 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 5: A,B,C,F has the least cost Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B,C, D A,B 1 9 A,B,C 3 A,B,C, F 4 A,B,C, F 4

38 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 5: A,B,C,F has the least cost Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B,C, D 9 A,B 1 A,B,C 3 A,B,C, F 4

39 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are C, and E Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B,C, D 9 A,B 1 A,B,C 3 A,B,C, F 4

40 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are C, and E Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B,C, D A,B 1 9 A,B,C 3 A,B,C, F, C 4+C(F,C) A,B,C, F 4

41 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are C, and E Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B,C, D A,B 1 9 A,B,C 3 A,B,C, F, C 4+C(F,C) A,B,C, F 4 A,B,C, F, E 4+C(F,E)

42 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are C, and E Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B,C, D A,B 1 9 A,B,C 3 A,B,C, F, C 5 4+C(F,C) A,B,C, F A,B,C, F, E 6 4+C(F,E) 4

43 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost A A,B,E 7 A,B,C, D A,B 1 9 A,B,C 3 A,B,C, F, C 5 A,B,C, F 4 A,B,C, F, E 6

44 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B 1 A,B,C, F, C 5 A,B,C 3 A,B,C, F, E 6 A,B,C, F 4

45 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B 1 A,B,C, F, C 5 A,B,C 3 A,B,C, F, E 6 A,B,C, F 4

46 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B 1 A,B,C, F, E 6 A,B,C 3 A,B,C, F 4

47 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 10: Keep on going Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B 1 A,B,C, F, E 6 A,B,C 3 A,B,C, F 4

48 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 5: A, B, C, F, E has the least cost Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B 1 A,B,C, F, E 6 A,B,C 3 A,B,C, F 4

49 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 6: Move the newly found least cost path Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B 1 A,B,C, F, E 6 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

50 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 6: Move the newly found least cost path Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

51 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are B, D and F Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

52 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are B, D and F Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B,C, F, E, B 6+C(E,B) A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

53 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are B, D and F Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B,C, F, E, B 6+C(E,B) A,B 1 A,B,C, F, E, D 6+C(E,D) A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

54 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are B, D and F Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B,C, F, E, B 6+C(E,B) A,B 1 A,B,C, F, E, D 6+C(E,D) A,B,C 3 A,B,C, F 4 A,B,C, F, E, F 6+C(E,F) A,B,C, F, E 6

55 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path F’s neighbors are B, D and F Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B,C, F, E, B 12 6+C(E,B) A,B 1 3 A,B,C, F, E, D 6+C(E,D) 7 A,B,C A,B,C, F 4 A,B,C, F, E, F 6+C(E,F) 8 A,B,C, F, E 6

56 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost A A,B,C, D 9 A,B,C, F, E, B 12 A,B 1 A,B,C, F, E, D 7 A,B,C 3 A,B,C, F 4 A,B,C, F, E, F 8 A,B,C, F, E 6

57 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost 12 A A,B,C, F, E, B A,B 1 A,B,C, F, E, D 7 A,B,C 3 A,B,C, F, E, F 8 A,B,C, F 4 A,B,C, F, E 6

58 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost 12 A A,B,C, F, E, B A,B 1 A,B,C, F, E, D 7 A,B,C 3 A,B,C, F, E, F 8 A,B,C, F 4 A,B,C, F, E 6

59 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost A A,B,C, F, E, D 7 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

60 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 10: keep on going Least costs paths Cost Candidate paths Cost A A,B,C, F, E, D 7 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

61 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 5: A,B,C,F,E,D has the least cost Least costs paths Cost Candidate paths Cost A A,B,C, F, E, D 7 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

62 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 6: move newly found least cost path Least costs paths Cost Candidate paths Cost A A,B,C, F, E, D 7 A,B 1 A,B,C 3 A,B,C, F 4 A,B,C, F, E 6

63 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 6: move newly found least cost path Least costs paths Cost Candidate paths Cost A A,B,C, F, E, D 7 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

64 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 6: move newly found least cost path Least costs paths Cost Candidate paths Cost A 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

65 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 7: Extend newly found least cost path D’s neighbors are A, C and E Least costs paths Cost Candidate paths Cost A A,B,C, F, E, D,A 19 A,B 1 A,B,C, F, E, D,C 13 A,B,C 3 A,B,C, F, E, D,E 8 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7

66 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 8: Clean up candidate list 1: Nothing to do Least costs paths Cost Candidate paths Cost A A,B,C, F, E, D,A 19 A,B 1 A,B,C, F, E, D,C 13 A,B,C 3 A,B,C, F, E, D,E 8 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7

67 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost A A,B,C, F, E, D,A 19 A,B 1 A,B,C, F, E, D,C 13 A,B,C 3 A,B,C, F, E, D,E 8 A,B,C, F 4 A,B,C, F, E 6 A,B,C, F, E, D 7

68 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 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 Least costs paths Cost Candidate paths Cost A 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

69 Dijsktra’s Algorithm from Router A
2 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 B C 1 1 6 6 Let u be the router running this algorithm 1 Initialization: Candidate paths CP = [0, {u}] Least cost paths = empty Loop find path [a, {u, …, w}] in CP with the least cost Move [a, {u, …, w}] to shortest paths Extend w and place extensions in CP: For each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}] Clean 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 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths If candidate paths is empty, then stop A F 2 12 D E 1 Step 10: DONE! Least costs paths Cost Candidate paths Cost A 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

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


Download ppt "Dijkstra’s Algorithm Data structures: Notation: Path"

Similar presentations


Ads by Google