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