In this article
  1. Before you start
  2. Why interviewers ask this
  3. People You May Know from first principles
  4. Worked example
  5. Trade-offs and edge cases
  6. How to answer it in an interview
  7. Common mistakes
  8. Follow-up questions
  9. Sources

Before you start

This page is one design problem inside the recommendation system design learning path.

Why interviewers ask this

A people-recommendation prompt tests whether a candidate can turn a vague product feature into a pipeline with a clear purpose, a graph-based first stage, a learned second stage and honest limits. Candidates report variants of it for social apps, professional networks and even hiring platforms, so the framing step matters: ask whether the goal is more connections, more engagement, or help finding people who share interests.

A weak answer says "count mutual friends and sort." A strong answer separates candidate generation from ranking, names the cold-start and privacy problems, and says how success is measured. A Staff-level answer adds what the feature does to the network: popular accounts can collect most of the attention, and a recommender can treat groups of people unequally. The sections below build each of those pieces from zero.

People You May Know from first principles

Link prediction is the task of estimating which pairs of people in a social network who are not yet connected will become connected, such as a new friendship or follow, using only the structure of the network and the information attached to its nodes and edges.
Triadic closure
Triadic closure is the tendency of two people who share a friend to become friends themselves, closing a triangle of three connections; it is the main reason friends of friends are good candidates for a new connection.
Adamic-Adar score
The Adamic-Adar score of a candidate is the sum, over every person the user and the candidate both know, of one divided by the logarithm of that person's number of connections, so a shared acquaintance with few connections counts for more than a hub.

In plain words

Picture a town where everyone knows a few neighbours. If you and a stranger both know the baker, the florist and the plumber, you will probably meet. If you only both know the mayor, who knows everybody, that tells you little. A PYMK system is a machine that finds such strangers at the scale of millions of people. The analogy breaks in one place: online, the system also has to respect who may be shown to whom, and a real recommender learns from clicks instead of using a fixed rule.

In one precise sentence, PYMK is link prediction on a social graph, followed by a ranking model that orders the surviving candidates for one user. The formal problem is set out in Liben-Nowell and Kleinberg (2007), and the Twitter team describe a production account-suggestion service in Gupta et al. (2013).

Step 1: Candidate generation starts from friends of friends

Candidate generation is the first stage, which cuts all accounts down to a few hundred plausible ones. Input: one user and their connections. Output: a candidate list. The cheapest source is triadic closure: take each connection's connections.

The cost grows fast. With 300 connections each (illustrative), the user has 90,000 two-step paths, and three steps give 27,000,000 paths.1 That is why systems stop at two steps, sample, or use a random walk that favours people close to the user, an idea the Twitter paper uses to build a "circle of trust" around each user (Gupta et al., 2013). Other candidate sources are imported contacts, shared groups or schools, and nearest neighbours of an embedding, as in a two-tower model. You now have a list; the next step asks what kind of edge the list came from.

Step 2: Friend graphs are mutual, follower graphs are directed

A friend graph is undirected: a friendship exists only when both sides agree. A follower graph is directed: one account follows another with no consent from the second. This single difference changes three things.

First, the candidate path. For friends it is friends of friends; for follows it is the accounts that the people you follow also follow. Second, the strongest feature. For friends it is the shared-friend overlap; for follows it is the shape of the audience, such as whether the candidate already follows you. Third, the feedback. A friend suggestion succeeds only when a request is sent and accepted, while a follow succeeds on one tap, so acceptance is a second label to model.

Friend and follower graphs differ in consent and candidatesTable comparing a friend graph and a follower graph by edge type, who must agree, where candidates come from and the strongest feature.QuestionFriend graphFollowergraphEdgemutualone-wayWho must agreeboth peopleonly the followerCandidate pathfriends of friendswho my followsfollowStrong featureshared friendsfollow-backchanceDiagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/design-people-you-may-know-friend-and-follower.html
The edge type decides the candidate path, the consent step and the strongest feature.CC BY 4.0 — source: How do you design a People You May Know friend and follower recommender?
Text description of the diagram
  • A friend graph is mutual and needs both sides to agree.
  • A follower graph is one-way and needs no consent from the followed account.
  • Friend candidates come from friends of friends; follow candidates come from who your follows follow.

Directed graphs also make popular accounts visible to everyone, which is one cause of the exposure imbalance discussed below.

Step 3: Scores compare the overlap between two people

A score turns a candidate into one number. Three classic scores are compared in Liben-Nowell and Kleinberg (2007), and the weighted one comes from Adamic and Adar (2003). The common-neighbour count is the number of shared connections. The Jaccard score divides that count by the number of people connected to either person, so it is not inflated by candidates who know everybody. The Adamic-Adar score weights each shared connection by one over the logarithm of its degree, where degree is the number of connections it has.

AA(u,v)=∑z∈N(u)∩N(v)1lnd(z)

