0% found this document useful (0 votes)
119 views

Solution Methods For The Shortest Path Tree Problem

This document describes two algorithms for solving the shortest path tree problem: Dijkstra's algorithm and the primal simplex algorithm. Dijkstra's algorithm finds the shortest path from a source node to all other nodes in a network when all arc lengths are nonnegative. It works by iteratively adding the closest unsolved node to the solved set until all nodes are solved. The primal simplex algorithm can also solve the problem but is not limited to nonnegative arc lengths as long as there are no negative cycles. It works by maintaining a spanning tree basis and exchanging nonbasic arcs to improve the solution.

Uploaded by

Ehsan Ghasisin
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views

Solution Methods For The Shortest Path Tree Problem

This document describes two algorithms for solving the shortest path tree problem: Dijkstra's algorithm and the primal simplex algorithm. Dijkstra's algorithm finds the shortest path from a source node to all other nodes in a network when all arc lengths are nonnegative. It works by iteratively adding the closest unsolved node to the solved set until all nodes are solved. The primal simplex algorithm can also solve the problem but is not limited to nonnegative arc lengths as long as there are no negative cycles. It works by maintaining a spanning tree basis and exchanging nonbasic arcs to improve the solution.

Uploaded by

Ehsan Ghasisin
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Solution Methods for the Shortest Path Tree Problem

13

5.2

Shortest Path Problem

The problem investigated in this section is one of finding the collection of arcs (or path) that comprises the shortest path from a specified node s, called the source, to a second specified node t, called the destination. Figure 11 shows a typical network where s = 1 and t = 10. The parameter on the arcs is enclosed in parenthesis and represents its length. Each arc is numbered sequentially. A closely related problem, which we also consider, finds the set of shortest paths from the source node to all other nodes in the network. This shortest path tree problem is solved with very little additional difficulty. Figure 12 shows the shortest path tree with the source at node 1.
(arc length)
2 (6) (40) 1 1 (8) 2 (10) 3 5 7 (4) 5 (2) 10 3 (2) 8 (12) 6 6 (1) 9 4 (6) 19 (3) 14 9 12 (2) (4) 13 21 (10) (0) 17 8 (10) 4 (4) 11 16 (20) 15 (20) 18 (2) 20 (1) 7

10

Figure 11. Network showing arc lengths


[12] 2 [14] 7 (4) [0] 1 (8) 2 (10) 3 [10] 4 3 (2) 6 [10] 6 (3) 14 [13] 9 (4) 13 (2) 20 [8] 5 (0) 17 [14] 8 [15] 10 (4) 11 [18] 7

(arc length) [length of path]

Figure 12. Shortest path tree rooted at node 1 In the following sections, we present two algorithms for the shortest path problem. The first is a greedy approach that was developed by Dijkstra and yields the optimal solution when all arc lengths are positive. If some lengths are negative but no negative cycles exist, a primal

14

Network Flow Programming Methods simplex solution algorithm may be used. This is the second approach discussed.

Dijkstra's Algorithm When all arc lengths are nonnegative, as in Fig. 11, an efficient greedy algorithm can solve the shortest path problem. Starting with the source node alone, the algorithm finds the shortest path from the source node to one additional node in each subsequent iteration. The procedure requires m - 1 iterations to find the shortest path tree. The algorithm uses a set S, called the set of solved nodes. This set includes the nodes for which the shortest path has already been determined at the current point in the algorithm. The unsolved nodes are the nodes not in S, defined as the set S . While iterating, the algorithm assigns the numbers i to each node in the network, where i is the length of the shortest path to node i from the source node s through the members of S. Note that the -values are equivalent to the dual variables associated with the mathematical programming formulation of the problem. At the end of the algorithm i is the length of the shortest path to node i. In the following M is the set of all arcs. Algorithm Initially, let S = {s}, s = 0. Repeat until S is the set of all nodes: Find an arc k(i, j) that passes from a solved node to an unsolved node such that: k(i, j) = argmin{ i' + ck' : k'(i', j') M , i' S, j' S } Add node j and arc k to the tree. Add node j to the solved set S. Let j = i + ck . At each iteration the algorithm computes the length of the path to every unsolved node through only solved nodes. The unsolved node with the shortest path length is added to the solved set. The process terminates when a spanning tree is obtained. Since a node is added to the tree at each step the algorithm requires m 1 iterations. The algorithm works because of the assumption of nonnegative arc lengths. Example Consider the network in Fig. 11. The problem is to find the shortest path tree rooted at node 1. For hand computations, the algorithm is easily accomplished on the figure describing the problem. Figure 13 shows the intermediate situation with five nodes assigned to the tree, S = {1, 3, 4, 6, 2} with arcs {2, 3, 6, 7} (note that the order of the items in the sets shows the order in which they were added in the algorithm). The bold numbers in brackets indicate the values of associated with the nodes in the set S. For example, the shortest path to node 6 is 10. The bracketed numbers on the nodes in S show the length of the shortest paths to unsolved nodes passing through only nodes in S. For example, the shortest path passing through S to node 8 is 14. The

