Published
Edited
May 31, 2020
10 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chart.update(graph);
Insert cell
Insert cell
Insert cell
/* Finds directed cycles for given node, link pairs.
Mutates array of input nodes.
*/
function detectCycles(nodes, links, flatlinks = true) {
let cycles = [];
nodes.forEach(function (n) {
let cycle = findCycle(nodes[n.id], links, flatlinks);
if (cycle != null) {
cycle.forEach(function (c) {
let node = (flatlinks) ? nodes[c.node] : nodes[c.node.id];
node.alloc = true;
const item = c.item;
node.item = item;
const next = c.li;
cycles.push({ node, item, next });
});
};
});
return cycles;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("desires@9.json").json()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@5")
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