Published
Edited
May 18, 2022
Importers
Insert cell
# Network Utilities

Some basic utilities to generate and transform networks
Insert cell
function convertLinksToIndexes({ nodes, links }, { id = "id" } = {}) {
const idf = typeof id === "function" ? id : (d) => d[id];

const mapNodes = new Map(nodes.map((d, i) => [idf(d), i]));

links = links.map((l) => ({
...l,
source: mapNodes.get(l.source),
target: mapNodes.get(l.target)
}));
return links;
}
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