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:
23
tests/1_dijkstra/outputs/openai_gpt-5.1-chat.js
Normal file
23
tests/1_dijkstra/outputs/openai_gpt-5.1-chat.js
Normal file
@@ -0,0 +1,23 @@
|
||||
async function findShortestPath(g,s,e){
|
||||
const {default:Q}=await import('https://cdn.jsdelivr.net/npm/js-priority-queue@latest/dist/priority-queue.min.js')
|
||||
const d={},v={}
|
||||
for(const k in g)d[k]=Infinity
|
||||
d[s]=0
|
||||
const q=new Q({comparator:(a,b)=>a[1]-b[1]})
|
||||
q.queue([s,0])
|
||||
while(q.length){
|
||||
const [n,w]=q.dequeue()
|
||||
if(v[n])continue
|
||||
v[n]=1
|
||||
if(n===e)return w
|
||||
for(const k in g[n]){
|
||||
const nw=w+g[n][k]
|
||||
if(nw<d[k]){
|
||||
d[k]=nw
|
||||
q.queue([k,nw])
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity
|
||||
}
|
||||
export default findShortestPath;
|
||||
Reference in New Issue
Block a user