17. Graph/traversaldfs.cpp
void dfsrec2(vector<int>adj[] , int s , vector<bool>&visited){
    visited[s]=true;
    cout<<s<<" ";
    for(int u : adj[s]){
        if(visited[u]==false){
            dfsrec2(adj , u , visited);
        }
    }
}
//dfs for graph having various connected components

dfs for graph having various connected components
dfs for graph having various connected components
void dfsrec2(vector<int>adj[] , int s , vector<bool>&visited){
    visited[s]=true;
    cout<<s<<" ";
    for(int u : adj[s]){
        if(visited[u]==false){
            dfsrec2(adj , u , visited);
        }
    }
}
void dfsrec2 ( vector < int > adj [ ] , int s , vector < bool > & visited ) { visited [ s ] = true ; cout << s << " " ; for ( int u : adj [ s ] ) { if ( visited [ u ] == false ) { dfsrec2 ( adj , u , visited ) ; } } }
dfs for graph having various connected components
dfs for graph having various connected components