Draymonders/Code-Life

floyd算法简单解释

Opened this issue · 0 comments

// dp[i][j][k-1] 是否能借助前k-1这个点,使得 (i,j)联通
for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++)
            if (dp[i][j])
                continue;
            else
                dp[i][j] = (dp[i][k] && dp[k][j]);
    }
}