# Article Rank

## Glossary

Directed

Directed trait. The algorithm is well-defined on a directed graph.

Directed

Directed trait. The algorithm ignores the direction of the graph.

Directed

Directed trait. The algorithm does not run on a directed graph.

Undirected

Undirected trait. The algorithm is well-defined on an undirected graph.

Undirected

Undirected trait. The algorithm ignores the undirectedness of the graph.

Heterogeneous nodes

Heterogeneous nodes fully supported. The algorithm has the ability to distinguish between nodes of different types.

Heterogeneous nodes

Heterogeneous nodes allowed. The algorithm treats all selected nodes similarly regardless of their label.

Heterogeneous relationships

Heterogeneous relationships fully supported. The algorithm has the ability to distinguish between relationships of different types.

Heterogeneous relationships

Heterogeneous relationships allowed. The algorithm treats all selected relationships similarly regardless of their type.

Weighted relationships

Weighted trait. The algorithm supports a relationship property to be used as weight, specified via the relationshipWeightProperty configuration parameter.

Weighted relationships

Weighted trait. The algorithm treats each relationship as equally important, discarding the value of any relationship weight.

## Introduction

ArticleRank is a variant of the Page Rank algorithm, which measures the transitive influence of nodes.

Page Rank follows the assumption that relationships originating from low-degree nodes have a higher influence than relationships from high-degree nodes. Article Rank lowers the influence of low-degree nodes by lowering the scores being sent to their neighbors in each iteration.

The Article Rank of a node v at iteration i is defined as:

where,

• Nin(v) denotes incoming neighbors and Nout(v) denotes outgoing neighbors of node v.

• d is a damping factor in [0, 1].

• Nout is the average out-degree

## Considerations

There are some things to be aware of when using the Article Rank algorithm:

• If there are no relationships from within a group of pages to outside the group, then the group is considered a spider trap.

• Rank sink can occur when a network of pages is forming an infinite cycle.

• Dead-ends occur when pages have no outgoing relationship.

Changing the damping factor can help with all the considerations above. It can be interpreted as a probability of a web surfer to sometimes jump to a random page and therefore not getting stuck in sinks.

## Syntax

This section covers the syntax used to execute the Article Rank algorithm in each of its execution modes. We are describing the named graph variant of the syntax. To learn more about general syntax variants, see Syntax overview.

Article Rank syntax per mode
Run Article Rank in stream mode on a named graph.
``````CALL gds.articleRank.stream(
graphName: String,
configuration: Map
)
YIELD
nodeId: Integer,
score: Float``````
Table 1. Parameters
Name Type Default Optional Description

graphName

String

`n/a`

no

The name of a graph stored in the catalog.

configuration

Map

`{}`

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 2. Configuration
Name Type Default Optional Description

nodeLabels

List of String

`['*']`

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

relationshipTypes

List of String

`['*']`

yes

Filter the named graph using the given relationship types. Relationships with any of the given types will be included.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

jobId

String

`Generated internally`

yes

An ID that can be provided to more easily track the algorithm’s progress.

logProgress

Boolean

`true`

yes

If disabled the progress percentage will not be logged.

dampingFactor

Float

`0.85`

yes

The damping factor of the Page Rank calculation. Must be in [0, 1).

maxIterations

Integer

`20`

yes

The maximum number of iterations of Article Rank to run.

tolerance

Float

`0.0000001`

yes

Minimum change in scores between iterations. If all scores change less than the tolerance value the result is considered stable, and the algorithm returns.

relationshipWeightProperty

String

`null`

yes

Name of the relationship property to use as weights. If unspecified, the algorithm runs unweighted.

sourceNodes

List or Node or Number

`[]`

yes

The nodes or node ids to use for computing Personalized Page Rank.

scaler

String or Map

`None`

yes

The name of the scaler applied for the final scores. Supported values are `None`, `MinMax`, `Max`, `Mean`, `Log`, and `StdScore`. To apply scaler-specific configuration, use the Map syntax: `{scaler: 'name', …​}`.

