Eigenvector Centrality

This section describes the Eigenvector Centrality algorithm in the Neo4j Graph Data Science library.

1. Introduction

Eigenvector Centrality is an algorithm that measures the transitive influence of nodes. Relationships originating from high-scoring nodes contribute more to the score of a node than connections from low-scoring nodes. A high eigenvector score means that a node is connected to many nodes who themselves have high scores.

The algorithm computes the eigenvector associated with the largest absolute eigenvalue. To compute that eigenvalue, the algorithm applies the power iteration approach. Within each iteration, the centrality score for each node is derived from the scores of its incoming neighbors. In the power iteration method, the eigenvector is L2-normalized after each iteration, leading to normalized results by default.

The PageRank algorithm is a variant of Eigenvector Centrality with an additional jump probability.

2. Considerations

There are some things to be aware of when using the Eigenvector centrality algorithm:

  • Centrality scores for nodes with no incoming relationships will converge to 0.

  • Due to missing degree normalization, high-degree nodes have a very strong influence on their neighbors' score.

3. Syntax

This section covers the syntax used to execute the Eigenvector Centrality 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.

Example 1. Eigenvector Centrality syntax per mode
Run Eigenvector Centrality in stream mode on a named graph.
CALL gds.eigenvector.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. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

['*']

yes

Filter the named graph using the given node labels.

relationshipTypes

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.

Table 3. Algorithm specific configuration
Name Type Default Optional Description

maxIterations

Integer

20

yes

The maximum number of iterations of Eigenvector Centrality 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

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

sourceNodes

List or Node or Number

[]

yes

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

scaler

String

None

yes

The name of the scaler applied for the final scores. Supported values are None, MinMax, Max, Mean, Log, L1Norm, L2Norm and StdScore.

Table 4. Results
Name Type Description

nodeId

Integer

Node ID.

score

Float

Eigenvector score.

Run Eigenvector Centrality in stats mode on a named graph.
CALL gds.eigenvector.stats(
  graphName: String,
  configuration: Map
)
YIELD
  ranIterations: Integer,
  didConverge: Boolean,
  createMillis: Integer,
  computeMillis: Integer,
  postProcessingMillis: Integer,
  centralityDistribution: Map,
  configuration: Map
Table 5. 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 6. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

['*']

yes

Filter the named graph using the given node labels.

relationshipTypes

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.

Table 7. Algorithm specific configuration
Name Type Default Optional Description

maxIterations

Integer

20

yes

The maximum number of iterations of Eigenvector Centrality 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

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

sourceNodes

List or Node or Number

[]

yes

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

scaler

String

None

yes

The name of the scaler applied for the final scores. Supported values are None, MinMax, Max, Mean, Log, L1Norm, L2Norm and StdScore.

Table 8. Results
Name Type Description

ranIterations

Integer

The number of iterations run.

didConverge

Boolean

Indicates if the algorithm converged.

createMillis

Integer

Milliseconds for creating 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 Eigenvector Centrality in mutate mode on a named graph.
CALL gds.eigenvector.mutate(
  graphName: String,
  configuration: Map
)
YIELD
  nodePropertiesWritten: Integer,
  ranIterations: Integer,
  didConverge: Boolean,
  createMillis: Integer,
  computeMillis: Integer,
  postProcessingMillis: Integer,
  mutateMillis: Integer,
  centralityDistribution: Map,
  configuration: Map
Table 9. 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 10. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

['*']

yes

Filter the named graph using the given node labels.

relationshipTypes

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.

mutateProperty

String

n/a

no

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

Table 11. Algorithm specific configuration
Name Type Default Optional Description

maxIterations

Integer

20

yes

The maximum number of iterations of Eigenvector Centrality 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

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

sourceNodes

List or Node or Number

[]

yes

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

scaler

String

None

yes

The name of the scaler applied for the final scores. Supported values are None, MinMax, Max, Mean, Log, L1Norm, L2Norm and StdScore.

Table 12. Results
Name Type Description

ranIterations

Integer

The number of iterations run.

didConverge

Boolean

Indicates if the algorithm converged.

createMillis

Integer

Milliseconds for creating the graph.

computeMillis

Integer

Milliseconds for running the algorithm.

postProcessingMillis

Integer

