PageRank and community detection
The examples require an existing people projection containing the selected
Person nodes. Leiden requires an undirected projection; start with the
projection guide. Numeric IDs are resolved from
live nodes here and must still belong to the projection.
Personalised PageRank and community algorithms
MATCH (a:Person {name:'Ada'}), (b:Person {name:'Bob'})
CALL gds.pageRank.stream('people', {sourceNodes:[[id(a),2.0],[id(b),1.0]]})
YIELD nodeId,score RETURN nodeId,score;
CALL gds.labelPropagation.write('people', {writeProperty:'label',maxIterations:20});
CALL gds.leiden.write('people', {
writeProperty:'community',randomSeed:42,gamma:1.0,theta:0.01,maxLevels:10
});
PageRank sourceNodes accepts a node/ID, a list of nodes/IDs, or [node,bias]
pairs. Biases must be finite and positive and sources must be distinct selected
nodes. Omitted/empty sources preserve ordinary PageRank. Other nodes start at
zero; each iteration adds (1-dampingFactor)*bias at the sources. Bias is not
normalised; sinks continue to discard rank as in the existing PageRank kernel.
Label Propagation updates labels sequentially in node-ID order using outgoing
neighbour votes, optionally weighted. It keeps the current label when tied;
otherwise ties choose the smallest label. Zero-weight edges cast no votes and
isolates keep their own communities. maxIterations defaults to 10; stats report
ranIterations and didConverge. Seed/node-weight properties and randomised
update ordering are not supported.
Leiden optimises weighted modularity on an UNDIRECTED projection through
queue-based local moves, constrained random singleton refinement and aggregation
of refined communities. The coarse partition seeds the next aggregate level.
gamma (default 1) and theta (default 0.01) must be positive; tolerance
(default 0.0001) must be non-negative; maxLevels defaults to 10. Positive-weight
connectivity is enforced even when the level limit stops the algorithm. Stats
include modularity, modularities, ranLevels and didConverge. Convergence describes
the stopping criterion, not a global optimum. A seed is repeatable within GDB;
partitions and RNG sequences are implementation-specific. Intermediate
communities, seeded communities, minimum-size filtering and concurrency options
are currently rejected. Numeric community IDs use GDB's existing canonical or
consecutive-ID convention.
Related articles
Graph projections and catalogue · GDS algorithms and execution modes · GDS resources and cancellation · Graph data science