O'Reilly logo

Neo4j Cookbook by Ankur Goel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding mutual friends with Neo4j

Sally and John are Facebook friends. Now, find out the people who are friends with both Sally and John. This is also known as the mutual friend problem.

In this recipe, you will learn how to find mutual friends between two people.

Getting ready

Perform the following steps to get ready for this recipe:

  1. Install Neo4j on your machine using the recipes from Chapter 1, Getting Started with Neo4j.
  2. Use the following Cypher script to create the dataset for this recipe:
    CREATE
        (bradley:User {name:'Bradley', surname:'Green', age:24, city:'Los Angeles'}),
        (matthew:User {name:'Matthew', surname:'Cooper', age:36, city:'Los Angeles'}),
        (lisa:User {name:'Lisa', surname:'Adams', age:15, city:'New York'}),
     (annie:User {name:'Annie', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required