mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update benchmark for minimax/minimax-m2.5
This commit is contained in:
32
tests/1_dijkstra/outputs/minimax_minimax-m2.5.js
Normal file
32
tests/1_dijkstra/outputs/minimax_minimax-m2.5.js
Normal file
@@ -0,0 +1,32 @@
|
||||
async function findShortestPath(graph, start, end) {
|
||||
if (!(start in graph) || !(end in graph)) return Infinity;
|
||||
if (start === end) return 0;
|
||||
|
||||
const { default: PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue');
|
||||
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a.w - b.w });
|
||||
const dist = {};
|
||||
|
||||
for (const n in graph) dist[n] = Infinity;
|
||||
dist[start] = 0;
|
||||
pq.queue({ n: start, w: 0 });
|
||||
|
||||
while (pq.length) {
|
||||
const { n, w } = pq.dequeue();
|
||||
if (w !== dist[n]) continue;
|
||||
if (n === end) return w;
|
||||
|
||||
for (const [nb, wgt] of Object.entries(graph[n] || {})) {
|
||||
const ndist = w + wgt;
|
||||
if (ndist < dist[nb]) {
|
||||
dist[nb] = ndist;
|
||||
pq.queue({ n: nb, w: ndist });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity;
|
||||
}
|
||||
export default findShortestPath;
|
||||
// Generation time: 64.656s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user