Here N(u) is the set of u's connections and d(z) is z's degree. Input: two people. Output: a number. These scores are fast, explainable baselines, and a learned model uses them as features.

Step 4: A ranking model orders the list and filters remove the rest

The ranker is a supervised model, usually trained on whether a past suggestion led to a connection. Its features are the Step 3 scores plus the number of shared groups, the time since each account was active, the candidate's popularity, and whether the candidate already follows the user. Because one list serves more than one goal (acceptance, later activity, and user comfort), teams often train one model with several outputs, called multi-task ranking. A heavier model that reads both people together can rerank a short list, as in a cross-encoder reranker.

Filters then apply rules the model must never break: remove the people the user already knows, accounts the user blocked or dismissed, and anyone who opted out of being suggested. Input: a few hundred scored candidates. Output: the final short list.

A people recommendation is built in four stepsFlow of four steps: a graph walk finds candidates, the edge type sets the candidate path, overlap scores compare each candidate with the user, and a ranking model plus filters produce the final list. Each step adds one decision.Graph walkfriends offriendsCandidatepathfriend or followpathScoresoverlapfeaturesRank, filtermodel andrulesDiagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/design-people-you-may-know-friend-and-follower.html

Each step adds one decision: where candidates come from, which path the edge type allows, how they score, and what the ranker and filters keep.CC BY 4.0 — source: How do you design a People You May Know friend and follower recommender?
Step-by-step description
  1. A graph walk finds friends of friends.
  2. Mutual or directed edges set the path.
  3. Overlap scores compare each candidate.
  4. A model orders; rules remove accounts.
  • A graph walk finds friends of friends as candidates.
  • The edge type, mutual or directed, changes the candidate path.
  • Overlap scores compare each candidate with the user.
  • A ranking model and filters produce the final list.

Knowing it is half the job. Saying it is the other half.

Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.

Start Free Trial →

Worked example

The toy graph below is illustrative. The user U has four friends: B, C, D and E. B has eight connections in total, C and E have three each, and D has two. Eight candidates share at least one friend with U: X knows B, C and D; Y knows C and E; Z knows B and E; and W and four others (g1 to g4) know only B.1

The Adamic-Adar weights are 0.4809 for B, 0.9102 for C and E, and 1.4427 for D, because B knows many people and D knows few.1 X scores 2.8338, Y 1.8205, Z 1.3911 and W 0.4809. A plain count ties Y and Z at 2 each, but Adamic-Adar puts Y ahead because Y shares two low-degree friends, while Z shares the well-connected B. The Jaccard scores are 0.75 for X, 0.5 for Y and Z, and 0.25 for W and for each of g1 to g4.1 The hub friend B gives g1 to g4 a single shared friend each, the same scores as W, which is why a ranker, not the count, makes the final call.

X ranks first on every score, and only Adamic-Adar breaks the tie between Y and Z.
CandidateShared friendsCommon neighboursJaccardAdamic-Adar
XB, C, D30.752.8338
YC, E20.51.8205
ZB, E20.51.3911
WB10.250.4809
g1–g4 (each)B10.250.4809
Adamic-Adar separates candidates that a shared-friend count tiesGrouped bars for four candidates in an illustrative graph: common neighbours are 3, 2, 2 and 1 for X, Y, Z and W, while Adamic-Adar scores are 2.8338, 1.8205, 1.3911 and 0.4809.Score0123XYZWCandidateCommon neighboursAdamic-Adar32212.83381.82051.39110.4809Diagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/design-people-you-may-know-friend-and-follower.html
Adamic-Adar separates candidates that a plain shared-friend count ties.CC BY 4.0 — source: How do you design a People You May Know friend and follower recommender?
Text description of the diagram
  • Common neighbours are 3 for X, 2 for Y, 2 for Z and 1 for W.
  • Adamic-Adar scores are 2.8338 for X, 1.8205 for Y, 1.3911 for Z and 0.4809 for W.

For a follower graph the same idea changes direction. If U follows B, C, D and E, and those four follow X, Y and Z as in the illustrative lists, then X is followed by three of U's follows, and Y and Z by two each.1

Trade-offs and edge cases

The central trade-off is precision against reach. Tight overlap scores recommend people the user almost certainly knows, which feels accurate but adds few new connections. Looser sources, such as shared interests, find new people but are more often wrong or unwelcome. Reported practice differs between products, and the sources here do not settle it, so state the choice as a goal: which outcome does the feature serve?

Cold start is the first edge case. A new user has no edges, so friends-of-friends finds nothing; the fixes are imported contacts with permission, onboarding interests and broadly popular accounts, covered in the cold start problem.

Privacy is the second. A suggestion can reveal that two people are connected in someone's contacts or that a person looked at a profile, so use only signals the user agreed to share and let people opt out.

