Dijkstras Algorithm Notation r cx y link cost

  • Slides: 70
Download presentation
Dijkstra’s Algorithm Notation: r c(x, y): link cost from node x to y; =

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

Dijsktra’s Algorithm Let u be the router running this algorithm 1 Initialization: 2 Candidate

Dijsktra’s Algorithm Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 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 2 B 6 6 A 12 D C 1 E 1 F 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 Initialization (Steps 2 -3) Least costs paths Cost Candidate paths A Cost 0

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 2 6 6 A 12 D 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}] Least costs paths Cost Clean up candidate paths: if there are 0 A 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 C 1 E 1 F 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 Step 6 Candidate paths Cost A 0 Move entry

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 find path [a, {u, …, w}] in CP with the least cost Step 8: Nothing to do 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}] Least costs paths Cost Candidate paths Cost Clean up candidate paths: if there are 0 A 1 A, B multiple entries in the list of candidate paths with the same destination, remove the ones 12 A, D 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 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 9: Nothing to do each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths: if there are 0 A 1 A, B multiple entries in the list of candidate paths with the same destination, remove the ones 12 A, D 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 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 2 6 6 A 12 D 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 Step 10: each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Clean up candidate paths: if there are 0 A 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 C E 1 F 2 1 Keep on going Candidate paths Cost A, B 1 A, D 12 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 5: A, B has the least cost each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths: if there are 0 A 1 A, B multiple entries in the list of candidate paths with the same destination, remove the ones 12 A, D 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 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 6: Move to shortest paths each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths: if there are 0 A 12 multiple entries in the list of candidate paths A, D with the same destination, remove the ones 1 A, B 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 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 2 6 6 A 12 D 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 Step 10: each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Clean up candidate paths 1: if there are 0 A multiple entries in the list of candidate paths with the same destination, remove the ones 1 A, B 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 C E 1 F 2 1 Keep on going Candidate paths Cost A, D A, B, C A, B, E 12 3 7 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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 5: A, B, C has the lowest each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths 1: if there are 0 A 12 multiple entries in the list of candidate paths A, D with the same destination, remove the ones 3 A, B, C 1 A, B with higher cost. If two have the same cost, 7 A, B, E 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. 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 costc

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 6: Move path to least costs each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths 1: if there are 0 A 12 multiple entries in the list of candidate paths A, D with the same destination, remove the ones 3 A, B, C 1 A, B with higher cost. If two have the same cost, 7 A, B, E 3 A, B, C 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 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 path

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 6: Move path to least costs each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths 1: if there are 0 A 12 multiple entries in the list of candidate paths A, D with the same destination, remove the ones 1 7 A, B, E with higher cost. If two have the same cost, 3 A, B, C 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. 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 path

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from A 1 Let u be the router running this algorithm 1

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 2 6 6 A 12 D 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 Step 10: each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Clean up candidate paths 1: if there are 0 A multiple entries in the list of candidate paths with the same destination, remove the ones 1 A, B with higher cost. If two have the same cost, 3 A, B, C 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 C E 1 F 2 1 Keep on going Candidate paths Cost A, B, E A, B, C, D 7 9 A, B, C, F 4 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 5: A, B, C, F has the least cost each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths 1: if there are 7 A, B, E 0 A multiple entries in the list of candidate paths A, B, C, D with the same destination, remove the ones 9 A, B 1 with higher cost. If two have the same cost, A, B, C, F A, B, C 3 4 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 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 5: A, B, C, F has the least cost each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths 1: if there are 7 A, B, E 0 A multiple entries in the list of candidate paths A, B, C, D with the same destination, remove the ones 9 1 A, B with higher cost. If two have the same cost, A, B, C, F 3 A, B, C 4 remove one with more hops, if two have the same number of hops, remove the one with A, B, C, F 4 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 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}] 3 Least cost paths = empty 4 5 6 7 8 9 10 B 6 A 12 D 2 C 6 E 1 F 2 Loop 1 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 Step 5: A, B, C, F has the least cost each neighbor v of w make new candidate path [a+c(w, v), {u, …, w, v}] Least costs paths Cost Candidate paths Cost Clean up candidate paths 1: if there are 7 A, B, E 0 A multiple entries in the list of candidate paths A, B, C, D 9 with the same destination, remove the ones 1 A, B with higher cost. If two have the same cost, 3 A, B, C remove one with more hops, if two have the same number of hops, remove the one with A, B, C, F 4 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 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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijsktra’s Algorithm from Router A 1 Let u be the router running this algorithm

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

Dijkstra’s algorithm, discussion Algorithm complexity: n nodes r each iteration: Need to check all

Dijkstra’s algorithm, discussion Algorithm complexity: n nodes r 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) m m 3. 5 N each iteration, so 3. 5 N^2 ~ O(N^2) more efficient implementations possible: O(nlogn) Oscillations possible: r e. g. , link cost = amount of carried traffic r r D 1 1 0 A 0 0 C e 1+e e initially B 1 2+e A 0 D 1+e 1 B 0 0 C … recompute routing 0 D 1 A 0 0 C 2+e B 1+e … recompute 2+e A 0 D 1+e 1 B e 0 C … recompute