Recurrence relation
for ( let it = 0 ; it < ed . length ; it ++ ) dis1 [ ed [ it ] [ 1 ] ] = Math . min ( dis1 [ ed [ it ] [ 1 ] ] , dis [ ed [ it ] [ 0 ] ] + ed [ it ] [ 2 ] ) ; document . write ( ) for ( let j = 0 ; j <= n ; j ++ ) dis [ j ] = dis1 [ j ] ; }