mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-13 16:17:54 +00:00
Delete tests/1_dijkstra/outputs_gemini directory
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
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] ?? Infinity)) continue
|
||||
|
||||
for (let v in g[n]) {
|
||||
let k = w + g[n][v]
|
||||
if (k < (d[v] ?? Infinity)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,21 +0,0 @@
|
||||
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[1] - b[1] })
|
||||
q.queue([s, 0])
|
||||
|
||||
while (q.length) {
|
||||
const [u, w] = q.dequeue()
|
||||
if (u === e) return w
|
||||
if (w > (d[u] ?? 1/0)) continue
|
||||
|
||||
for (let v in g[u]) {
|
||||
const k = w + g[u][v]
|
||||
if (k < (d[v] ?? 1/0)) {
|
||||
d[v] = k
|
||||
q.queue([v, k])
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1/0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,25 +0,0 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm');
|
||||
const q = new P({ 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 k = w + g[n][v];
|
||||
if (k < (d[v] ?? 1/0)) {
|
||||
d[v] = k;
|
||||
q.queue({ n: v, w: k });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1/0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -1,21 +0,0 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const d = { [s]: 0 }, q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
q.queue({ n: s, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n: u, w } = q.dequeue()
|
||||
if (u === e) return w
|
||||
if (w > (d[u] ?? 1 / 0)) continue
|
||||
|
||||
for (const v in g[u]) {
|
||||
const nw = w + g[u][v]
|
||||
if (nw < (d[v] ?? 1 / 0)) {
|
||||
d[v] = nw
|
||||
q.queue({ n: v, w: nw })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,20 +0,0 @@
|
||||
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 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 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;
|
||||
@@ -1,19 +0,0 @@
|
||||
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 }), 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 in g[n]) {
|
||||
const k = w + g[n][v]
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,19 +0,0 @@
|
||||
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 }), 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 v in g[n]) {
|
||||
const k = w + g[n][v];
|
||||
if (k < (m[v] ?? 1/0)) {
|
||||
m[v] = k;
|
||||
q.queue({ n: v, w: k });
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1/0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -1,22 +0,0 @@
|
||||
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 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] ?? Infinity)) continue
|
||||
|
||||
for (const k in g[n]) {
|
||||
const c = w + g[n][k]
|
||||
if (c < (d[k] ?? Infinity)) {
|
||||
d[k] = c
|
||||
q.queue({ n: k, w: c })
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,24 +0,0 @@
|
||||
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, c] of Object.entries(g[n] || {})) {
|
||||
const t = w + c
|
||||
if (t < (d[v] ?? 1 / 0)) {
|
||||
d[v] = t
|
||||
q.queue({ n: v, w: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,19 +0,0 @@
|
||||
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;
|
||||
@@ -1,23 +0,0 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
|
||||
const q = new PQ({ comparator: (a, b) => a.w - b.w })
|
||||
const dist = { [start]: 0 }
|
||||
|
||||
q.queue({ n: start, w: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, w } = q.dequeue()
|
||||
if (n === end) return w
|
||||
if (w > (dist[n] ?? Infinity)) continue
|
||||
|
||||
for (const v in graph[n]) {
|
||||
const d = w + graph[n][v]
|
||||
if (d < (dist[v] ?? Infinity)) {
|
||||
dist[v] = d
|
||||
q.queue({ n: v, w: d })
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,19 +0,0 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: P } = await import('https://cdn.skypack.dev/js-priority-queue')
|
||||
const d = { [s]: 0 }, q = new P({ compare: (a, b) => a.w - b.w })
|
||||
q.queue({ id: s, w: 0 })
|
||||
while (q.length) {
|
||||
const { id, w } = q.dequeue()
|
||||
if (id === e) return w
|
||||
if (w > (d[id] ?? 1 / 0)) continue
|
||||
for (let n in g[id]) {
|
||||
const k = w + g[id][n]
|
||||
if (k < (d[n] ?? 1 / 0)) {
|
||||
d[n] = k
|
||||
q.queue({ id: n, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,22 +0,0 @@
|
||||
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: u, w: c } = q.dequeue()
|
||||
if (u === e) return c
|
||||
if (c > (d[u] ?? 1 / 0)) continue
|
||||
|
||||
for (const v in g[u] || {}) {
|
||||
const k = c + g[u][v]
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,25 +0,0 @@
|
||||
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.d - b.d })
|
||||
const D = { [s]: 0 }
|
||||
|
||||
q.queue({ n: s, d: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, d } = q.dequeue()
|
||||
|
||||
if (n === e) return d
|
||||
if (d > (D[n] ?? 1 / 0)) continue
|
||||
|
||||
for (const [v, w] of Object.entries(g[n] || {})) {
|
||||
const c = d + w
|
||||
if (c < (D[v] ?? 1 / 0)) {
|
||||
D[v] = c
|
||||
q.queue({ n: v, d: c })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,23 +0,0 @@
|
||||
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 in g[n] || {}) {
|
||||
const k = w + g[n][v]
|
||||
if (k < (d[v] ?? 1 / 0)) {
|
||||
d[v] = k
|
||||
q.queue({ n: v, w: k })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,21 +0,0 @@
|
||||
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 }), 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, v] of Object.entries(g[n] || {})) {
|
||||
const t = w + v;
|
||||
if (t < (m[k] ?? 1 / 0)) {
|
||||
m[k] = t;
|
||||
q.queue({ n: k, w: t });
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1 / 0;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -1,27 +0,0 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue');
|
||||
const q = new PQ({ compare: (a, b) => a.d - b.d });
|
||||
const m = { [s]: 0 };
|
||||
const v = new Set();
|
||||
|
||||
q.queue({ n: s, d: 0 });
|
||||
|
||||
while (q.length) {
|
||||
const { n, d: c } = q.dequeue();
|
||||
if (n === e) return c;
|
||||
if (v.has(n)) continue;
|
||||
v.add(n);
|
||||
|
||||
const adj = g[n] || {};
|
||||
for (const k in adj) {
|
||||
const t = c + adj[k];
|
||||
if (t < (m[k] ?? Infinity)) {
|
||||
m[k] = t;
|
||||
q.queue({ n: k, d: t });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity;
|
||||
};
|
||||
export default findShortestPath;
|
||||
@@ -1,24 +0,0 @@
|
||||
const findShortestPath = async (g, s, e) => {
|
||||
const { default: Q } = await import('https://cdn.skypack.dev/js-priority-queue')
|
||||
const q = new Q({ comparator: (a, b) => a.d - b.d })
|
||||
const m = { [s]: 0 }
|
||||
|
||||
q.queue({ n: s, d: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, d } = q.dequeue()
|
||||
|
||||
if (n === e) return d
|
||||
if (d > (m[n] ?? 1/0)) continue
|
||||
|
||||
for (const v in g[n]) {
|
||||
const t = d + g[n][v]
|
||||
if (t < (m[v] ?? 1/0)) {
|
||||
m[v] = t
|
||||
q.queue({ n: v, d: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1/0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,25 +0,0 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PQ } = await import('https://esm.sh/js-priority-queue@0.1.5')
|
||||
const q = new PQ({ compare: (a, b) => a.d - b.d })
|
||||
const dist = { [start]: 0 }
|
||||
|
||||
q.queue({ n: start, d: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, d } = q.dequeue()
|
||||
|
||||
if (n === end) return d
|
||||
if (d > (dist[n] ?? Infinity)) continue
|
||||
|
||||
for (const [v, w] of Object.entries(graph[n] || {})) {
|
||||
const t = d + w
|
||||
if (t < (dist[v] ?? Infinity)) {
|
||||
dist[v] = t
|
||||
q.queue({ n: v, d: t })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,25 +0,0 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
|
||||
const dists = new Map([[start, 0]])
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a.w - b.w })
|
||||
|
||||
pq.queue({ n: start, w: 0 })
|
||||
|
||||
while (pq.length) {
|
||||
const { n, w } = pq.dequeue()
|
||||
|
||||
if (n === end) return w
|
||||
if (w > (dists.get(n) ?? 1 / 0)) continue
|
||||
|
||||
for (const [neighbor, weight] of Object.entries(graph[n] || {})) {
|
||||
const newWeight = w + weight
|
||||
if (newWeight < (dists.get(neighbor) ?? 1 / 0)) {
|
||||
dists.set(neighbor, newWeight)
|
||||
pq.queue({ n: neighbor, w: newWeight })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -1,25 +0,0 @@
|
||||
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.d - b.d })
|
||||
const m = { [s]: 0 }
|
||||
|
||||
q.queue({ n: s, d: 0 })
|
||||
|
||||
while (q.length) {
|
||||
const { n, d } = q.dequeue()
|
||||
if (n === e) return d
|
||||
if (d > (m[n] ?? 1 / 0)) continue
|
||||
|
||||
const adj = g[n] || {}
|
||||
for (const k in adj) {
|
||||
const v = d + adj[k]
|
||||
if (v < (m[k] ?? 1 / 0)) {
|
||||
m[k] = v
|
||||
q.queue({ n: k, d: v })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / 0
|
||||
}
|
||||
export default findShortestPath;
|
||||
Reference in New Issue
Block a user