Adjacency List program

program which you write here I also copy this code but it does not print any thing ?
#include
#include<bits/stdc++.h>
#include
using namespace std;
class Graph {
int V;
list *l;
public:
Graph(int V){
this->V= V;
l=new list[V];
}
void addEdge(int x,int y){
l[x].push_back(y);
l[y].push_back(x);
}
void printAdjList() {
for(int i=0;i<V;i++){
cout<<“Vertex “<<i<<”–>”;
for(int x:l[i])
cout<<x<<",";
cout<<endl;
}
}
};
int main() {
Graph g(4);
g.addEdge(0,1);
g.addEdge(0,2);
g.addEdge(1,2);
g.addEdge(2,3);
return 0;

you have to call the print function
which you forgot to call G.printAdjList();\

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.