Reputation: 8423
I need to find connections between all the nodes (with a "Hashtag" label) connected to the main user node.
So far, I came up with a solution like this, but it seems to me a bit inefficient, because I traverse the graph twice to first find c1 and then c2.
Anybody has better ideas?
MATCH (u:User{uid:"777"}), (c1:Hashtag), (c2:Hashtag),
c1-[:BY]->u, c2-[:BY]->u, c1-[rel:TO]->c2 RETURN rel,c1,c2;
(I'm working with Neo4J / Cypher 2.0)
Upvotes: 1
Views: 298
Reputation: 1874
Try this, play around with it and let me know the output.
MATCH (u:User {uid:"777"})
WITH u
MATCH u<-[:BY]-(c1:Hashtag)-[rel:TO]-(c2:Hashtag)--(u)
RETURN rel, c1, c2
Basically, the idea here is as follow:
Upvotes: 2