mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 08:37:56 +00:00
Docs: Update benchmark for z-ai/glm-4.7
This commit is contained in:
27
tests/1_dijkstra/outputs/z-ai_glm-4.7.js
Normal file
27
tests/1_dijkstra/outputs/z-ai_glm-4.7.js
Normal file
@@ -0,0 +1,27 @@
|
||||
async function findShortestPath(graph, start, end) {
|
||||
const { default: PriorityQueue } = await import('https://esm.sh/js-priority-queue@1.0.0');
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] });
|
||||
const costs = { [start]: 0 };
|
||||
pq.queue([start, 0]);
|
||||
|
||||
while (pq.length) {
|
||||
const [node, currentCost] = pq.dequeue();
|
||||
|
||||
if (node === end) return currentCost;
|
||||
if (currentCost > costs[node]) continue;
|
||||
|
||||
const neighbors = graph[node] || {};
|
||||
for (const [neighbor, weight] of Object.entries(neighbors)) {
|
||||
const newCost = currentCost + weight;
|
||||
if (newCost < (costs[neighbor] ?? Infinity)) {
|
||||
costs[neighbor] = newCost;
|
||||
pq.queue([neighbor, newCost]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity;
|
||||
}
|
||||
export default findShortestPath;
|
||||
// Generation time: 42.134s
|
||||
// Result: FAIL
|
||||
Reference in New Issue
Block a user