📅  最后修改于: 2022-03-11 14:55:25.537000             🧑  作者: Mango
1. F graph (graph G, int K, int n, int p[])
2. {
3. Float cost [max size], int d [max size], r;
4. Cost [n] = 0.0
5. For (int j = n-1; j>= 1; j--)
6. {
7. Let r be a vertex such that is an edge of G and C[j][r] + cost[r] is minimum;
8. Cost [j] = C[j][r] + Cost[r]
9. D [j] = r
10. }
11. P [1] = 1 , P[k] = n
12. For (j = 2 ; j <= K-1; j++)
13. P[j] = d[P(j-1)];
14. }