Table 3. Results
Name Type Description

nodeId

Integer

Node ID.

score

Float

Eigenvector score.

Run Article Rank in stats mode on a named graph.
``````CALL gds.articleRank.stats(
graphName: String,
configuration: Map
)
YIELD
ranIterations: Integer,
didConverge: Boolean,
preProcessingMillis: Integer,
computeMillis: Integer,
postProcessingMillis: Integer,
centralityDistribution: Map,
configuration: Map``````
Table 4. Parameters
Name Type Default Optional Description

graphName

String

`n/a`

no

The name of a graph stored in the catalog.

configuration

Map

`{}`

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 5. Configuration
Name Type Default Optional Description

nodeLabels

List of String

`['*']`

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

relationshipTypes

List of String

`['*']`

yes

Filter the named graph using the given relationship types. Relationships with any of the given types will be included.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

jobId

String

`Generated internally`

yes

An ID that can be provided to more easily track the algorithm’s progress.

logProgress

Boolean

`true`

yes

If disabled the progress percentage will not be logged.

dampingFactor

Float

`0.85`

yes

The damping factor of the Page Rank calculation. Must be in [0, 1).

maxIterations

Integer

`20`

yes

The maximum number of iterations of Article Rank to run.

tolerance

Float

`0.0000001`

yes

Minimum change in scores between iterations. If all scores change less than the tolerance value the result is considered stable, and the algorithm returns.

relationshipWeightProperty

String

`null`

yes

Name of the relationship property to use as weights. If unspecified, the algorithm runs unweighted.

sourceNodes

List or Node or Number

`[]`

yes

The nodes or node ids to use for computing Personalized Page Rank.

scaler

String or Map

`None`

yes

The name of the scaler applied for the final scores. Supported values are `None`, `MinMax`, `Max`, `Mean`, `Log`, and `StdScore`. To apply scaler-specific configuration, use the Map syntax: `{scaler: 'name', …​}`.

Table 6. Results
Name Type Description

ranIterations

Integer

The number of iterations run.

didConverge

Boolean

Indicates if the algorithm converged.

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

computeMillis

Integer

Milliseconds for running the algorithm.

postProcessingMillis

Integer

Milliseconds for computing the `centralityDistribution`.

centralityDistribution

Map

Map containing min, max, mean as well as p50, p75, p90, p95, p99 and p999 percentile values of centrality values.

configuration

Map

The configuration used for running the algorithm.

Run Article Rank in mutate mode on a named graph.
``````CALL gds.articleRank.mutate(
graphName: String,
configuration: Map
)
YIELD
nodePropertiesWritten: Integer,
ranIterations: Integer,
didConverge: Boolean,
preProcessingMillis: Integer,
computeMillis: Integer,
postProcessingMillis: Integer,
mutateMillis: Integer,
centralityDistribution: Map,
configuration: Map``````
Table 7. Parameters
Name Type Default Optional Description

graphName

String

`n/a`

no

The name of a graph stored in the catalog.

configuration

Map

`{}`

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 8. Configuration
Name Type Default Optional Description

mutateProperty

String

`n/a`

no

The node property in the GDS graph to which the score is written.

nodeLabels

List of String

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

List of String

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

jobId

String

`Generated internally`

yes

An ID that can be provided to more easily track the algorithm’s progress.

dampingFactor

Float

`0.85`

yes

The damping factor of the Page Rank calculation. Must be in [0, 1).

maxIterations

Integer

`20`

yes

The maximum number of iterations of Article Rank to run.

tolerance

Float

`0.0000001`

yes

Minimum change in scores between iterations. If all scores change less than the tolerance value the result is considered stable, and the algorithm returns.

relationshipWeightProperty

String

`null`

yes

Name of the relationship property to use as weights. If unspecified, the algorithm runs unweighted.

sourceNodes

List or Node or Number

`[]`

yes

The nodes or node ids to use for computing Personalized Page Rank.

scaler

String or Map

`None`

yes

