基于Neo4j计算网络节点中心性(Closeness、betweenness Centrality)

使用Neo4j计算节点中心性——紧密度中心性(Closeness Centrality)、介数中心性(betweenness Centrality),适用于v3.5 以上的Graph Algorithms plugin。

一、计算紧密度中心性

CALL algo.closeness.stream('v','same-sentence',{direction:'out'})

YIELD nodeId, centrality

MATCH (word:v) WHERE id(word) = nodeId

RETURN word.name AS word,centrality

ORDER BY centrality DESC;

参考:https://neo4j.com/docs/graph-algorithms/current/labs-algorithms/closeness-centrality/

 

二、计算介数中心性

CALL algo.betweenness.stream('n','same-sentence',{direction:'out'})

YIELD nodeId, centrality

MATCH (word:n) WHERE id(word) = nodeId

RETURN word.name AS word,centrality

ORDER BY centrality DESC;

参考:https://neo4j.com/docs/graph-algorithms/current/labs-algorithms/betweenness-centrality/

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页