feat: show popularity score

This commit is contained in:
2025-03-12 14:39:42 +01:00
parent 5b8f476997
commit 4f30888c5c
2 changed files with 43 additions and 28 deletions

View File

@@ -67,6 +67,7 @@ export const GraphComponent = () => {
}
function handlePopularity() {
popularityLabel(!popularity);
setPopularity(!popularity);
}
@@ -122,6 +123,20 @@ export const GraphComponent = () => {
}
setData({ nodes: data.nodes, edges: newEdges });
}
function popularityLabel(popularity: boolean) {
const newNodes = data.nodes;
console.log(data.nodes);
if (popularity) {
newNodes.forEach(
(node) => (node.subLabel = `pop.: ${node.data.inDegree.toFixed(1)}`)
);
} else {
newNodes.forEach((node) => (node.subLabel = undefined));
}
setData({ nodes: newNodes, edges: data.edges });
}
useEffect(() => {
if (mutuality) colorMatches(false);
colorMatches(mutuality);