Milliseconds for computing the centralityDistribution.

mutateMillis

Integer

Milliseconds for adding properties to the in-memory graph.

nodePropertiesWritten

Integer

The number of properties that were written to the in-memory 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 Eigenvector Centrality in write mode on a named graph.
CALL gds.eigenvector.write(
  graphName: String,
  configuration: Map
)
YIELD
  nodePropertiesWritten: Integer,
  ranIterations: Integer,
  didConverge: Boolean,
  createMillis: Integer,
  computeMillis: Integer,
  postProcessingMillis: Integer,
  writeMillis: Integer,
  centralityDistribution: Map,
  configuration: Map
Table 13. 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 14. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

['*']

yes

Filter the named graph using the given node labels.

relationshipTypes

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. Also provides the default value for 'writeConcurrency'.

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.

Table 15. Algorithm specific configuration
Name Type Default Optional Description

maxIterations

Integer

20

yes

The maximum number of iterations of Eigenvector Centrality 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

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

sourceNodes

List or Node or Number

[]

yes

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

scaler

String

None

yes

The name of the scaler applied for the final scores. Supported values are None, MinMax, Max, Mean, Log, L1Norm, L2Norm and StdScore.

Table 16. Results
Name Type Description

ranIterations

Integer

The number of iterations run.

didConverge

Boolean

Indicates if the algorithm converged.

createMillis

Integer

Milliseconds for creating 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.

3.1. Anonymous graphs

It is also possible to execute the algorithm on a graph that is projected in conjunction with the algorithm execution. In this case, the graph does not have a name, and we call it anonymous. When executing over an anonymous graph the configuration map contains a graph projection configuration as well as an algorithm configuration. All execution modes support execution on anonymous graphs, although we only show syntax and mode-specific configuration for the write mode for brevity.

For more information on syntax variants, see Syntax overview.

Run Eigenvector Centrality in write mode on an anonymous graph:
CALL gds.eigenvector.write(
  configuration: Map
)
YIELD
  nodePropertiesWritten: Integer,
  ranIterations: Integer,
  didConverge: Boolean,
  createMillis: Integer,
  computeMillis: Integer,
  writeMillis: Integer,
  centralityDistribution: Map,
  configuration: Map
Table 17. General configuration for algorithm execution on an anonymous graph.
Name Type Default Optional Description

nodeProjection

String, String[] or Map

null

yes

The node projection used for anonymous graph creation via a Native projection.

relationshipProjection

String, String[] or Map

null

yes

The relationship projection used for anonymous graph creation a Native projection.

nodeQuery

String

null

yes

The Cypher query used to select the nodes for anonymous graph creation via a Cypher projection.

relationshipQuery

String

null

yes

The Cypher query used to select the relationships for anonymous graph creation via a Cypher projection.

nodeProperties

String, String[] or Map

null

yes

The node properties to project during anonymous graph creation.

relationshipProperties

String, String[] or Map

null

yes

The relationship properties to project during anonymous graph creation.

concurrency

Integer

4

yes

The number of concurrent threads used for running the algorithm. Also provides the default value for 'readConcurrency' and 'writeConcurrency'.

readConcurrency

Integer

value of 'concurrency'

yes

The number of concurrent threads used for creating the graph.

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.

Table 18. Algorithm specific configuration
Name Type Default Optional Description

maxIterations

Integer

20

yes

The maximum number of iterations of Eigenvector Centrality 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

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

sourceNodes

List or Node or Number

[]

yes

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

scaler

String

None

yes

The name of the scaler applied for the final scores. Supported values are None, MinMax, Max, Mean, Log, L1Norm, L2Norm and StdScore.

The results are the same as for running write mode with a named graph, see the write mode syntax above.

4. Examples

In this section we will show examples of running the Eigenvector Centrality 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:

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

  (home)-[:LINKS {weight: 0.2}]->(about),
  (home)-[:LINKS {weight: 0.2}]->(links),
  (home)-[:LINKS {weight: 0.6}]->(product),
  (about)-[:LINKS {weight: 1.0}]->(home),
  (product)-[:LINKS {weight: 1.0}]->(home),
  (a)-[:LINKS {weight: 1.0}]->(home),
  (b)-[:LINKS {weight: 1.0}]->(home),
  (c)-[:LINKS {weight: 1.0}]->(home),
  (d)-[:LINKS {weight: 1.0}]->(home),
  (links)-[:LINKS {weight: 0.8}]->(home),
  (links)-[:LINKS {weight: 0.05}]->(a),
  (links)-[:LINKS {weight: 0.05}]->(b),
  (links)-[:LINKS {weight: 0.05}]->(c),
  (links)-[:LINKS {weight: 0.05}]->(d);

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

