Bellman ford algorithm
for ( var i = 0 ; i < n - 1 ; i ++ ) { for ( var j = 0 ; j < ed . length ; j ++ ) { dis [ ed [ j ] [ 0 ] [ 1 ] ] = Math . min ( dis [ ed [ j ] [ 0 ] [ 1 ] ] , dis [ ed [ j ] [ 0 ] [ 0 ] ] * ed [ j ] [ 1 ] ) ; } }