Assume i have graph relations defined as A->B, A->D, C->A, B->C, B->D. I need to get the following subgraph in Neo4j -
For the 1st part, I have the following query -
MATCH (s:Node)->(d:Node)
WHERE s.name = 'A' OR d.name = 'A'
I'm not able to get the 2nd part of the data in the same query. Do i need to iterate through all the nodes?
This is a simple pattern that says that you start the path from the node, then go to the node next to it, then one of which you can return to the starter node:
MATCH (A:Node {name:'A'}) WITH A
MATCH (A)--(FD1:Node)-[r]-(FD2:Node)--(A)
WHERE ID(FD1) > ID(FD2)
RETURN FD1, r, FD2
PS And remember that you can not specify the direction of the relationship.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.