Mark current as visited
visited [ current ] = true ; for ( int i = 0 ; i < g [ current ] -> children . size ( ) ; i ++ ) { int v = g [ current ] -> children [ i ] . first ; if ( visited [ v ] ) continue ;