The name of the scaler applied for the final scores. Supported values are `None`, `MinMax`, `Max`, `Mean`, `Log`, and `StdScore`. To apply scaler-specific configuration, use the Map syntax: `{scaler: 'name', …​}`.

Table 9. Results
Name Type Description

ranIterations

Integer

The number of iterations run.

didConverge

Boolean

Indicates if the algorithm converged.

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

computeMillis

Integer

Milliseconds for running the algorithm.

postProcessingMillis

Integer

Milliseconds for computing the `centralityDistribution`.

mutateMillis

Integer

Milliseconds for adding properties to the projected graph.

nodePropertiesWritten

Integer

The number of properties that were written to the projected graph.

centralityDistribution

Map

Map containing min, max, mean as well as p50, p75, p90, p95, p99 and p999 percentile values of centrality values.

configuration

Map

The configuration used for running the algorithm.

Run Article Rank in write mode on a named graph.
``````CALL gds.articleRank.write(
graphName: String,
configuration: Map
)
YIELD
nodePropertiesWritten: Integer,
ranIterations: Integer,
didConverge: Boolean,
preProcessingMillis: Integer,
computeMillis: Integer,
postProcessingMillis: Integer,
writeMillis: Integer,
centralityDistribution: Map,
configuration: Map``````
Table 10. Parameters
Name Type Default Optional Description

graphName

String

`n/a`

no

The name of a graph stored in the catalog.

configuration

Map

`{}`

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 11. Configuration
Name Type Default Optional Description

nodeLabels

List of String

`['*']`

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

relationshipTypes

List of String

`['*']`

yes

Filter the named graph using the given relationship types. Relationships with any of the given types will be included.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

jobId

String

`Generated internally`

yes

An ID that can be provided to more easily track the algorithm’s progress.

logProgress

Boolean

`true`

yes

If disabled the progress percentage will not be logged.

writeConcurrency

Integer

`value of 'concurrency'`

yes

The number of concurrent threads used for writing the result to Neo4j.

writeProperty

String

`n/a`

no

The node property in the Neo4j database to which the score is written.

dampingFactor

Float

`0.85`

yes

The damping factor of the Page Rank calculation. Must be in [0, 1).

maxIterations

Integer

`20`

yes

The maximum number of iterations of Article Rank to run.

tolerance

Float

`0.0000001`

yes

Minimum change in scores between iterations. If all scores change less than the tolerance value the result is considered stable, and the algorithm returns.

relationshipWeightProperty

String

`null`

yes

Name of the relationship property to use as weights. If unspecified, the algorithm runs unweighted.

sourceNodes

List or Node or Number

`[]`

yes

The nodes or node ids to use for computing Personalized Page Rank.

scaler

String or Map

`None`

yes

The name of the scaler applied for the final scores. Supported values are `None`, `MinMax`, `Max`, `Mean`, `Log`, and `StdScore`. To apply scaler-specific configuration, use the Map syntax: `{scaler: 'name', …​}`.

Table 12. Results
Name Type Description

ranIterations

Integer

The number of iterations run.

didConverge

Boolean

Indicates if the algorithm converged.

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

computeMillis

Integer

Milliseconds for running the algorithm.

postProcessingMillis

Integer

Milliseconds for computing the `centralityDistribution`.

writeMillis

Integer

Milliseconds for writing result data back.

nodePropertiesWritten

Integer

The number of properties that were written to Neo4j.

centralityDistribution

Map

Map containing min, max, mean as well as p50, p75, p90, p95, p99 and p999 percentile values of centrality values.

configuration

Map

The configuration used for running the algorithm.

## Examples

 All the examples below should be run in an empty database. The examples use native projections as the norm, although Cypher projections can be used as well.

In this section we will show examples of running the Article Rank algorithm on a concrete graph. The intention is to illustrate what the results look like and to provide a guide in how to make use of the algorithm in a real setting. We will do this on a small web network graph of a handful nodes connected in a particular pattern. The example graph looks like this:

