Can you tell my mistake?

int *parent=new int[v]{-1};
actually this statement will not initialize the array with -1
you check this by printing the array

this will only initialize the first element of array to -1 rest are 0;

you have to run a loop and initialize every element =-1;