Reputation: 251
So I saw this StackOverflow post on how to get all nodes in a certain distance depth. Neo4j/Gremlin/Cypher: how to get all nodes until i reach a certain distance (depth) in a map-like setup?
However, I want to also visualize this collection of nodes. However, the resulting query
MATCH (n { handle: '" + handle + "' })-[r:EDGE*1..4]->x "
"RETURN r, n.handle,x.handle")
n will give me the starting node, and x will give me the very last node of every path. r gives me a list of relationships. I want to see a list of the intermediate nodes in every path. However, it seems the relationships are stored in urls and it seems inefficient to crawl every URL and parse it.
Is there a way to construct the query so that I can get the intermediate nodes in a path?
Upvotes: 2
Views: 690
Reputation: 41706
You can return the paths or the nodes of the path as you'd like.
MATCH path = (n:Label { handle: {handle} })-[r:EDGE*1..4]->(x)
RETURN r, n.handle,x.handle, path, nodes(path)
Upvotes: 1