Docs: Update benchmark results

This commit is contained in:
github-actions[bot]
2025-11-27 19:36:55 +00:00
parent e8b9dd6d0e
commit ba567f4017
109 changed files with 1138 additions and 1679 deletions

View File

@@ -1,12 +1,10 @@
async function findShortestPath(graph, start, end) {
const { default: PriorityQueue } = await import("https://esm.run/js-priority-queue");
const dist = {}, visited = new Set();
for (let n in graph) dist[n] = Infinity;
dist[start] = 0;
const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.4.1/+esm');
const dist = { [start]: 0 };
const visited = new Set();
const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] });
pq.queue([start, 0]);
while (pq.length) {
@@ -17,16 +15,17 @@ async function findShortestPath(graph, start, end) {
if (node === end) return d;
for (let neighbor in graph[node] || {}) {
if (visited.has(neighbor)) continue;
const newDist = d + graph[node][neighbor];
if (newDist < dist[neighbor]) {
for (const [neighbor, weight] of Object.entries(graph[node] || {})) {
const newDist = d + weight;
if (newDist < (dist[neighbor] ?? Infinity)) {
dist[neighbor] = newDist;
pq.queue([neighbor, newDist]);
}
}
}
return dist[end] ?? Infinity;
return Infinity;
}
export default findShortestPath;
export default findShortestPath;
// Generation time: 4.850s
// Result: FAIL