For all it 's child nodes
for ( int i = 0 ; i < gr . get ( child ) . size ( ) ; i ++ ) { if ( gr . get ( child ) . get ( i ) == par ) continue ; dfs ( gr . get ( child ) . get ( i ) , child , color ) ; } }