We apply recursive equation to distance to target through j . and compare with minimum distance so far .
dist [ i ] = Math . min ( dist [ i ] , graph [ i ] [ j ] + dist [ j ] ) ; } } return dist [ 0 ] ; }