70
Dijkstra’s Algorithm Notation: c(x,y): link cost from node x to y; = ∞ if not direct neighbors D(v): current value of cost of path from source to dest. v p(v): predecessor node along path from source to v N': set of nodes whose least cost path definitively known Data structures: 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)

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

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

Dijkstra’s Algorithm

Notation: c(x,y): link cost from

node x to y; = ∞ if not direct neighbors

D(v): current value of cost of path from source to dest. v

p(v): predecessor node along path from source to v

N': set of nodes whose least cost path definitively known

Data structures: 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)

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 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

121

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Least costs paths Cost Candidate paths Cost

A 0

Initialization (Steps 2-3)

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

A

B

E

C

D

F

1

2

2

16

121

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

Step 5

Entry with least cost

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

121

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 6

Move entryA 0 A 0

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 7: Extend newly found least cost pathA’s neighbors are B and D

A 0

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 7: Extend newly found least cost pathA’s neighbors are B and D

A 0 A,B 0+C(A,B)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 7: Extend newly found least cost pathA’s neighbors are B and D

A 0 A,B 0+C(A,B)

A,D 0+C(A,D)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 7: Extend newly found least cost pathA’s neighbors are B and D

A 0 A,B 0+1=1

A,D 0+12=12

0+C(A,B)

0+C(A,D)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 8: Nothing to do

A 0 A,B 1

A,D 12

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 9: Nothing to do

A 0 A,B 1

A,D 12

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 10: Keep on going

A 0 A,B 1

A,D 12

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 5: A,B has the least cost

A 0 A,B 1

A,D 12

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

Step 6: Move to shortest paths

A 0 A,D 12A,B 1

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1

Step 7: Extend newly found least cost pathB’s neighbors are A, C, D, and E

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1

Step 7: Extend newly found least cost pathB’s neighbors are A, C, and E

A,B,A 1+C(B,A)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1

Step 7: Extend newly found least cost pathB’s neighbors are A, C, and E

A,B,A 1+C(B,A)

A,B,C 1+C(B,C)

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1

Step 7: Extend newly found least cost pathB’s neighbors are A, C, and E

A,B,A 1+C(B,A)

A,B,C 1+C(B,C)

A,B,E 1+C(B,E)

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1

Step 7: Extend newly found least cost pathB’s neighbors are A, C, and E

A,B,A 1+C(B,A)

A,B,C 1+C(B,C)

A,B,E 1+C(B,E)

2

3

7

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1

Step 8: Clean up candidate list 1: remove candidate paths with the same end

Nothing to do

A,B,A 2

A,B,C 3

A,B,E 7

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,A

A,B,A 2

A,B,C 3

A,B,E 7

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,A

A,B,C 3

A,B,E 7

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0 A,D 12

A,B 1 A,B,C 3

A,B,E 7

Step 10: Keep on going

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1 A,B,C 3

A,B,E 7

Step 5: A,B,C has the lowest costc

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1 A,B,C 3

A,B,E 7

Step 6: Move path to least costs path

A,B,C 3

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1 A,B,E 7

Step 6: Move path to least costs path

A,B,C 3

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1 A,B,E 7

A,B,C 3

Step 7: Extend newly found least cost pathC’s neighbors are B, D, and F

A,B,C, B 3+C(C,B)

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1 A,B,E 7

A,B,C 3

Step 7: Extend newly found least cost pathC’s neighbors are B, D, and F

A,B,C, B 3+C(C,B)

A,B,C, D 3+C(C,D)

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1 A,B,E 7

A,B,C 3

Step 7: Extend newly found least cost pathC’s neighbors are B, D, and F

A,B,C, B 3+C(C,B)

A,B,C, D 3+C(C,D)A,B,C, F 3+C(C,F)

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1 A,B,E 7

A,B,C 3

Step 7: Extend newly found least cost pathC’s neighbors are B, D, and F

A,B,C, B 3+C(C,B)

A,B,C, D 3+C(C,D)A,B,C, F 3+C(C,F)

5

9

4

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop.

Least costs pathsCost Candidate paths Cost

A 0 A,D 12A,B 1 A,B,E 7

A,B,C 3 A,B,C, B

A,B,C, D

A,B,C, F

5

9

4

Step 8: Clean up candidate list 1: remove candidate paths with the same end

A,B,C,D has lower cost than A,D

Dijsktra’s Algorithm from A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, B

A,B,C, D

A,B,C, F

5

9

4

Step 8: Clean up candidate list 1: remove candidate paths with the same end

A,B,C,D has lower cost than A,D

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, B

A,B,C, D

A,B,C, F

5

9

4

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,C,B

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0A,B 1

A,B,E 7

A,B,C 3A,B,C, D

A,B,C, F9

4

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,C,B

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, D

A,B,C, F9

4

Step 10: Keep on going

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0A,B 1

A,B,E 7

A,B,C 3

A,B,C, D

A,B,C, F9

4

Step 5: A,B,C,F has the least cost

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, D

A,B,C, F9

4

Step 5: A,B,C,F has the least cost

A,B,C, F 4

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, D 9

Step 5: A,B,C,F has the least cost

A,B,C, F 4

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, D 9

A,B,C, F 4

Step 7: Extend newly found least cost pathF’s neighbors are C, and E

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, D 9

A,B,C, F 4

Step 7: Extend newly found least cost pathF’s neighbors are C, and E

A,B,C, F, C 4+C(F,C)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, D 9

A,B,C, F 4

Step 7: Extend newly found least cost pathF’s neighbors are C, and E

A,B,C, F, C 4+C(F,C)

