neo4j实现Eigenvector Centrality算法

文章目录

  • 创建一个属性图
  • 一、属性图如下
  • 二、实现算法
    • 1.stream模式执行算法
    • 2.结果如下
    • 3.max:divide all scores by the maximum score(所有得分比上最高得分)
    • 4.结果如下
    • 5.l1norm:normalize scores so that they sum up to 1(归一化分数,加一起为1)
    • 6.结果如下
    • 7.l2norm:divide each score by the square root of the squared sum of all scores(将每个分数除以所有分数平方和的平方根)
    • 8.结果如下
  • 总结


创建一个属性图

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)

一、属性图如下

neo4j实现Eigenvector Centrality算法_第1张图片

二、实现算法

1.stream模式执行算法

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

2.结果如下

neo4j实现Eigenvector Centrality算法_第2张图片

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.
home具有最高的特征向量中心度,因为它具有来自所有其他页面的传入链接。我们还可以看到,不仅重要的传入链接数量很重要,而且这些链接后面的页面也很重要。

3.max:divide all scores by the maximum score(所有得分比上最高得分)

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

4.结果如下

neo4j实现Eigenvector Centrality算法_第3张图片

5.l1norm:normalize scores so that they sum up to 1(归一化分数,加一起为1)

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

6.结果如下

neo4j实现Eigenvector Centrality算法_第4张图片

7.l2norm:divide each score by the square root of the squared sum of all scores(将每个分数除以所有分数平方和的平方根)

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

8.结果如下

neo4j实现Eigenvector Centrality算法_第5张图片

总结

该算法支持有向和无向的无权图,更关注节点的得分,相比于PageRank,后者更关注关系的权重。其数学本质就是计算特征向量,特征向量里面的元素就是对应位置的点的特征向量中心性。
neo4j实现Eigenvector Centrality算法_第6张图片
上面这个截图来自链接:https://www.cnblogs.com/baiyunwanglai/p/13228813.html其中讲解了Eigenvector Centrality算法的数学原理和其他中心性算法的知识,总结的很好。如果有需要,可以移步去观看学习。

你可能感兴趣的:(neo4j,nosql)