neo4j社区发现算法(Community detection algorithms)-4.The Triangle Counting / Clustering Coefficient

一.介绍
    聚集系数算法,在图论中,聚集系数表示一个图形中节点聚集程度的系数,具体来说,是一个点的邻接点之间相互连接的程度。证据显示,在现实网络中,尤其是在特定的网络中,由于相对高密度连接点的关系,节点总是趋向于建立一组严密组织关系。
  聚集系数可分为全局聚集和局部聚集:
    全局聚集:
    全局聚集系数是基于节点三元组的,三元组分为开放的和封闭的,开放的是指三个节点由两条边连接,封闭的是指三个节点由三条边连接。全局聚集系数是所有三元组中封闭三元组的数目。
    全局聚集系数是封闭的三元组数目/所有三元组数目
    局部聚集:
    局部聚集系数针对的是节点,一个节点的局部集聚系数是他的邻居节点也被链接的可能性
二.neo4j算法:

CALL algo.triangle.stream(label:String, relationship:String, {concurrency:4})
YIELD nodeA, nodeB, nodeC
返回的是节点
CALL algo.triangleCount.stream(label:String, relationship:String, {concurrency:4}) 
YIELD nodeId, triangles,coefficient
返回节点的聚集系数

三.实例:

MERGE (alice:Person{id:"Alice"})
MERGE (michael:Person{id:"Michael"})
MERGE (karin:Person{id:"Karin"})
MERGE (chris:Person{id:"Chris"})
MERGE (will:Person{id:"Will"})
MERGE (mark:Person{id:"Mark"})
MERGE (michael)-[:KNOWS]->(karin)
MERGE (michael)-[:KNOWS]->(chris)
MERGE (will)-[:KNOWS]->(michael)
MERGE (mark)-[:KNOWS]->(michael)
MERGE (mark)-[:KNOWS]->(will)
MERGE (alice)-[:KNOWS]->(michael)
MERGE (will)-[:KNOWS]->(chris)
MERGE (chris)-[:KNOWS]->(karin);

在这里插入图片描述

CALL algo.triangle.stream('Person','KNOWS')
YIELD nodeA,nodeB,nodeC
RETURN algo.getNodeById(nodeA).id AS nodeA, algo.getNodeById(nodeB).id AS nodeB,algo.getNodeById(nodeC).id AS node

在这里插入图片描述

CALL algo.triangleCount.stream('Person', 'KNOWS', {concurrency:4})
YIELD nodeId, triangles, coefficient
RETURN algo.getNodeById(nodeId).id AS name, triangles, coefficient
ORDER BY coefficient DESC

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值