Professional Documents
Culture Documents
1 Part 1: Routing
1. Find the shortest path tree from every node to node 1 for the graph
of Fig.1 using the Bellman-ford and Dijkstra algorithms.
10
2 5
3 6 2
4
4
1 6 4 3 2 7
3
4 3
5 2
3 6
9
Solution:
(h)
The Bellman-Ford Algorithm Let Cl be the cost from node l to
(h) (1)
node 1 at the hth iteration. C1 = 0, for all h. Initially C1 = d1i , for
(h+1) (h)
all i 6= 1. For each successive h ≥ 1 we compute C i = minj [Cj +
dji ], for all i 6= 1. The results are summarized in Table 1.
The arcs on the shortest path tree are computed after running the
Bellman-Ford algorithm. For each i 6= 1 we include in the shortest
path tree one arc (j, i) that minimizes Bellman’s equation.
1
Table 1: Bellman-Ford Algorithm
i Ci1 Ci2 Ci3 Ci4 Ci5 Shortest path arcs†
1 0 0 0 0 0
2 4 4 4 4 4 (1, 2)
3 5 5 5 5 5 (1, 3)
4 ∞ 7 7 7 7 (2, 4)
5 ∞ 14 13 12 12 (6, 5)
6 ∞ 14 10 10 10 (1, 2)
7 ∞ ∞ 16 12 12 (1, 2)
† The arcs on the shortest path tree are computed after running the Bellman-
Ford algorithm. For each i 6= j we include in the shortest path tree one arc
(j, i) that minimizes Bellman’s equation.
2
1 2 1 2
5
4
3 3
4
3
(a) one message transmission (b) two message transmissions