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.

Get nodes and relationships path, and get related relation and nodes for a node in the middle of my path

Hi,
I have a path:

(node1)->(node2)->(node3)->(node4)
also, I have "node5" connected to "node2", and "node6" connected to "node3"
2X_5_5af26cfc21f2b51fa583e84b6b9edf7358c11f66.jpeg

Is it possible to get the paths from node1 to node4 with all the nodes and relationships in between, and also all the nodes that are related to node2 and node3 (node5 and node6) with one query?
Thanks!

1 ACCEPTED SOLUTION

Vinoth
Node Clone

Sorry, couldn't understand the requirement here.
Are you looking for an output like:
node1-> node2-> node3 -> node4
node5 -> node2
node6 -> node2

or all nodes together ?

View solution in original post

4 REPLIES 4

ameyasoft
Graph Maven

It depends on the relationship type between (node1 and node2) and (node2-node5). Let me know the type of relationships.

Thank you for the help!
Can you please explain?
Let's say all have "CONTAINS" relationships, directions are like in the diagram:
(node1)-[r:CONTAINS]->(node2)
(node5)-[r:CONTAINS]->(node2)
(node6)-[r:CONTAINS]->(node3)
(node2)-[r:CONTAINS]->(node3)
(node3)-[r:CONTAINS]->(node4)
Thanks

Try this:

MATCH (a:node1)
CALL apoc.path.spanningTree(a, {})
YIELD path
RETURN path

Vinoth
Node Clone

Sorry, couldn't understand the requirement here.
Are you looking for an output like:
node1-> node2-> node3 -> node4
node5 -> node2
node6 -> node2

or all nodes together ?