问题描述
我有一组通过 :connected_to 相互连接的节点 IP 地址,我想在它们上实现标签传播算法。但是运行下面的命令后没有结果
CALL algo.labelPropagation('Node','connected_to','OUTGOING'(write:true,partitionProperty:'community',weightProperty:'count'))
解决方法
如果可以,请使用 GDS 库。
1.创建命名图。
如果您真的只有 :Node
标签,那么您可能想要处理这个问题。 (:设备?,:网关?等)
CALL gds.graph.create('projection','*','*')
// CALL gds.graph.create('projection',['Device','Gateway','Node'],'connected_to')
YIELD graphName,nodeCount,relationshipCount;
2.运行投影
CALL gds.labelPropagation.stream('projection')
YIELD nodeId,communityId AS Community
RETURN gds.util.asNode(nodeId).ip AS IP,Community
ORDER BY Community,IP
3.如果你愿意,可以改变你的图表。
CALL gds.labelPropagation.stream('projection')
YIELD nodeId,communityId AS Community
WITH gds.util.asNode(nodeId).ip AS IP,Community
MATCH (x:Node {ip: IP})
SET x.community = Community
RETURN Community,count(DISTINCT x)
来源: