Lakeside52
Lakeside52

Reputation: 519

Algorithm queries in latest version of Neo4j - GDS syntax updates

I'm working on a project that began on an older version of Neo4j (3.5) and has slightly different syntax, particularly regarding algorithms. I'm trying to 'update' the following query to work with 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

The main issues are likely the first part (algo.labelPropagation) and (algo.asNode) since these have changed in GDS. Here is the error that is returned:

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("
 ^

How can I resolve this error?

Upvotes: 1

Views: 94

Answers (1)

Roy Awill
Roy Awill

Reputation: 192

According to the syntax I know about the LPA algorithm, which is used for finding communities in a graph, it seems you are using a different syntax by including MATCH statement. You can find the syntax of the stream mode in Label Propagation

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

You can check the exapmle of the social network graph in the website as well

Upvotes: 1

Related Questions