Bfs shortest path error


cna u plz check this out where the error is??

check ur updated code here->


just changed 1 based indexing to 0 based indexing,
rest evrthing is correct

okay if there is an vertices 0 also then it would be fine na??

previous indexing if 0 is also present in vertices

they will never give 0 as an input, all the input will be gretaer than 0 because of 1 based indexing

@aman212yadav
u have converted the 1 based index to zero based indexing like
for(int i=0;i<m;i++){
int e,r;

		cin>>e>>r;
		e--;
		r--;
		g.addedge(e,r);
	}

what if you can do this?? If u are not allowed to do that… Then what should we do here…