Spot the flawed inequality used to verify a heuristic is consistent (monotonic).
Codejavascript
// A heuristic h is consistent if for every edge (n, m):
// h(n) <= cost(n, m) + h(m)
function isConsistent(edges, h) {
for (const { from, to, cost } of edges) {
if (h[from] > cost + h[from]) {
return false; // violation found
}
}
return true;
}