Array of list in graph doubt

list*l Why we use pointer in this?
please make me clear this doubt.

and also l=new list[v] why we use this

@divesh2000
We use a pointer because we initially do not the size of the array of lists earlier. But when we get to know of the number of nodes, we pass the number to the constructor of the class and here, we are able to perform dynamic allocation of an array of V lists.

If my reply was able to answer your query, please mark the doubt as resolved.

Here, I am talking about *l.Why we use *l?

@divesh2000
That’s what I was telling you. *l is a pointer. We declare a pointer first and when we get the number of vertices, we pass the number of vertices in the constructor and perform dynamic allocation of memory to the pointer because in this way, no extra memory is being consumed.

If my reply was able to answer your query, please mark the doubt as resolved.

okay ,I get it .
Thanks for the nice explaination.

i have also one doubt . How iterator is working int the code of BFS ( for(int nbr:l[node]) ).Please check the code ,and explain it