Solution Methods for the Shortest Path Tree Problem

15

algorithm now selects the arc and node associated with the smallest i value for i S . In reduced terms, the choice is min{18, 22, 14, 13} = 13 so node 9 and arc 14 join the tree. [dual () value] (arc length)
[12] 2 (6) (40) 1 [0] 1 (8) 2 (10) 3 5 7 [8] 3 (2) 8 (12) 6 6 (1) 9 4 [10] (6) 19 (3) 14 9 [13] (4) (2) 10 12 (2) [10] (4) 13 21 (10) 17 8 (10) 4 [18] 5 (0) (4) 11 16 (20) 15 [14] (20) 18 (2) 20 10 (1) [22] 7

Figure 13. Intermediate point in Dijkstra's Algorithm with S = {1, 3, 4, 6, 2} Tabular Implementation An alternative statement of the algorithm constructs a table with seven columns. Initialization: Let h = 1 and let s be the origin node. Let S = {s}, let s = 0. Interative step: Repeat until all nodes are in the set S a. Add to the table Column 1: Show the value of h. At any step, h is the number of nodes in the S. Column 2: List the members of S (the solved set) that have at least one arc connected to an unsolved node. Column 3: For each node listed in column 2, find the closest unsolved node. Column 4: Let i be the index of the node listed in column 2, let j be the index of the node listed in column 3, and let k be the index of the arc connecting nodes i and j. Compute for each case j' = i + ck . Show these numbers in column 4.

16

Network Flow Programming Methods Column 5: Select the smallest number in column 4. Let i be the node in column 2 and j the node in column 3 from which this number was computed. Show node j in column 5. Column 6: Show the length of the shortest path to the node added. This is the minimum obtained from column 4. Column 7: Show the arc k(i, j). Add node j and arc k to the shortest path tree. b. Add node j to S. Let j = j' . The steps of the algorithm for the example of Fig. 11 are shown in Table 3. The optimal tree is displayed in Fig. 12. Table 3. Shortest path computations for network in Fig. 11 Solved nodes 1 1 3 1 3 4 1 3 6 2 6 2 6 9 2 8 9 2 5 8 9 2 5 Closest unsolved node 3 4 6 2 6 6 2 2 9 5 9 5 8 10 5 5 10 7 7 10 10 7 7 Length of path to unsolved node 8 10 10 40 10 11 40 12 13 18 13 18 14 15 18 14 15 22 18 34 15 22 18 Node added to solved set 3 4 6 2 9 8 5 Length of shortest path 8 10 10 12 13 14 14 Arc added to tree 2 3 6 7 14 13 17

h 1 2 3 4 5 6 7 8

10 7

15 18

20 11

Primal Simplex Algorithm The primal simplex algorithm can also be used to solve the shortest path tree problem but is not limited to the case of all nonnegative arc lengths. It required, however, that there exist no directed cycles with negative total length. If such a cycle were present, the simplex algorithm would yield an unbounded solution.

Solution Methods for the Shortest Path Tree Problem

17

The algorithm described below is a variant on the pure network flow programming algorithm discussed in Section 5.4 of this chapter. As with all simplex-based procedures, the optimal solution to the shortest path problem is a basic solution. The algorithm for the shortest path problem makes use of the critical property that any collection of arcs that forms a spanning tree is a basic solution. Algorithm 1. Start with a basis described by the arcs of a spanning tree. Assign the dual value s = 0. 2. Repeat until all marginal costs are nonnegative: a. Compute the dual values for all nodes but the source node s such that if arc k(i, j) is in the basis j = i + ck . b. Compute the marginal costs, dk , for each nonbasic arc k(i, j), where dk = i + ck j. c. Select some nonbasic arc for which dk < 0 and call it the entering arc. The leaving arc is the arc in the tree that currently enters node j. d. Change the basis by removing the leaving arc from the tree and adding the entering arc. Compute the dual solution associated with the new basis. Example We use the example problem in Fig. 11 to illustrate the computations but assume arc 4(2, 7) has length 10 rather than 10. The arcs shown in Fig. 12 form the initial basis. The node labels in that figure are equivalent to the values of computed in Step 2a of the algorithm. With c4 = 10, we compute for arc 4 d4 = 2 + c4 7 = 12 10 18 = 6. Because d4 is negative, we select arc 4 to enter the basis. According to Step 2c of the algorithm the arc that currently enters node 7 must leave the basis. We change the basis and obtain the new spanning tree in Fig. 14. The dual values are shown adjacent to the nodes.

18

Network Flow Programming Methods

[12] (-10) 2 4 [14] 7 [0] 1 (8) 2 (10) 3 [10] 4 3 (2) 6 6 (3) 14 [10] (4) 13 (4) [8] 5 (0) 17

[2] 7

[dual () value] (arc length)

[14] 8 (2) 20 [13] 9

[15] 10

Figure 14. New basis after an iteration of the primal simplex algorithm At the next iteration we find that arcs 15 and 16 are candidates to enter the basis, so the solution in Fig. 14 is not optimal.

You might also like