GDS create a specific sub graphs

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:


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

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 ??