mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 08:37:56 +00:00
Docs: Update Gemini benchmark results
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: Q } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new Q({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1/0)) continue
|
||||
|
||||
for (let v in g[n]) {
|
||||
let t = w + g[n][v]
|
||||
if (t < (d[v] ?? 1/0)) {
|
||||
d[v] = t
|
||||
q.queue({ n: v, w: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1/0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,19 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new P({ comparator: (a, b) => a.w - b.w }), d = { [s]: 0 };
|
||||
q.queue({ n: s, w: 0 });
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue();
|
||||
if (n === e) return w;
|
||||
if (w > (d[n] ?? 1 / 0)) continue;
|
||||
for (const k in g[n] || {}) {
|
||||
const t = w + g[n][k];
|
||||
if (t < (d[k] ?? 1 / 0)) {
|
||||
d[k] = t;
|
||||
q.queue({ n: k, w: t });
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,20 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new P({ comparator: (a, b) => a.w - b.w })
|
||||
const m = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (m[n] ?? 1 / 0)) continue
|
||||
for (const k in g[n] || {}) {
|
||||
const t = w + g[n][k]
|
||||
if (t < (m[k] ?? 1 / 0)) {
|
||||
m[k] = t
|
||||
q.queue({ n: k, w: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,22 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1 / 0)) continue
|
||||
|
||||
for (const [v, cost] of Object.entries(g[n] || {})) {
|
||||
const t = w + cost
|
||||
if (t < (d[v] ?? 1 / 0)) {
|
||||
d[v] = t
|
||||
q.queue({ n: v, w: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,19 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: Q } = await import('https://esm.sh/js-priority-queue')
|
||||
const d = { [s]: 0 }, q = new Q({ comparator: (a, b) => a.w - b.w })
|
||||
q.queue({ n: s, w: 0 })
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1 / 0)) continue
|
||||
for (const [v, c] of Object.entries(g[n] || {})) {
|
||||
const k = w + c
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,24 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }, v = new Set()
|
||||
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (v.has(n)) continue
|
||||
v.add(n)
|
||||
|
||||
for (const k in g[n]) {
|
||||
const t = w + g[n][k]
|
||||
if (t < (d[k] ?? Infinity)) {
|
||||
d[k] = t
|
||||
q.queue({ n: k, w: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,25 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w });
|
||||
const d = { [s]: 0 };
|
||||
|
||||
q.queue({ w: 0, n: s });
|
||||
|
||||
while (q.length) {
|
||||
const { w, n } = q.dequeue();
|
||||
|
||||
if (n === e) return w;
|
||||
if (w > (d[n] ?? 1 / 0)) continue;
|
||||
|
||||
for (const v in g[n]) {
|
||||
const k = w + g[n][v];
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k;
|
||||
q.queue({ w: k, n: v });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / 0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,19 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new P({ comparator: (a, b) => a.c - b.c }), d = { [s]: 0 };
|
||||
q.queue({ n: s, c: 0 });
|
||||
while (q.length) {
|
||||
const { n, c } = q.dequeue();
|
||||
if (n === e) return c;
|
||||
if (c > (d[n] ?? 1 / 0)) continue;
|
||||
for (let v in g[n]) {
|
||||
let k = c + g[n][v];
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k;
|
||||
q.queue({ n: v, c: k });
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,25 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const d = { [s]: 0 }
|
||||
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1 / 0)) continue
|
||||
|
||||
for (const k in g[n] || {}) {
|
||||
const c = w + g[n][k]
|
||||
if (c < (d[k] ?? 1 / 0)) {
|
||||
d[k] = c
|
||||
q.queue({ n: k, w: c })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,19 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w }), d = { [s]: 0 }
|
||||
q.queue({ n: s, w: 0 })
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === e) return w
|
||||
if (w > (d[n] ?? 1/0)) continue
|
||||
for (const [v, c] of Object.entries(g[n] || {})) {
|
||||
const k = w + c
|
||||
if (k < (d[v] ?? 1/0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1/0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,25 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue/+esm')
|
||||
const costs = { [start]: 0 }
|
||||
const queue = new PQ({ comparator: (a, b) => a.cost - b.cost })
|
||||
|
||||
queue.queue({ node: start, cost: 0 })
|
||||
|
||||
while (queue.length) {
|
||||
const { node, cost } = queue.dequeue()
|
||||
|
||||
if (node === end) return cost
|
||||
if (cost > (costs[node] ?? Infinity)) continue
|
||||
|
||||
for (const [neighbor, weight] of Object.entries(graph[node] || {})) {
|
||||
const nextCost = cost + weight
|
||||
if (nextCost < (costs[neighbor] ?? Infinity)) {
|
||||
costs[neighbor] = nextCost
|
||||
queue.queue({ node: neighbor, cost: nextCost })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,24 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PQ } = await import('https://cdn.skypack.dev/js-priority-queue');
|
||||
const queue = new PQ({ comparator: (a, b) => a.d - b.d });
|
||||
const dists = { [start]: 0 }, visited = new Set();
|
||||
|
||||
queue.queue({ n: start, d: 0 });
|
||||
|
||||
while (queue.length) {
|
||||
const { n, d } = queue.dequeue();
|
||||
if (n === end) return d;
|
||||
if (visited.has(n)) continue;
|
||||
visited.add(n);
|
||||
|
||||
for (const [neighbor, weight] of Object.entries(graph[n] || {})) {
|
||||
const newDist = d + weight;
|
||||
if (newDist < (dists[neighbor] ?? Infinity)) {
|
||||
dists[neighbor] = newDist;
|
||||
queue.queue({ n: neighbor, d: newDist });
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
};
|
||||
export default findShortestPath;
|
||||
Reference in New Issue
Block a user