Unformatted text preview: g order of CHAPTER 18. NETWORK ROUTING - I 12 WITHOUT ANY FAILURES Figure 18-6: Dijkstra’s shortest paths algorithm in operation, ﬁnding paths from A to all the other nodes.
Initially, the set S of nodes to which the algorithm knows the shortest path is empty. Nodes are added to
it in non-decreasing order of shortest path costs, with ties broken arbitrarily. In this example, nodes are
added in the order (A, C, B, F, E, D, G). The numbers in parentheses near a node show the current value of
spcost of the node as the algorithm progresses, with old values crossed out. shortest-path costs. The ﬁrst node we will add to S is n itself, since the cost of the path
from n to itself is 0 (and not larger than the path to any other node, since the links all have
non-negative weights). Figure 18-6 shows an example of the algorithm in operation.
Fortunately, there is an efﬁcient way to determine the next node to add to S from the set
X . As the algorithm proceeds, it maintains the current shortest-path costs, spcost(v ), for
each node v . Initially, spcost(v ) = ∞ (some big number in practice) for all nodes, except
for n, whose spcost is 0. Whenever a node u is added to S , the algorithm checks each
of u’s neighbors, w, to see if the current value of spcost(w) is larger than spcost(u) +
linkcost(uw). If it is, then update spcost(w). Clearly, we don’t need to check if the
spcost of any other node that isn’t a neighbor of u has changed because u was added to
S —it couldn’t have. Having done this step, we check the set X to ﬁnd the next node to
add to S ; as mentioned before, the node with the smallest spcost is selected (we break
The last part is to remember that what the algorithm needs to produce is a route for each
destination, which means that we need to maintain the outgoing link for each destination.
To compute the route, observe that what Dijkstra’s algorithm produces is a shortest path
tree rooted at the source, n, traversing all the destination nodes in the network. (A tree is a
graph that has no cycles and is connected, i.e., there is exactly one path betw...
View Full Document
This document was uploaded on 02/26/2014 for the course CS 6.02 at MIT.
- Fall '13