Skip to content

PageRank

Introduction

PageRank is an algorithm used to measure the relative importance of nodes in a graph based on their connections.

Output

The algorithm produces the following fields:

Field Name Description
id The ID of the vertex (node)
score The PageRank score of the vertex (node)

Query Example

CALL algo.paral.pagerank({
    labels: ['Page'],
    relationshipTypes: ['LINKS'],
    relationshipWeightProperty: 'weight',
    maxIterations: 20,
    dampingFactor: 0.85
    }) YIELD id, score 
RETURN id, score 
graph.compute().program(
  PageRankProgram.build()
    .maxIteration(20)
    .vertices("Page")
    .edges("LINKS")
    .setParams("weight", "weight", "threshold", 10.0, "dampingFactor", 0.7)
    .create()
).submit().get().toList()

Parameters

Name Description Required Default Value
labels Specifies the node labels to include in the algorithm Yes
relationshipTypes Specifies the relationship types to include Yes
maxIterations Maximum number of iterations No 30
relationshipWeightProperty Defines the property name representing edge weights No
dampingFactor Factor representing the probability of continuing along links No 0.85
tolerance Minimum edge weight value for it to be included in the algorithm No 1e-7
Method Description Required Default Value
vertices(String... names) Specifies the vertex labels to include Yes
edges(String... names) Specifies the edge labels to include Yes
maxIteration(int n) Sets the maximum number of iterations No 30
setParams(Object... args) Adds additional parameters using alternating keys and values No see below

Additional parameter keys in setParams

Key Description Default Value
weight Specifies the edge weight property or a constant value as weight 1.0
dampingFactor Factor representing the probability of continuing along links 0.85
tolerance Minimum edge weight value for it to be included in the algorithm 1e-7

Exporting Query Results

For large datasets, export the results to object storage:

EXPORT TO 's3://my_bucket/target_dir'
PROPERTIES {
  catalog: 'puppygraph_catalog_name'
}
CALL algo.paral.pagerank({
    labels: ['Page'],
    relationshipTypes: ['LINKS'],
    relationshipWeightProperty: 'weight',
    }) YIELD id, score 
RETURN id, score 
graph.compute().program(
    PageRankProgram.build()
            .maxIteration(20)
            .vertices("Page")
            .edges("LINKS")
            .setParams("weight", "weight", "threshold", 10.0)
            .create()
).submit().get().save([
  "exportTo": "s3://my_bucket/target_dir",
  "catalog": "puppygraph_catalog_name"
])