mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-07-18 05:45:46 +00:00
Docs: Update benchmark for x-ai/grok-4.5
This commit is contained in:
26
tests/1_dijkstra/outputs/x-ai_grok-4.5.js
Normal file
26
tests/1_dijkstra/outputs/x-ai_grok-4.5.js
Normal file
@@ -0,0 +1,26 @@
|
||||
async function findShortestPath(graph, start, end) {
|
||||
const { default: PriorityQueue } = await import('https://esm.sh/js-priority-queue');
|
||||
const dist = {};
|
||||
for (const node of Object.keys(graph)) dist[node] = Infinity;
|
||||
dist[start] = 0;
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] });
|
||||
pq.queue([start, 0]);
|
||||
const visited = new Set();
|
||||
while (pq.length) {
|
||||
const [u, cost] = pq.dequeue();
|
||||
if (visited.has(u)) continue;
|
||||
visited.add(u);
|
||||
if (u === end) return cost;
|
||||
for (const [v, weight] of Object.entries(graph[u] || {})) {
|
||||
const alt = cost + weight;
|
||||
if (alt < (dist[v] ?? Infinity)) {
|
||||
dist[v] = alt;
|
||||
pq.queue([v, alt]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
}
|
||||
export default findShortestPath;
|
||||
// Generation time: 22.841s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user