The following Cypher statement will create the example graph in the Neo4j database:
``````CREATE
(home:Page {name:'Home'}),
(product:Page {name:'Product'}),
(a:Page {name:'Site A'}),
(b:Page {name:'Site B'}),
(c:Page {name:'Site C'}),
(d:Page {name:'Site D'}),

This graph represents eight pages, linking to one another. Each relationship has a property called `weight`, which describes the importance of the relationship.

The following statement will project a graph using a native projection and store it in the graph catalog under the name 'myGraph'.
``````CALL gds.graph.project(
'myGraph',
'Page',
{
relationshipProperties: 'weight'
}
)``````

### Memory Estimation

First off, we will estimate the cost of running the algorithm using the `estimate` procedure. This can be done with any execution mode. We will use the `write` mode in this example. Estimating the algorithm is useful to understand the memory impact that running the algorithm on your graph will have. When you later actually run the algorithm in one of the execution modes the system will perform an estimation. If the estimation shows that there is a very high probability of the execution going over its memory limitations, the execution is prohibited. To read more about this, see Automatic estimation and execution blocking.

For more details on `estimate` in general, see Memory Estimation.

The following will estimate the memory requirements for running the algorithm:
``````CALL gds.articleRank.write.estimate('myGraph', {
writeProperty: 'centrality',
maxIterations: 20
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory``````
Table 13. Results
nodeCount relationshipCount bytesMin bytesMax requiredMemory

8

14

696

696

"696 Bytes"

### Stream

In the `stream` execution mode, the algorithm returns the score for each node. This allows us to inspect the results directly or post-process them in Cypher without any side effects. For example, we can order the results to find the nodes with the highest Eigenvector score.

For more details on the `stream` mode in general, see Stream.

The following will run the algorithm in `stream` mode:
``````CALL gds.articleRank.stream('myGraph')
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC``````
Table 14. Results
name score

"Home"

0.5607071761939444

0.250337073634706

0.250337073634706

"Product"

0.250337073634706

"Site A"

0.18152391630760797

"Site B"

0.18152391630760797

"Site C"

0.18152391630760797

"Site D"

0.18152391630760797

The above query is running the algorithm in `stream` mode as `unweighted`. Below, one can find an example for weighted graphs.

### Stats

In the `stats` execution mode, the algorithm returns a single row containing a summary of the algorithm result. For example Eigenvector stats returns centrality histogram which can be used to monitor the distribution of centrality scores across all computed nodes. This execution mode does not have any side effects. It can be useful for evaluating algorithm performance by inspecting the `computeMillis` return item. In the examples below we will omit returning the timings. The full signature of the procedure can be found in the syntax section.

For more details on the `stats` mode in general, see Stats.

The following will run the algorithm and return statistics about the centrality scores.
``````CALL gds.articleRank.stats('myGraph')
YIELD centralityDistribution
RETURN centralityDistribution.max AS max``````
Table 15. Results
max

0.560710907

### Mutate

The `mutate` execution mode extends the `stats` mode with an important side effect: updating the named graph with a new node property containing the score for that node. The name of the new property is specified using the mandatory configuration parameter `mutateProperty`. The result is a single summary row, similar to `stats`, but with some additional metrics. The `mutate` mode is especially useful when multiple algorithms are used in conjunction.

For more details on the `mutate` mode in general, see Mutate.

The following will run the algorithm in `mutate` mode:
``````CALL gds.articleRank.mutate('myGraph', {
mutateProperty: 'centrality'
})
YIELD nodePropertiesWritten, ranIterations``````
Table 16. Results
nodePropertiesWritten ranIterations

`8`

`19`

### Write

The `write` execution mode extends the `stats` mode with an important side effect: writing the score for each node as a property to the Neo4j database. The name of the new property is specified using the mandatory configuration parameter `writeProperty`. The result is a single summary row, similar to `stats`, but with some additional metrics. The `write` mode enables directly persisting the results to the database.

For more details on the `write` mode in general, see Write.

The following will run the algorithm in `write` mode:
``````CALL gds.articleRank.write('myGraph', {
writeProperty: 'centrality'
})
YIELD nodePropertiesWritten, ranIterations``````
Table 17. Results
nodePropertiesWritten ranIterations

`8`

`19`

### Weighted

By default, the algorithm considers the relationships of the graph to be unweighted. To change this behaviour, we can use the `relationshipWeightProperty` configuration parameter. If the parameter is set, the associated property value is used as relationship weight. In the `weighted` case, the previous score of a node sent to its neighbors is multiplied by the normalized relationship weight. Note, that negative relationship weights are ignored during the computation.

In the following example, we use the `weight` property of the input graph as relationship weight property.

The following will run the algorithm in `stream` mode using relationship weights:
``````CALL gds.articleRank.stream('myGraph', {
relationshipWeightProperty: 'weight'
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC``````
Table 18. Results
name score

"Home"

0.5160810726222141

"Product"

0.24570958074084706

0.1819031935802824

0.1819031935802824

"Site A"

0.15281123078335393

"Site B"

0.15281123078335393

"Site C"

0.15281123078335393

"Site D"

0.15281123078335393

As in the unweighted example, the "Home" node has the highest score. In contrast, the "Product" now has the second highest instead of the fourth highest score.

 We are using `stream` mode to illustrate running the algorithm as `weighted`, however, all the algorithm modes support the `relationshipWeightProperty` configuration parameter.

### Tolerance

The `tolerance` configuration parameter denotes the minimum change in scores between iterations. If all scores change less than the configured tolerance, the iteration is aborted and considered converged. Note, that setting a higher tolerance leads to earlier convergence, but also to less accurate centrality scores.

The following will run the algorithm in `stream` mode using a high `tolerance` value:
``````CALL gds.articleRank.stream('myGraph', {
tolerance: 0.1
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC``````
Table 19. Results
name score

"Home"

0.4470707071

0.2300021265

0.2300021265

"Product"

0.2300021265

"Site A"

0.1688888889

"Site B"

0.1688888889

"Site C"

0.1688888889

"Site D"

0.1688888889

We are using `tolerance: 0.1`, which leads to slightly different results compared to the stream example. However, the computation converges after four iterations, and we can already observe a trend in the resulting scores.

### Personalised Article Rank

Personalized Article Rank is a variation of Article Rank which is biased towards a set of `sourceNodes`. By default, the power iteration starts with the same value for all nodes: `1 / |V|`. For a given set of source nodes `S`, the initial value of each source node is set to `1 / |S|` and to `0` for all remaining nodes.

The following examples show how to run Eigenvector centrality centered around 'Site A' and 'Site B'.

The following will run the algorithm and stream results:
``````MATCH (siteA:Page {name: 'Site A'}), (siteB:Page {name: 'Site B'})
CALL gds.articleRank.stream('myGraph', {
maxIterations: 20,
sourceNodes: [siteA, siteB]
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC``````
Table 20. Results
name score

"Site A"

0.15249052775314756

"Site B"

0.15249052775314756

"Home"

0.1105231342997017

0.019777824032578193

0.019777824032578193

"Product"

0.019777824032578193

"Site C"

0.002490527753147571

"Site D"

0.002490527753147571

Comparing these results to the ones from the stream example (which is not using `sourceNodes` configuration parameter) shows the 'Site A' and `Site B` nodes we used in the `sourceNodes` list now score second and third instead of fourth and fifth.

### Scaling centrality scores

To normalize the final scores as part of the algorithm execution, one can use the `scaler` configuration parameter. A description of all available scalers can be found in the documentation for the `scaleProperties` procedure.

The following will run the algorithm in `stream` mode and returns normalized results:
``````CALL gds.articleRank.stream('myGraph', {
scaler: "StdScore"
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC``````
Table 21. Results
name score

"Home"

2.550761988515413

-0.036593974039468

-0.036593974039468

"Product"

-0.036593974039468

"Site A"

-0.610245016599252

"Site B"

-0.610245016599252

"Site C"

-0.610245016599252

"Site D"

-0.610245016599252

Comparing the results with the stream example, we can see that the relative order of scores is the same.