Neo4j: bring back top 10people with most common friends and a few more complex queries

My graphic database contains users who are friends with each other. (User) -write → (text), (text) -containers → (tag).

Now I want to return the following queries:

  • Bring back the top 10 users who have the most common friend with user X. I have already completed this query: this group of 10 users is named Y

    MATCH (user:User)-[:FOLLOWS]->(mf)<-[:FOLLOWS]-(other)
    
    WHERE user.username = '@majorlyprofound'
    
    WITH other,count(DISTINCT mf) AS mutualFriends
    
    ORDER BY mutualFriends DESC
    
    LIMIT 10
    
    RETURN other
    
  • Return the top 10 users who are friends with group Y but not friends with X. “Friend with group Y” means that the user has as many friends in group Y (maximum 10).

  • 10 , Y, X. , X. , X , , .

, 3 , . .

+3

All Articles