let line = [
[1, 2, 5],
[4, 2, 3],
[1, 3, 4],
[2, 3, -3],
[3, 4, 5],
[2, 5, 13],
[4, 5, 7],
];
const Ed = [];
for (let i = 0; i < line.length; ++i) {
const [a, b, c] = line[i];
Ed.push({s: a, e: b, val: c});
}
const dist = Array.from(Array(10), () => Array(10).fill(99999));
let start = 1;
let end = 5;
for (let i = 1; i < Ed.length; ++i) {
dist[i - 1][start] = 0;
for (let j = 0; j < Ed.length; ++j) {
const {s, e, val} = Ed[j];
if (dist[i - 1][s] != 99999 && dist[i - 1][s] + val < dist[i][e]) {
dist[i][e] = dist[i - 1][s] + val;
}
}
}
console.log();
음의 사이클 캐치한분 잇음 저도 알려줏세무