network = {
const dLinks = new Map();
for (let t of movies.slice(0,limith)) {
if (t.type == "Movie") {
const key = getKey(t.director, t.show_id);
if (key == "ignore") continue;
if (!dLinks.has(key)) dLinks.set(key, 0);
dLinks.set(key, dLinks.get(key) + 1);
}
}
const dNodes = new Map();
let links = [];
for (let [l, v] of dLinks) {
const [source, target] = l.split("~");
const s = findOrAdd(dNodes, source);
const t = findOrAdd(dNodes, target);
dNodes.set(source, ((s.value += 1), s));
dNodes.set(target, ((t.value += 1), t));
links.push({ source: s, target: t, value: v });
}
const network = { nodes: Array.from(dNodes.values()), links };
return network;
}