Function traversing the graph using DFS approach and updating the set of nodes
void dfs ( bool visit [ ] , int src ) { visit [ src ] = true ; node . insert ( src ) ; int len = Graph [ src ] . size ( ) ; for ( int i = 0 ; i < len ; i ++ ) if ( ! visit [ Graph [ src ] [ i ] ] ) dfs ( visit , Graph [ src ] [ i ] ) ; }