Traverse its neighbors
for ( let it = 0 ; it < adj [ current_node ] . length ; it ++ ) { if ( adj [ current_node ] [ it ] != prev_node ) dfs ( adj [ current_node ] [ it ] , current_node , len + 1 , add_to_map , adj ) ; } }