Update dijkstra.c (#928)

in this way valgrind checks will pass and result will stay the same (functions as a static variable)
This commit is contained in:
Idan BananI 2022-01-11 20:20:32 +02:00 committed by GitHub
parent bd06a9f424
commit 0ceb3b340e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -32,7 +32,8 @@ void addEdge(struct Graph *G, int src, int dst, int weight)
// Utility function to find minimum distance vertex in mdist
int minDistance(int mdist[], int vset[], int V)
{
int minVal = INT_MAX, minInd;
int minVal = INT_MAX;
static int minInd = -1; //remembers the previous value if not modified in the loop
for (int i = 0; i < V; i++)
if (vset[i] == 0 && mdist[i] < minVal)
{