mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update benchmark for openrouter/pony-alpha
This commit is contained in:
25
tests/1_dijkstra/outputs/openrouter_pony-alpha.js
Normal file
25
tests/1_dijkstra/outputs/openrouter_pony-alpha.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PriorityQueue } = await import('https://esm.sh/js-priority-queue');
|
||||
const dist = { [start]: 0 };
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a.w - b.w });
|
||||
pq.queue({ v: start, w: 0 });
|
||||
|
||||
while (pq.length) {
|
||||
const { v, w } = pq.dequeue();
|
||||
if (v === end) return w;
|
||||
if (w > (dist[v] ?? Infinity)) continue;
|
||||
|
||||
const edges = graph[v] || {};
|
||||
for (const n in edges) {
|
||||
const nd = w + edges[n];
|
||||
if (nd < (dist[n] ?? Infinity)) {
|
||||
dist[n] = nd;
|
||||
pq.queue({ v: n, w: nd });
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
};
|
||||
export default findShortestPath;
|
||||
// Generation time: 136.164s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user