I'm trying to create a graph projection and use different GDS algorithms on the latest version of Neo4j - the previous algorithms were made using the pre-GDS syntax.
I'd like to project a new graph to perform community detection from the in-memory graph but am unsure how to translate the previous syntax into a graph projection in order to then perform the LPA.
Previous syntax (works on pre-GDS version):
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
My attempt:
- Graph projection
CALL gds.labelPropagation.stream('pbRef')
YIELD nodeId, communityId
RETURN gds.util.asNode(nodeId).name AS name, communityId;
I may be missing something here ^^^
- LPA stream
CALL gds.labelPropagation.stream('pbRef')
YIELD nodeId, communityId AS Community
RETURN gds.util.asNode(nodeId).name AS Name, Community
ORDER BY Community, Name
The following part works but maybe it has to be within one of the previous steps?
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
I'm missing something to get it working. Does anyone have any insight into this?
Thanks in advance