Dijkstra
A JavaScript implementation of Dijkstra's algorithm
Install / Use
/learn @andrewhayward/DijkstraREADME
/*
"Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra, is a graph search algorithm that solves the single-source shortest path problem for a graph with nonnegative edge path costs, producing a shortest path tree. This algorithm is often used in routing and as a subroutine in other graph algorithms."
*/
var map = {a:{b:3,c:1},b:{a:2,c:1},c:{a:4,b:1}}, graph = new Graph(map);
graph.findShortestPath('a', 'b'); // => ['a', 'c', 'b'] graph.findShortestPath('a', 'c'); // => ['a', 'c'] graph.findShortestPath('b', 'a'); // => ['b', 'a'] graph.findShortestPath('b', 'c', 'b'); // => ['b', 'c', 'b'] graph.findShortestPath('c', 'a', 'b'); // => ['c', 'b', 'a', 'c', 'b'] graph.findShortestPath('c', 'b', 'a'); // => ['c', 'b', 'a']
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
