0

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:

  1. 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 ^^^

  1. 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

Lakeside52
  • 159
  • 1
  • 2
  • 7
  • please give us your GDS version, Neo4j version, sample data, expected result and the result that is not working for you. Thanks. – jose_bacoy Jul 21 '22 at 17:10
  • 1
    How do you construct the pbref graph? – Tomaž Bratanič Jul 21 '22 at 19:24
  • The GDS version is 2.0.3 and the expected result is to create communities based on the number of occurrences of words within the publications. The 'publications' are the 'abstract' texts from research papers and there needs to be more than 5 occurrences of the same word (not including stop-words) – Lakeside52 Jul 22 '22 at 09:10
  • The graph is constructed by doing a graph projection. But how to construct the graph is something I'm not fully understanding perhaps. Any ideas @TomažBratanič ? – Lakeside52 Jul 24 '22 at 09:24
  • Or @jose_bacoy ? – Lakeside52 Jul 24 '22 at 09:24

0 Answers0