In the examples below we will use named graphs and native projections as the norm. However, anonymous graphs and/or Cypher projections can also be used.

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

4.1. 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.eigenvector.write.estimate('myGraph', {
  writeProperty: 'centrality',
  maxIterations: 20
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory
Table 19. Results
nodeCount relationshipCount bytesMin bytesMax requiredMemory

8

14

696

696

"696 Bytes"

4.2. 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.eigenvector.stream('myGraph')
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC
Table 20. Results
name score

"Home"

0.7465574981728249

"About"

0.33997520529777137

"Links"

0.33997520529777137

"Product"

0.33997520529777137

"Site A"

0.15484062876886298

"Site B"

0.15484062876886298

"Site C"

0.15484062876886298

"Site D"

0.15484062876886298

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

4.3. 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.eigenvector.stats('myGraph', {
  maxIterations: 20
})
YIELD centralityDistribution
RETURN centralityDistribution.max AS max
Table 21. Results
max

0.7465581893920898

4.4. 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.eigenvector.mutate('myGraph', {
  maxIterations: 20,
  mutateProperty: 'centrality'
})
YIELD nodePropertiesWritten, ranIterations
Table 22. Results
nodePropertiesWritten ranIterations

8

20

4.5. 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.eigenvector.write('myGraph', {
  maxIterations: 20,
  writeProperty: 'centrality'
})
YIELD nodePropertiesWritten, ranIterations
Table 23. Results
nodePropertiesWritten ranIterations

8

20

4.6. 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.eigenvector.stream('myGraph', {
  maxIterations: 20,
  relationshipWeightProperty: 'weight'
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC
Table 24. Results
name score

"Home"

0.8328163407319487

"Product"

0.5004775834976313

"About"

0.1668258611658771

"Links"

0.1668258611658771

"Site A"

0.008327591469710233

"Site B"

0.008327591469710233

"Site C"

0.008327591469710233

"Site D"

0.008327591469710233

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.

4.7. 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.eigenvector.stream('myGraph', {
  maxIterations: 20,
  tolerance: 0.1
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC
Table 25. Results
name score

"Home"

0.7108273818583551

"About"

0.3719400001993262

"Links"

0.3719400001993262

"Product"

0.3719400001993262

"Site A"

0.14116155811301126

"Site B"

0.14116155811301126

"Site C"

0.14116155811301126

"Site D"

0.14116155811301126

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

4.8. Personalised Eigenvector Centrality

Personalized Eigenvector Centrality is a variation of Eigenvector Centrality 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'.

The following will run the algorithm and stream results:
MATCH (siteA:Page {name: 'Site A'}), (siteB:Page {name: 'Site B'})
CALL gds.eigenvector.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 26. Results
name score

"Home"

0.7465645391567868

"About"

0.33997203172449453

"Links"

0.33997203172449453

"Product"

0.33997203172449453

"Site A"

0.15483736775159632

"Site B"

0.15483736775159632

"Site C"

0.15483736775159632

"Site D"

0.15483736775159632

4.9. Scaling centrality scores

Internally, centrality scores are scaled after each iteration using L2 normalization. As a consequence, the final values are already normalized. This behavior cannot be changed as it is part of the power iteration method.

However, to normalize the final scores as part of the algorithm execution, one can use the scaler configuration parameter. A common scaler is the L1Norm, which normalizes each score to a value between 0 and 1. 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.eigenvector.stream('myGraph', {
  scaler: "L1Norm"
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC
Table 27. Results
name score

"Home"

0.31291106560043064

"About"

0.1424967320371402

"Links"

0.1424967320371402

"Product"

0.1424967320371402

"Site A"

0.06489968457203725

"Site B"

0.06489968457203725

"Site C"

0.06489968457203725

"Site D"

0.06489968457203725

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