From 77e7ebadb400f34f717805d08391a1d0f9d8c59e Mon Sep 17 00:00:00 2001 From: realstealthninja <68815218+realstealthninja@users.noreply.github.com> Date: Fri, 4 Oct 2024 20:31:09 +0530 Subject: [PATCH] fix: int overflow in floyd_warshall --- dynamic_programming/floyd_warshall.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dynamic_programming/floyd_warshall.cpp b/dynamic_programming/floyd_warshall.cpp index d895af0d9..d192f25bc 100644 --- a/dynamic_programming/floyd_warshall.cpp +++ b/dynamic_programming/floyd_warshall.cpp @@ -1,6 +1,6 @@ #include +#include #include -#include #include using std::cin; @@ -55,7 +55,7 @@ void print(const std::vector dist, int V) { // The main function that finds the shortest path from a vertex // to all other vertices using Floyd-Warshall Algorithm. void FloydWarshall(Graph graph) { - int V = graph.vertexNum; + std::size_t V = graph.vertexNum; std::vector > dist(V, std::vector(V)); // Initialise distance array