A,B,C, F, E 4+C(F,E)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, D 9

A,B,C, F 4

Step 7: Extend newly found least cost pathF’s neighbors are C, and E

A,B,C, F, C 4+C(F,C)A,B,C, F, E 4+C(F,E)

56

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1

A,B,E 7

A,B,C 3

A,B,C, D 9

A,B,C, F 4A,B,C, F, CA,B,C, F, E

56

Step 8: Clean up candidate list 1: remove candidate paths with the same end

A,B,C,F,E has lower cost than A,B,E

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

A,B,C, F, CA,B,C, F, E

56

Step 8: Clean up candidate list 1: remove candidate paths with the same end

A,B,C,F,E has lower cost than A,B,E

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

A,B,C, F, CA,B,C, F, E

56

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,C,F,C

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

A,B,C, F, E 6

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,C,F,C

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

A,B,C, F, E 6

Step 10: Keep on going

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

A,B,C, F, E 6

Step 5: A, B, C, F, E has the least cost

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

A,B,C, F, E 6

Step 6: Move the newly found least cost path

A,B,C, F, E 6

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

Step 6: Move the newly found least cost path

A,B,C, F, E 6

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

A,B,C, F, E 6

Step 7: Extend newly found least cost pathF’s neighbors are B, D and F

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4A,B,C, F, E 6

Step 7: Extend newly found least cost pathF’s neighbors are B, D and F

A,B,C, F, E, B 6+C(E,B)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4A,B,C, F, E 6

Step 7: Extend newly found least cost pathF’s neighbors are B, D and F

A,B,C, F, E, B 6+C(E,B)A,B,C, F, E, D6+C(E,D)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4

A,B,C, F, E 6

Step 7: Extend newly found least cost pathF’s neighbors are B, D and F

A,B,C, F, E, B 6+C(E,B)

A,B,C, F, E, D6+C(E,D)

A,B,C, F, E, F 6+C(E,F)

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4A,B,C, F, E 6

Step 7: Extend newly found least cost pathF’s neighbors are B, D and F

A,B,C, F, E, B 6+C(E,B)

A,B,C, F, E, D6+C(E,D)

A,B,C, F, E, F 6+C(E,F)

12

7

8

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, D 9

A,B,C, F 4A,B,C, F, E 6

A,B,C, F, E, B

A,B,C, F, E, D

A,B,C, F, E, F

12

7

8

Step 8: Clean up candidate list 1: remove candidate paths with the same end

A,B,C,F,E,D has lower cost than A,B, C, D

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4A,B,C, F, E 6

A,B,C, F, E, B

A,B,C, F, E, D

A,B,C, F, E, F

12

7

8

Step 8: Clean up candidate list 1: remove candidate paths with the same end

A,B,C,F,E,D has lower cost than A,B, C, D

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4A,B,C, F, E 6

A,B,C, F, E, B

A,B,C, F, E, D

A,B,C, F, E, F

12

7

8

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,C,F,E,B and A, B, C, F,E,F

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4A,B,C, F, E 6

A,B,C, F, E, D 7

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,C,F,E,B and A, B, C, F,E,F

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

Step 10: keep on going

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

Step 5: A,B,C,F,E,D has the least cost

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

Step 6: move newly found least cost path

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

Step 6: move newly found least cost path

A,B,C, F, E, D 7

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

Step 6: move newly found least cost path

A,B,C, F, E, D 7

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

Step 7: Extend newly found least cost pathD’s neighbors are A, C and E

A,B,C, F, E, D,A 19A,B,C, F, E, D,C 13

A,B,C, F, E, D,E 8

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

A,B,C, F, E, D,A 19A,B,C, F, E, D,C 13

A,B,C, F, E, D,E 8

Step 8: Clean up candidate list 1: Nothing to do

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

A,B,C, F, E, D,A 19A,B,C, F, E, D,C 13

A,B,C, F, E, D,E 8

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,C,F,E,D,A, A, B, C, F,E,D,C and A,B,C,F,E,D,E

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

Step 9: Clean up candidate list 2: remove candidate paths with the same ends already in least cost paths

Remove A,B,C,F,E,D,A, A, B, C, F,E,D,C and A,B,C,F,E,D,E

Dijsktra’s Algorithm from Router A

A

B

E

C

D

F

1

2

2

16

12

1

6

Link CostsC(A,B)=1C(A,D)=12C(B,E)=6C(B,C)=2C(C,F)=1C(C,D)=6C(D,E)=1C(E,F)=2

Let u be the router running this algorithm 1 Initialization: 2 Candidate paths CP = [0, {u}]3 Least cost paths = empty

4 Loop 5 find path [a, {u, …, w}] in CP with the least

cost6 Move [a, {u, …, w}] to shortest paths7 Extend w and place extensions in CP: For

each neighbor v of w make new candidate path [a+c(w,v), {u,…, w,v}]

8 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

9 Clean up candidate paths 2: Remove candidate paths that have a destination that is already in the list of shortest paths

10 If candidate paths is empty, then stop

Least costs pathsCost Candidate paths Cost

A 0

A,B 1A,B,C 3

A,B,C, F 4

A,B,C, F, E 6

A,B,C, F, E, D 7

Step 10: DONE!

Dijsktra’s Algorithm from Router A

Dijkstra’s algorithm, discussionAlgorithm 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

B1 1+e

e0

e

1 1

0 0

A

D

C

B2+e 0

001+e1

A

D

C

B0 2+e

1+e10 0

A

D

C

B2+e 0

e01+e1

initially… recompute

routing… recompute … recompute