Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void travel (int n,
- const number W [] [],
- index P [] [],
- number & minlength)
- {
- index i, j, k;
- number D [1 .. n] [subset of V - {v1}];
- for (i = 2; i <= n; i++)
- D [i] [⊘] = W[i] [1];
- for (k = 1; k <= n - 2; k++)
- for (all subsets A ⊆ V - {v1} containing k vertices)
- for (i such that i ≠ 1 and vi is not in A){
- D [i] [A] = minimum (W [i] [j] + D [j] [A - {vj}]);
- j: [vj ∊ A
- P[i] [A] = value of j that gave the minimum;
- }
- D [1] [V - {v1}] = minimum (W[1] [j] + D[j] [V - {v1, vj}]);
- 2 ≤ j ≤ n
- P[1] [V - {v1}] = value of j that gave the minimum;
- minlength = D[1] [V - {v1}];
- }
Advertisement
Add Comment
Please, Sign In to add comment