### 6.2.7. Eigenvector Centrality

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:

#### 6.2.7.1. History and explanation

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.

#### 6.2.7.2. Use-cases - when to use the Eigenvector Centrality algorithm

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

#### 6.2.7.3. Syntax

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``````

Table 6.79. Configuration
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'.

int

value of 'concurrency'

yes

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 `max`, `l1norm`, `l2norm`.

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.

Table 6.80. Results
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

computeMillis

int

Milliseconds for running the algorithm.

writeMillis

int

Milliseconds for writing result data back.

The following will run the algorithm and stream results:

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

Table 6.81. Configuration
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'.

int

value of 'concurrency'

yes

normalization

string

null

yes

The type of normalization to apply to the results. Valid values are `max`, `l1norm`, `l2norm`.

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.

Table 6.82. Results
Name Type Description

nodeId

long

Node ID

score

float

Eigenvector Centrality weight

#### 6.2.7.4. Eigenvector Centrality algorithm sample

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

``````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'}),

The following will run the algorithm and stream results:

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

Table 6.83. Results
page score

"Home"

31.458663403987885

14.403928011655807

"Product"

14.403928011655807

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',
writeProperty: 'eigenvector'
})
YIELD nodes, iterations, dampingFactor, writeProperty``````

Table 6.84. Results
nodes iterations dampingFactor writeProperty

0

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',
normalization: 'max'
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS page, score
ORDER BY score DESC``````

Table 6.85. Results
page score

"Home"

1.0

0.4578684042192931

"Product"

0.4578684042192931

0.4578684042192931

"Site A"

0.20892278811203477

"Site B"

0.20892278811203477

"Site C"

0.20892278811203477

"Site D"

0.20892278811203477

#### 6.2.7.5. Cypher projection

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``````

#### 6.2.7.6. Graph type support

The Eigenvector Centrality algorithm supports the following graph types:

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