Skip to content

Commit 77e7eba

Browse files
fix: int overflow in floyd_warshall
1 parent a0abcbe commit 77e7eba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dynamic_programming/floyd_warshall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <climits>
2+
#include <cstddef>
23
#include <iostream>
3-
#include <string>
44
#include <vector>
55

66
using std::cin;
@@ -55,7 +55,7 @@ void print(const std::vector<int> dist, int V) {
5555
// The main function that finds the shortest path from a vertex
5656
// to all other vertices using Floyd-Warshall Algorithm.
5757
void FloydWarshall(Graph graph) {
58-
int V = graph.vertexNum;
58+
std::size_t V = graph.vertexNum;
5959
std::vector<std::vector<int> > dist(V, std::vector<int>(V));
6060

6161
// Initialise distance array

0 commit comments

Comments
 (0)