动态规划算法——弗洛伊德算法(Dynamic Programming Algorithm - Floyd's Algorithm)

动态规划算法——弗洛伊德算法(Dynamic Programming Algorithm - Floyd’s Algorithm)


伪代码(Pseudocode)

function Floyd(W[1..n, 1..n])
    D ⟵ W
    for k ⟵ 1 to n do
        for i ⟵ 1 to n do
            for j ⟵ 1 to n do
                D[i, j] ⟵ min(D[i, j], D[i, k] + D[k, j])
    return D

时间复杂度(Time Complexity)
Time complexity of Floyd’s algorithm is Θ(n^3).

你可能感兴趣的:(算法,动态规划,算法,Floyd)