How does Facebook determine the six friends that you see when looking at someone’s profile?

Answer by Yee Lee:

Facebook calculates a "social closeness" score for every pair of nodes in its social graph.  They use this social proximity score to rank each person's friends and this ranking is reflected throughout the site — it's used for determining which people's posts show up in Newsfeed, which mutual friends are shown on Profile pages, which people's Likes and social ads are shown in the right rail, etc.

Since the FB social graph changes every day (e.g., as people add new friends), the social proximity score needs to be updated regularly.

The actual scoring algorithm itself is proprietary to Facebook, but is likely based on traditional social graph distance metrics developed in academia.  E.g., Facebook might take into consideration factors like:

  • # of friends in common that each pair of people shares (e.g., the number of unique 2-edge paths between any two nodes in the graph)
  • the total # of friends that each person has (e.g., if Person A only has 20 Facebook friends and shares all 20 with Person B then A might be considered "closer" to B than, say, to Person C who has 2000 friends and shares 20 mutual friends with A)
  • # of interactions between a pair of people (e.g., if Person A and Person B regularly share mentions/comments/likes with each other, then A might be considered closer to B's friends than, say, to Person C's friends where A and C never comment/like each other's posts)
  • the type of interactions between a pair of people (e.g., if Person A tags Person B in a photo, that might be a stronger signal of closeness than just having some friends in common)
  • pace and recency of interactions between a pair of people (e.g., if Person A has recently checked-in to a location with Person B, that might be a stronger signal of closeness than if they checked-in a year ago and haven't been seen together since)

There are lots and lots of graph structure and interaction signals that can go into a social proximity score!  Note that similar techniques/algorithms are utilized by just about every company that works on social apps and communication products.  E.g., Google utilizes this type of scoring/ranking when they suggest email addresses to include in the "To:" line of a GMail message.  E.g., Zynga utilizes this type of scoring when they suggest friends to invite to a social game.

View Answer on Quora