Reputation: 494
I was looking for the feature to generate some graph queries in neo4j. As the database size is huge so can anyone suggest the procedure to generate small queries (3-5 nodes a -> b -> c ->a). I can run BFS from a node but how can I find the small graph containing only a specific number of nodes as graph structure?
a / \ b-----c----d
Upvotes: 0
Views: 248
Reputation: 67044
[UPDATED]
If you want to get a single arbitrary path of length 4 (having 4 relationships and 5 nodes), and you do not need the path to be unidirectional, then you can simply do this:
MATCH p=()-[*4]-()
RETURN p
LIMIT 1;
If you want the path to be unidirectional (where all relationships point in the same direction), then you just need to specify a direction:
MATCH p=()-[*4]->()
RETURN p
LIMIT 1;
Upvotes: 2