Finding friends of friends with Neo4j
If you have used Facebook or LinkedIn, you must have seen something such as "People you may know". This feature can be implemented using various different algorithms; most common are mutual friends, common interests, common location, and so on.
In this recipe, you will learn how to implement these algorithms and implement this feature with Neo4j.
Getting ready
The steps required for this recipe are similar to the steps described in the first recipe of this chapter. We are adding one more field, Interest
, to find friends based on mutual interests. Apart from the Cypher query used in the first recipe of this chapter, we add the following nodes and relationships in a similar Cypher query, as shown here:
CREATE (music:Interest {name : 'music'}), (sports:Interest {name : 'sports'}), (dance:Interest {name : 'dance'}), //INTEREST (bradley)-[:INTEREST]->(music), (bradley)-[:INTEREST]->(dance), (john)-[:INTEREST...