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

Eigenvector Centrality is an algorithm that measures the **transitive** influence or connectivity of nodes.

Relationships to high-scoring nodes contribute more to the score of a node than connections to low-scoring nodes. A high score means that a node is connected to other nodes that have high scores.

This algorithm is in the alpha tier.
For more information on algorithm tiers, see Chapter 6, *Algorithms*.

This section includes:

Eigenvector Centrality was proposed by Phillip Bonacich, in his 1986 paper Power and Centrality: A Family of Measures. It was the first of the centrality measures that considered the transitive importance of a node in a graph, rather than only considering its direct importance.

Eigenvector Centrality can be used in many of the same use cases as the Page Rank algorithm.

The following will run the algorithm and write back results:

```
CALL gds.alpha.eigenvector.write(configuration: Map)
YIELD nodes, iterations, dampingFactor, writeProperty, createMillis, computeMillis, writeMillis, centralityDistribution
```

Name | Type | Default | Optional | Description |
---|---|---|---|---|

concurrency |
int |
4 |
yes |
The number of concurrent threads used for running the algorithm. Also provides the default value for 'readConcurrency' and 'writeConcurrency'. |

readConcurrency |
int |
value of 'concurrency' |
yes |
The number of concurrent threads used for reading the graph. |

writeConcurrency |
int |
value of 'concurrency' |
yes |
The number of concurrent threads used for writing the result. |

normalization |
string |
null |
yes |
The type of normalization to apply to the results. Valid values are |

maxIterations |
int |
20 |
yes |
The maximum number of iterations of EigenvectorCentrality to run. |

sourceNodes |
list<node> |
empty list |
yes |
A list of nodes to start the computation from. |

Name | Type | Description |
---|---|---|

nodes |
int |
The number of nodes considered. |

iterations |
int |
The number of iterations run. |

dampingFactor |
float |
The damping factor used. |

writeProperty |
string |
The property name written back to. |

createMillis |
int |
Milliseconds for loading data. |

computeMillis |
int |
Milliseconds for running the algorithm. |

writeMillis |
int |
Milliseconds for writing result data back. |

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

The following will run the algorithm and stream results:

```
CALL gds.alpha.eigenvector.stream(configuration: Map)
YIELD node, score
```

Name | Type | Default | Optional | Description |
---|---|---|---|---|

concurrency |
int |
4 |
yes |
The number of concurrent threads used for running the algorithm. Also provides the default value for 'readConcurrency'. |

readConcurrency |
int |
value of 'concurrency' |
yes |
The number of concurrent threads used for reading the graph. |

normalization |
string |
null |
yes |
The type of normalization to apply to the results. Valid values are |

maxIterations |
int |
20 |
yes |
The maximum number of iterations of EigenvectorCentrality to run. |

sourceNodes |
list<node> |
empty list |
yes |
A list f nodes to start the computation from. |

Name | Type | Description |
---|---|---|

nodeId |
long |
Node ID |

score |
float |
Eigenvector Centrality weight |

This sample will explain the Eigenvector Centrality algorithm, using a simple graph:

The following will create a sample graph:

```
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]->(about),
(about)-[:LINKS]->(home),
(product)-[:LINKS]->(home),
(home)-[:LINKS]->(product),
(links)-[:LINKS]->(home),
(home)-[:LINKS]->(links),
(links)-[:LINKS]->(a),
(a)-[:LINKS]->(home),
(links)-[:LINKS]->(b),
(b)-[:LINKS]->(home),
(links)-[:LINKS]->(c),
(c)-[:LINKS]->(home),
(links)-[:LINKS]->(d),
(d)-[:LINKS]->(home)
```

The following will run the algorithm and stream results:

```
CALL gds.alpha.eigenvector.stream({
nodeProjection: 'Page',
relationshipProjection: 'LINKS'
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS page, score
ORDER BY score DESC
```

page | score |
---|---|

"Home" |
31.458663403987885 |

"About" |
14.403928011655807 |

"Product" |
14.403928011655807 |

"Links" |
14.403928011655807 |

"Site A" |
6.572431668639183 |

"Site B" |
6.572431668639183 |

"Site C" |
6.572431668639183 |

"Site D" |
6.572431668639183 |

As we might expect, the *Home* page has the highest Eigenvector Centrality because it has incoming links from all other pages.
We can also see that it’s not only the number of incoming links that is important, but also the importance of the pages behind
those links.

The following will run the algorithm and write back results:

```
CALL gds.alpha.eigenvector.write({
nodeProjection: 'Page',
relationshipProjection: 'LINKS',
writeProperty: 'eigenvector'
})
YIELD nodes, iterations, dampingFactor, writeProperty
```

nodes | iterations | dampingFactor | writeProperty |
---|---|---|---|

8 |
20 |
1.0 |
"eigenvector" |

By default, the scores returned by the Eigenvector Centrality are not normalized.
We can specify a normalization using the `normalization`

parameter.
The algorithm supports the following options:

`max`

- divide all scores by the maximum score`l1norm`

- normalize scores so that they sum up to 1`l2norm`

- divide each score by the square root of the squared sum of all scores

The following will run the algorithm and stream results using `max`

normalization:

```
CALL gds.alpha.eigenvector.stream({
nodeProjection: 'Page',
relationshipProjection: 'LINKS',
normalization: 'max'
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS page, score
ORDER BY score DESC
```

page | score |
---|---|

"Home" |
1.0 |

"About" |
0.4578684042192931 |

"Product" |
0.4578684042192931 |

"Links" |
0.4578684042192931 |

"Site A" |
0.20892278811203477 |

"Site B" |
0.20892278811203477 |

"Site C" |
0.20892278811203477 |

"Site D" |
0.20892278811203477 |

If node label and relationship type are not selective enough to create the graph projection to run the algorithm on, you can use Cypher queries to project your graph. This can also be used to run algorithms on a virtual graph. You can learn more in the Section 4.3, “Cypher projection” section of the manual.

Use `nodeQuery`

and `relationshipQuery`

in the config:

```
CALL gds.alpha.eigenvector.write({
nodeQuery: 'MATCH (p:Page) RETURN id(p) AS id',
relationshipQuery: 'MATCH (p1:Page)-[:LINKS]->(p2:Page) RETURN id(p1) AS source, id(p2) AS target',
maxIterations: 5
})
YIELD nodes, iterations, dampingFactor, writeProperty
```

The Eigenvector Centrality algorithm supports the following graph types:

- ✓ directed, unweighted
- [] directed, weighted
- ✓ undirected, unweighted
- [] undirected, weighted