NumPy allowed · plain Python earns 10 bonus points
Cosine-like similarity scores ranked before context assembly
Implement a single real PageRank power-iteration step, the algorithm behind ranking the most 'important' entities in a large knowledge graph by link structure.
Implement pagerank_step(graph, scores, damping). For each node n, its new score is (1-damping)/N + damping * sum(scores[m]/len(graph[m]) for m in graph if n in graph[m]), where N = len(graph). A node with NO outgoing edges (len(graph[m])==0) contributes nothing to any node's new score (avoid dividing by zero). Return the dict of new scores.
pagerank_step(graph: dict[str, list[str]], scores: dict[str, float], damping: float) -> dict[str, float]