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.

GDS create a specific sub graphs

Hi,
I'm trying create a sub graph for specific id and later calculate pagerank:

call gds.graph.create.cypher('teste','match (p)-[r]-(p2) return id(p) as id','match (p:Person{id:123456})-[r*3]-(p2) return id(p) as source, id(p2) as target')

A graph is created in memory with 8804 thousand nodes 728 relationships:

2X_1_12972305f938326329ce2eb4fbaa88dfb7098280.png

But the id: 123456 doesn't have all these nodes and relationships, what am I doing wrong???

2 REPLIES 2

This part of the query means that it will look for relationships 3 hops away from 123456 rather than just its immediate neighbours. If that isn't what you want to do, remove the *3. Or are you saying that 123456 doesn't have those neighbours even at 3 hops?

Also on that first query you aren't doing any filtering of which nodes should be included. It's including all nodes that have a relationship, which likely is all nodes in the graph.

Thanks for your reply.

Id 123456 does have those neighbours. Should I invert the query??

call gds.graph.create.cypher('teste','match (p:Person{id:123456})-[r*3]-(p2) return id(p2) as id, match (p)-[r]-(p2) return id(p) as source, id(p2) as target)

It's correct ??