Published
Edited
Sep 24, 2019
Insert cell
Insert cell
dijkstra = require("https://bundle.run/dijkstra")
Insert cell
{
var subject, a, b, c, d, e, f;

/**
* b - c
* / / \
* a - d - f
* \ / /
* e ---
*/
subject = new dijkstra.Graph();
subject.addVertex((a = { 1: 2 }));
subject.addVertex((b = { 3: 4 }));
subject.addVertex((c = { 5: 6 }));
subject.addVertex((d = { 7: 8 }));
subject.addVertex((e = { 9: 10 }));
subject.addVertex((f = { 11: 12 }));
subject.addEdge(a, b, 5);
subject.addEdge(a, d, 5);
subject.addEdge(a, e, 5);
subject.addEdge(b, c, 5);
subject.addEdge(c, d, 5);
subject.addEdge(c, f, 5);
subject.addEdge(d, e, 5);
subject.addEdge(d, f, 1);
subject.addEdge(e, f, 5);

return dijkstra.dijkstra(subject, a);
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more