Floyd Warshall algorithm

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
283 B
3
Indexable
Never
void floyd_warshall(vector<vector<int> > &d){
  for (int k = 0; k < d.size(); k++)
        for (int i = 0; i <  d.size(); i++)
            for (int j = 0; j < d.size(); j++)
                if (d[i][k] + d[k][j] < d[i][j])
                      d[i][j] = d[i][k] + d[k][j];
}