This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dijkstra Algorithm Example | |
// - Using suite data structure make algorithm clearer | |
// compile graph data to vertices structure: {"label": Vertex, ...} | |
// - Graph: [{from: "label", to: "label". cost: number}, ...] | |
// - Vertex: {label: string, edges: [{dest: Vertex, cost: number}, ...]} | |
var compileVertices = function (graph) { | |
var vs = {}; | |
graph.forEach(function (edge) { | |
if (!vs[edge.from]) vs[edge.from] = {label: edge.from, edges: []}; |
NewerOlder