Function
checkNeighbors
(graph, cost, city, stops, seen, minHeap)
Source from the content-addressed store, hash-verified
| 52 | }; |
| 53 | |
| 54 | var checkNeighbors = (graph, cost, city, stops, seen, minHeap) => { |
| 55 | for (let [nextCity, nextCost] of graph[city]) { |
| 56 | const hasSeen = seen.has(nextCity) && stops - 1 <= seen.get(nextCity); |
| 57 | if (hasSeen) continue; |
| 58 | |
| 59 | const priority = cost + nextCost; |
| 60 | const node = [priority, nextCity, stops - 1]; |
| 61 | |
| 62 | minHeap.enqueue(node, priority); |
| 63 | } |
| 64 | }; |
Tested by
no test coverage detected