feat: add popularity option

This commit is contained in:
2025-02-23 17:10:18 +01:00
parent 47fd9bd859
commit 978aafc204
3 changed files with 52 additions and 25 deletions

View File

@@ -92,7 +92,9 @@ def graph_json():
G = nx.DiGraph()
G.add_weighted_edges_from([(e["source"], e["target"], e["size"]) for e in edges])
in_degrees = G.in_degree(weight="weight")
nodes = [dict(node, **{"inDegree": in_degrees[node["id"]]}) for node in nodes]
nodes = [
dict(node, **{"data": {"inDegree": in_degrees[node["id"]]}}) for node in nodes
]
return JSONResponse({"nodes": nodes, "edges": edges})