mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 16:47:55 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
async function findShortestPath(graph, start, end) {
|
||||
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm');
|
||||
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]: Infinity }), {});
|
||||
distances[start] = 0;
|
||||
|
||||
const pq = new PQ({ comparator: (a, b) => a.dist - b.dist });
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a.dist - b.dist });
|
||||
pq.queue({ node: start, dist: 0 });
|
||||
|
||||
const visited = new Set();
|
||||
|
||||
while (pq.length) {
|
||||
while (pq.length > 0) {
|
||||
const { node, dist } = pq.dequeue();
|
||||
|
||||
if (visited.has(node)) continue;
|
||||
|
||||
Reference in New Issue
Block a user