Fairness is the third, and it is a frequent follow-up. Demographic parity asks that the share of each group who get a favourable outcome is equal. Disparate impact is the legal idea that a neutral-looking rule can still disadvantage a group, and the federal Uniform Guidelines regard a selection rate below four-fifths of the highest group's rate as evidence of adverse impact.

In a toy hiring recommender (illustrative), 60 of 100 candidates in group A and 36 of 80 in group B are shown to recruiters: rates of 0.6 and 0.45, a gap of 0.15 and a ratio of 0.75, below four-fifths.1 Graph-based systems can create this gap because people tend to connect with similar people, so friends of friends reproduce the existing network.

The fourth is popularity. Hubs collect followers, and a ranker that rewards popularity widens the gap. Remedies include normalising by the candidate's own degree (as Jaccard does), a popularity penalty among the ranking features, and caps on how often one account is suggested.

Serving and training data matter as much as the model. A people recommender usually precomputes candidate lists in a batch job that runs periodically, then refreshes a user's list soon after a new connection, because that connection opens new friends of friends. The ranker needs labels: a positive is a suggestion the user accepted or followed, and a negative is an impression, a suggestion shown with no action.

That makes impression logging essential, since without a record of what was shown, a missing action cannot be told from a suggestion never seen. Suggestion fatigue is the matching product rule: stop showing a person the user dismissed or ignored several times. The last risk is the feedback loop: the model trains on its own past suggestions, so people it never showed never become positives, and exposure narrows unless some suggestions come from other sources or are explored at random.

How to answer it in an interview

Interviewer asks

Design a people-recommendation system for a social app.

A strong answer

First I would clarify the goal, whether it is more mutual friends or help finding accounts to follow. Then two stages. Candidate generation takes friends of friends, contacts the user shared, and embedding neighbours. A ranking model scores them with overlap features such as Adamic-Adar, activity and whether they already follow the user, trained on accepted suggestions. Filters remove blocked and opted-out accounts. The trade-offs are cold start for new users, privacy of imported contacts, and popular accounts taking most exposure, so I would measure acceptance and fairness together.

The spoken structure: clarify the goal, name the two stages, give one concrete feature, then say what breaks.

Common mistakes

  • "I rank by mutual friend count." (wrong) A hub friend inflates the count for everybody. (right) "I weight shared friends by how connected they are, and let a model combine that with other features."
  • "Friend and follow recommendations are the same problem." (wrong) The edge type changes consent and candidates. (right) "A friend needs both sides to accept; a follow is one-way, so I model follow-back and audience shape."
  • "Accuracy on held-out edges tells me the feature works." (wrong) It measures prediction, not value. (right) "I check held-out recall first, then acceptance and later activity in a live test."
  • "A new user just gets popular accounts." (wrong) That ignores permission and relevance. (right) "I combine permitted contact imports, onboarding interests and popular accounts."

Follow-up questions

How would you design a friend recommendation system based on user interactions?

Treat interactions, such as messages, profile views and shared groups, as weighted edges. Generate candidates from strongly weighted neighbours, rank with those weights as features, and filter blocked or opted-out accounts. Use only interactions users expect to be used.

How do friend recommendations differ from follower recommendations?

A friend graph is mutual and needs acceptance, so shared-friend overlap is the strongest signal. A follower graph is one-way, so the candidate path is who your follows follow, and follow-back is a key feature.

How do you recommend people to a brand-new user?

Use signals that need no graph: permitted contacts, stated interests and broadly popular accounts, then switch to graph signals as the first connections arrive.

How do you measure whether the recommendations work?

Hide the newest connections, rank candidates, and measure recall at k on those held-out edges. Then run a live test measuring acceptance rate, later activity and complaints, because held-out accuracy does not equal product success.

How do demographic parity and disparate impact apply to a hiring recommendation system?

Compare how often each group is shown to recruiters, then, if the four-fifths ratio is low, examine features that proxy for group membership and the network effects behind them. The machine learning system design guide covers monitoring of this kind.

Key takeaways
  • PYMK is link prediction on a social graph followed by a learned ranker and rule filters.
  • Friends of friends is the first candidate source because of triadic closure, but it grows quickly with each hop.
  • Friend graphs are mutual and need acceptance; follower graphs are directed and use follow-back features.
  • Adamic-Adar down-weights hub connections, so it separates candidates that a plain count ties.
  • Cold start, privacy, popularity and group fairness are the standard trade-offs to name.

Sources

  1. WTF: The Who to Follow Service at Twitter — WWW 2013 (Gupta, Goel, Lin, Sharma, Wang, Zadeh), 13 May 2013
  2. The Link Prediction Problem for Social Networks — Journal of the American Society for Information Science and Technology (Liben-Nowell, Kleinberg), 1 May 2007
  3. Friends and neighbors on the Web — Social Networks (Adamic, Adar), 1 Jul 2003
  4. Uniform Guidelines on Employee Selection Procedures, part 1607 — Code of Federal Regulations, title 29, 25 Aug 1978