Docsity

Bellman-Ford Algorithm-Analysis of Algorithms-Lecture Slides, Slides of Design and Analysis of Algorithms

Toggle sidebar
bg1
Bellman-Ford Algorithm
Consider computations for one destination d
Initialization
Each node table has 1 row for destination d
Distance of node d to itself is zero: Dd=0
Distance of other node j to d is infinite: Dj=
, for j
d
Next hop node nj = -1 to indicate not yet defined for j
d
Send Step
Send new distance vector to immediate neighbors across local link
Receive Step
At node j, find the next hop that gives the minimum distance to d,
Minj { Cij + Dj }
Replace old (nj, Dj(d)) by new (nj*, Dj*(d)) if new next node or distance
Go to send step
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Bellman-Ford Algorithm-Analysis of Algorithms-Lecture Slides and more Slides Design and Analysis of Algorithms in PDF only on Docsity!

Bellman-Ford Algorithm

 Consider computations for one destination d

 Initialization

 Each node table has 1 row for destination d  Distance of node d to itself is zero: Dd=

 Distance of other node j to d is infinite: Dj=  , for j  d

 Next hop node nj = -1 to indicate not yet defined for j  d

 Send Step

 Send new distance vector to immediate neighbors across local link

 Receive Step

 At node j , find the next hop that gives the minimum distance to d ,  Minj { Cij + Dj }  Replace old (nj, Dj(d)) by new (nj, Dj(d)) if new next node or distance  Go to send step

Bellman-Ford Algorithm

 Now consider parallel computations for all destinations d

 Initialization

 Each node has 1 row for each destination d  Distance of node d to itself is zero: Dd(d)=

 Distance of other node j to d is infinite: Dj(d)=  , for j  d

 Next node nj = -1 since not yet defined

 Send Step

 Send new distance vector to immediate neighbors across local link

 Receive Step

 For each destination d , find the next hop that gives the minimum distance to d ,  Minj { Cij+ Dj(d) }  Replace old (nj, Di(d)) by new (nj, Dj(d)) if new next node or distance found  Go to send step

Initial (-1, ) (-1, ) (-1, ) (-1, ) (-1, )

1 (-1, ) (-1, ) (6,1) (-1, ) (6,2) 2 3

Root Node

D 6 =

D 3 =D 6 + n 3 =

3 1

5

4 6

2

2

3

4

2

1

1

2

3

5

D^ D^6 = 5 =D 6 + n 5 =

Initial (-1, ) (-1, ) (-1, ) (-1, ) (-1, )

1 (-1, ) (-1, ) (6, 1) (-1, ) (6,2) 2 (3,3) (5,6) (6, 1) (3,3) (6,2) 3

Root Node

3 1

5

4 6

2

2

3

4

2

1

1

2

3

5 0

Initial (3,3) (4,4) (6, 1) (3,3) (6,2)

1 (3,3) (4,4) (4, 5) (3,3) (6,2)

2

3

Root Node

3 1

5

4 6

2

2

3

4

2

1

1

2

3

5 0

Network disconnected; Loop created between nodes 3 and 4

Initial (3,3) (4,4) (6, 1) (3,3) (6,2)

1 (3,3) (4,4) (4, 5) (3,3) (6,2)

2 (3,7) (4,4) (4, 5) (5,5) (6,2)

3

Root Node

3 1

5

4 6

2

2

3

4

2

1

1

2

3

5 0

Node 4 could have chosen 2 as next node because of tie

3

5

4 6

2

2

3

4

2

1

1

2

3

5

1

Root Node

Node 1 could have chose 3 as next node because of tie

1 2 3 4 1 1 1

1 2 3 4 1 1

X

(a)

(b)

Update Node 1 Node 2 Node 3 Before break (2,3) (3,2) (4, 1) After break (2,3) (3,2) (2,3) 1 (2,3) (3,4) (2,3) 2 (2,5) (3,4) (2,5) 3 (2,5) (3,6) (2,5) 4 (2,7) (3,6) (2,7) 5 (2,7) (3,8) (2,7)

Counting to Infinity Problem

Nodes believe best path is through each other (Destination is node 4)