Lets assume a,b,c and b,d,e and c,f,g, and a,e,g,h are friends .So
get mutual friends b/w a&b:
MATCH (me:User {username:'a'}) -[r:FRIENDS]-(mutualfriends)
-[r:FRIENDS]- (u:User {username:'b'})
RETURn mutualfriends
Now how to get all common friends from above and user 'a' ?
Also can we do all this in one query ?I really appreciate any help.
答案 0 :(得分:3)
r
twice, otherwise you won't get the correct results for mutual-friends. Actually you don't need r
at all.you just continue to match.
MATCH (me:User {username:'a'})-[:FRIENDS]-(mf)-[:FRIENDS]-(u:User {username:'b'})
WITH distinct me, mf
MATCH (me)-[:FRIENDS]-(mmf)-[:FRIENDS]-(mf)
RETURN distinct mmf