Algorithm
PageRank
activeNeeds verification
Scores nodes by the stationary probability that a random surfer — following links, occasionally teleporting — is on them. Originally used to rank web pages.
Definition
Intuition
A page is important if important pages link to it; the damping factor d (often 0.85) models a surfer who sometimes jumps to a random page.
Pseudocode
PR[v] = 1/N for all v
repeat until converged:
for v: new[v] = (1-d)/N + d * Σ_{u→v} PR[u] / outdeg(u)
PR = new # dangling nodes redistribute mass uniformly
Complexity
| Time | O(k (V + E)) for k iterations |
|---|---|
| Space | O(V) |
Python
import networkx as nx
pr = nx.pagerank(G, alpha=0.85)Cypher (Neo4j GDS)
CALL gds.pageRank.stream('myGraph', {dampingFactor: 0.85})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score ORDER BY score DESCProcedure names and options vary between GDS versions; check the GDS docs for your version.
An interactive step-by-step visualizer for this algorithm is planned for phase 3.
Profile
| Time complexity | O(k (V + E)) for k iterations |
|---|---|
| Space complexity | O(V) |
Relationships
- Belongs to
- Prerequisite of
- Prerequisites
- Adjacency matrix(Concept)
- Random walk on a graph(Concept)
- Implemented by
- GraphFrames(Library / framework)
- Graphology(Library / framework)
- Neo4j Graph Data Science(Library / framework)
- NetworkX(Library / framework)
- Related
- PageRank paper(Timeline event)