function getCommonConnections({ links, connectionsSets }) {
const linksCC = [];
const mapCC = new Map();
if (links !== undefined && connectionsSets === undefined) {
console.log("building connection sets");
connectionsSets = getConnectionsSets({ links });
}
const before = performance.now();
for (let [n1, s1] of connectionsSets) {
for (let [n2, s2] of connectionsSets) {
if (n1 === n2 || !n1 || !n2) continue;
const intersectionSet = new Set([...s1].filter((d) => s2.has(d)));
if (intersectionSet.size) {
linksCC.push({
source: n1,
target: n2,
value: intersectionSet.size,
commonConnections: intersectionSet
});
}
}
}
console.log("Finished creating the array", performance.now() - before);
return linksCC;
}