mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Refactor: Remove stale benchmark outputs
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
export async function findShortestPath(graph, start, end) {
|
||||
if (start === end) return 0
|
||||
if (!graph || typeof graph !== "object") return Infinity
|
||||
|
||||
const { default: PriorityQueue } = await import(
|
||||
"https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm"
|
||||
)
|
||||
|
||||
const dist = Object.create(null)
|
||||
dist[start] = 0
|
||||
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a[0] - b[0] })
|
||||
pq.queue([0, start])
|
||||
|
||||
while (pq.length) {
|
||||
const [d, u] = pq.dequeue()
|
||||
if (d !== dist[u]) continue
|
||||
if (u === end) return d
|
||||
|
||||
const nbrs = graph[u]
|
||||
if (!nbrs || typeof nbrs !== "object") continue
|
||||
|
||||
for (const v in nbrs) {
|
||||
const w = +nbrs[v]
|
||||
if (!Number.isFinite(w) || w < 0) continue
|
||||
const nd = d + w
|
||||
const cur = dist[v]
|
||||
if (cur === undefined || nd < cur) {
|
||||
dist[v] = nd
|
||||
pq.queue([nd, v])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
// Generation time: 6.889s
|
||||
// Result: PASS
|
||||
@@ -1,26 +0,0 @@
|
||||
async function findShortestPath(g, s, t) {
|
||||
if (!(s in g) || !(t in g)) return Infinity;
|
||||
const { PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue');
|
||||
const d = {}, v = new Set();
|
||||
for (const n in g) d[n] = Infinity;
|
||||
d[s] = 0;
|
||||
const q = new PriorityQueue({ comparator: (a, b) => a[0] - b[0] });
|
||||
q.queue([0, s]);
|
||||
while (q.length) {
|
||||
const [dist, u] = q.dequeue();
|
||||
if (v.has(u)) continue;
|
||||
if (u === t) return dist;
|
||||
v.add(u);
|
||||
for (const [nbr, w] of Object.entries(g[u])) {
|
||||
const nd = dist + w;
|
||||
if (nd < d[nbr]) {
|
||||
d[nbr] = nd;
|
||||
q.queue([nd, nbr]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
}
|
||||
export default findShortestPath;
|
||||
// Generation time: 2.281s
|
||||
// Result: FAIL
|
||||
@@ -1,25 +0,0 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PriorityQueue } = await import('https://esm.sh/js-priority-queue');
|
||||
const dist = { [start]: 0 };
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a.w - b.w });
|
||||
pq.queue({ v: start, w: 0 });
|
||||
|
||||
while (pq.length) {
|
||||
const { v, w } = pq.dequeue();
|
||||
if (v === end) return w;
|
||||
if (w > (dist[v] ?? Infinity)) continue;
|
||||
|
||||
const edges = graph[v] || {};
|
||||
for (const n in edges) {
|
||||
const nd = w + edges[n];
|
||||
if (nd < (dist[n] ?? Infinity)) {
|
||||
dist[n] = nd;
|
||||
pq.queue({ v: n, w: nd });
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
};
|
||||
export default findShortestPath;
|
||||
// Generation time: 136.164s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user