Docs: Update benchmark results

This commit is contained in:
github-actions[bot]
2025-11-07 21:32:49 +00:00
parent f9da7d4ed7
commit d0bc3b95dd
54 changed files with 1115 additions and 372 deletions

View File

@@ -1,26 +1,22 @@
const findShortestPath = async (graph, start, end) => {
const { default: PriorityQueue } = await import(
'https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm'
);
const distances = Object.keys(graph).reduce((acc, node) => {
acc[node] = node === start ? 0 : Infinity;
return acc;
}, {});
async function findShortestPath(graph, start, end) {
const { default: PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue');
const distances = Object.keys(graph).reduce((acc, node) => ({ ...acc, [node]: Infinity }), {});
distances[start] = 0;
const pq = new PriorityQueue({ comparator: (a, b) => a.dist - b.dist });
const visited = new Set();
pq.queue({ node: start, dist: 0 });
const visited = new Set();
while (pq.length) {
const { node, dist } = pq.dequeue();
if (visited.has(node)) continue;
if (node === end) return dist;
visited.add(node);
if (node === end) return dist;
for (const [neighbor, weight] of Object.entries(graph[node] || {})) {
const newDist = dist + weight;
if (newDist < distances[neighbor]) {
@@ -29,7 +25,7 @@ const findShortestPath = async (graph, start, end) => {
}
}
}
return distances[end];
};
}
export default findShortestPath;