If I do:
MATCH (x:NODE {x.name: "Node1"})-[r:REL1]-(y:NODE) return x,r,y
How do I then find all the REL1
relationships amongst the set of x
and y
nodes?
EDIT:
Based on the answers I think the question wasn't clear.
Example graph:
create (:T1 {name:1}), (:T1 {name:2}), (:T1 {name:3}), (:T1 {name:4}), (:T1 {name:5}), (:T1 {name:6}), (:T1 {name:7})
match (a:T1 {name:1}), (b:T1 {name:2}) create (a)-[r:REL1]->(b)
match (a:T1 {name:1}), (b:T1 {name:3}) create (a)-[r:REL1]->(b)
match (a:T1 {name:5}), (b:T1 {name:4}) create (a)-[r:REL1]->(b)
match (a:T1 {name:5}), (b:T1 {name:3}) create (a)-[r:REL1]->(b)
match (a:T1 {name:5}), (b:T1 {name:2}) create (a)-[r:REL1]->(b)
match (a:T1 {name:5}), (b:T1 {name:1}) create (a)-[r:REL1]->(b)
match (a:T1 {name:7}), (b:T1 {name:6}) create (a)-[r:REL2]->(b)
match (a:T1 {name:7}), (b:T1 {name:5}) create (a)-[r:REL2]->(b)
match (a:T1 {name:7}), (b:T1 {name:4}) create (a)-[r:REL2]->(b)
match (a:T1 {name:7}), (b:T1 {name:3}) create (a)-[r:REL2]->(b)
I'm going to find everything that has a REL1
relationship with node name:5
. I want to also find all the REL1
relationships amongst the returned nodes.
So I should get
5->4
5->3
5->2
5->1
1->2
1->3
But not
7->5
7->4
7->3
Because those are REL2
relationships.
So I think I can do it like this:
match (a:T1 {name: 5})-[b:REL1]->(c:T1) return a,b,c
union match (a:T1)-[b:REL1]-(c:T1) return a,b,c
But the problem is that the graph I'm working with is really large, so this seems quite inefficient. I'd prefer to be able to
- Select a set of nodes (everything connected to
5
) - Find all the connections amongst those nodes
x.name
cannot be used that way, since a property name cannot contain a period -- unless you use back-ticks to quote the name. Did you mean to usename
instead? And what do you mean by "amongst the set of x and y nodes"? Do you want to get all theREL1
relationships between each distinctx
andy
pair? – cybersam