I am not able to understand how can we represent the undirected graph having n nodes using a vector of type int of size n+1
Why is the correct option D and not option B?
ans is D because all options are correct , let me explain how,
-
vector < int > graph [ N + 1 ]
Here what is happening is we are declaring an array of vector and the array size is N+1 .
how?? , when we do int arr[N+1] it means an array of type int with size N+1 similary if you replace int with vector , you will get vector arr[N+1] , thus u will get an array of type vector with size N+1. so you got a 2D data structure which can be used to implement adjacency list -
since you think b is the answer then i am assuming you know why
-
vector < vector < int > > graph(N+1) here we are declaring a vector of type vector of size N+1 , which is again a 2D structure and can be used to represent adjacency list
In case of any doubt feel free to ask 
mark your doubt as RESOLVED if you got the answer
Thanks for the excellent clarification. Cheers!