//dfs traversal of undirected graph using stack approach #include using namespace std; int main() { int n,m; cin>>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); stacks; s.push(1); while(!s.empty()) { int t=s.top(); if(!v[t]) { v[t]=1;//mark the vertex as visited cout<