2

How does Facebook calculate mutual friends?

Does it cache all mutual friends for each user? Does it use MySQL to calculate mutual friends with a query?

13

According to Facebook,

Mutual friends are the people who are Facebook friends with both you and the person whose profile you are viewing. For instance, if you are friends with Chris, and Mark is friends with Chris, then Chris will be shown as a mutual friend when you are viewing Mark's profile.

So, the set of mutual friends is the intersection of the set of your friends and the set of friends of the person you are viewing. If we assume that Facebook maintains an active cache of your friends, then when you view a person's page, another list containing that person's friends is retrieved, and the intersection of these two lists is the list of mutual friends.

  • 1
    Who knew that Charles Dickens would be so prophetic? – user251748 Sep 14 '17 at 20:05
  • What?? Very Simple, I thought they are using graphs DS to manage them – Thamaraiselvam Apr 26 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.