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;
}