//dfs traversal of undirected graph using recursive approach #include using namespace std; void dfs(vector>&adj, vector&v,int x) { v[x]=1; cout<>n>>m;//enter the number of vertices and number of edges vector>adj(n+1,vector()); //create an adjacency list according to the edges given in input for(int i=0;i>u>>v; adj[u].push_back(v); adj[v].push_back(u); } cout<<"The dfs traversal is \n"; vectorv(n+1,0); dfs(adj,v,1); return 0; } //INPUT //6 5 //1 2 //2 6 //1 3 //3 4 //3 5 //OUTPUT //The dfs traversal is //1 2 6 3 4 5 //TIME COMPLEXITY OF THE PROGRAM //O(V+E) //where V is number of vertices //and E is number of edges