cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Algorithm queries in latest version of Neo4j - GDS syntax update

stephflint
Node Clone

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

 

 

Any help much appreciated!

1 REPLY 1

Best to check out the docs, afaik there is also a migration part

the GDS library now works exclusively on in-memory graphs that are prepared under a name,

so you cannot any longer project and run the algorithm in one go, you need to project the data first and then run any number of algorithms, filters, ml-algos or prediction pipelines on the in-memory graph(s).

https://neo4j.com/docs/graph-data-science/current/common-usage/

https://neo4j.com/docs/graph-data-science/current/appendix-b/