最新版本 Neo4j 中的算法查询 - GDS 语法更新

问题描述 投票:0回答:1

我正在开发一个项目,该项目始于旧版本的 Neo4j (3.5),并且语法略有不同,特别是在算法方面。我正在尝试“更新”以下查询以与 GDS 配合使用:

CALL algo.labelPropagation.stream(
'MATCH (p:Publication) RETURN id(p) as id',
'MATCH (p1:Publication)-[r1:HAS_WORD]->(w)<-[r2:HAS_WORD]-(p2:Publication) 
WHERE r1.occurrence > 5 AND r2.occurrence > 5
RETURN id(p1) as source, id(p2) as target, count(w) as weight',
{graph:'cypher',write:false, weightProperty : "weight"}) yield nodeId, label
with label, collect(algo.asNode(nodeId)) as nodes where size(nodes) > 2
MERGE (c:PublicationLPACommunity {id : label})
FOREACH (n in nodes |
   MERGE (n)-[:IN_LPA_COMMUNITY]->(c)
)
return label, nodes

主要问题可能是第一部分 (algo.labelPropagation) 和 (algo.asNode),因为它们在 GDS 中发生了变化。这是返回的错误:

Procedure call provides too many arguments: got 3 expected no more than 2.

Procedure gds.labelPropagation.stream has signature: gds.labelPropagation.stream(graphName :: STRING?, configuration  =  Map{} :: MAP?) :: nodeId :: INTEGER?, communityId :: INTEGER?
meaning that it expects at least 1 argument of type STRING?
Description: The Label Propagation algorithm is a fast algorithm for finding communities in a graph. (line 1, column 1 (offset: 0))
"CALL gds.labelPropagation.stream("
 ^

如何解决此错误?

algorithm neo4j cypher graph-theory
1个回答
1
投票

根据我所知道的用于在图中查找社区的 LPA 算法的语法,您似乎通过包含 MATCH 语句来使用不同的语法。 流模式的语法可以在Label Propagation

中找到
CALL gds.labelPropagation.stream(
graphName: String,
configuration: Map
)
YIELD
    nodeId: Integer,
    communityId: Integer

您也可以在网站中查看社交网络图的示例

© www.soinside.com 2019 - 2024. All rights reserved.