Floyd 无向图模板

这是无向图的

void Floyd()
{
    memset(v, 0x3f, sizeof v);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
        v[i][j] = map[i][j];
    for(int k = 1; k <= n; k++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
            v[i][j] = v[j][i] =min(v[i][j], v[i][k]+v[k][j]);
}

 

转载于:https://www.cnblogs.com/ZP-Better/p/4714824.html

你可能感兴趣的:(Floyd 无向图模板)