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]);
}

 

posted @ 2015-08-09 11:27  JoneZP  阅读(384)  评论(0编辑  收藏  举报