heap.c
void decreaseKey(struct MinHeap *minHeap, int v, int dist) {

    int i = minHeap->pos[v];

    minHeap->array[i]->dist = dist;

    while (i && minHeap->array[i]->dist < minHeap->array[(i - 1) / 2]->dist)
    {

        minHeap->pos[minHeap->array[i]->v] = (i - 1) / 2;
        minHeap->pos[minHeap->array[(i - 1) / 2]->v] = i;
        swapMinHeapNode(&minHeap->array[i], &minHeap->array[(i - 1) / 2]);

        i = (i - 1) / 2;
    }
}
// Function to decrease key value of a given vertex v. This function
// uses pos[] of min heap to get the current index of node in min heap
Function to decrease key value of a given vertex v. This function
uses pos[] of min heap to get the current index of node in min heap
Function to decrease key value of a given vertex v . This function uses pos [] of min heap to get the current index of node in min heap
void decreaseKey(struct MinHeap *minHeap, int v, int dist) {
    int i = minHeap->pos[v];
    minHeap->array[i]->dist = dist;
    while (i && minHeap->array[i]->dist < minHeap->array[(i - 1) / 2]->dist)
    {
        minHeap->pos[minHeap->array[i]->v] = (i - 1) / 2;
        minHeap->pos[minHeap->array[(i - 1) / 2]->v] = i;
        swapMinHeapNode(&minHeap->array[i], &minHeap->array[(i - 1) / 2]);
        i = (i - 1) / 2;
    }
}
void decreaseKey ( struct MinHeap * minHeap , int v , int dist ) { int i = minHeap -> pos [ v ] ; minHeap -> array [ i ] -> dist = dist ; while ( i && minHeap -> array [ i ] -> dist < minHeap -> array [ ( i - 1 ) / 2 ] -> dist ) { minHeap -> pos [ minHeap -> array [ i ] -> v ] = ( i - 1 ) / 2 ; minHeap -> pos [ minHeap -> array [ ( i - 1 ) / 2 ] -> v ] = i ; swapMinHeapNode ( & minHeap -> array [ i ] , & minHeap -> array [ ( i - 1 ) / 2 ] ) ; i = ( i - 1 ) / 2 ; } }
Function to decrease key value of a given vertex v. This function
uses pos[] of min heap to get the current index of node in min heap
Function to decrease key value of a given vertex v . This function uses pos [] of min heap to get the current index of node in min heap