Condition to check the distance is correct and update it if it is minimum from the previous computed distance
if ( alt < dist [ v ] ) { dist [ v ] = alt ; path [ v ] = current ; } } sett . erase ( current ) ; if ( sett . empty ( ) ) break ;