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 | ID of the vertex (node) |
score | The PageRank score of the vertex (node) |
Using Cypher
Query Example
CALL algo.paral.pagerank({
labels: ['Page'],
relationshipTypes: ['LINKS'],
relationshipWeightProperty: 'weight',
maxIterations: 20,
dampingFactor: 0.85
}) YIELD id, score
RETURN id, score
Parameters
Name | Description | Required |
---|---|---|
labels | Specifies the node labels to include in the algorithm | Yes |
relationshipTypes | Specifies the relationship types to include | Yes |
relationshipWeightProperty | Defines the property name representing edge weights | No |
maxIterations | Maximum number of iterations, default is 30 | No |
dampingFactor | Factor representing the probability of continuing along links, default is 0.85 | No |
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
Using Gremlin
Query Example
graph.compute().program(
PageRankProgram.build()
.maxIteration(20)
.vertices("Page")
.edges("LINKS")
.edgeProperties("amount")
.setParam("weight", "weight", "threshold", 10.0, "dampingFactor", 0.7)
.create()
).submit().get().toList()
Parameters
Method | Description |
---|---|
maxIteration(int n) | Sets the maximum number of iterations, default is 30 |
vertices(String... names) | Specifies the vertex labels to include |
edges(String... names) | Specifies the edge labels to include |
edgeProperties(String... names) | Sets the property name for edge weights |
setParams(Object... args) | Adds additional parameters using alternating keys and values |
Additional Parameters
Key | Description | Default Value |
---|---|---|
dampingFactor | Factor representing the probability of continuing along links | 0.85 |
weight | Specifies the edge weight property or a constant value as weight | 1.0 |
threshold | Minimum edge weight value for it to be included in the algorithm | 0.0 |
Exporting Query Results
For large datasets, use the save()
method to export the results.