AlgoViz

Design a LinkedIn-style connection graph

hard 55 min

Store who is connected to whom for a billion people, and say in a blink whether a stranger is a 1st, 2nd or 3rd degree connection.

Where it shows up

The same pattern appears across everyday software.

  • Profile badges

    A profile on LinkedIn shows 1st, 2nd or 3rd beside the name. LinkedIn's help pages define these as direct connections, their connections, and the next hop.

  • A cap on list length

    LinkedIn's help page states a maximum of 30,000 first-degree connections. A cap like that bounds the worst supernode, which makes exact answers affordable.

  • Warm introductions

    A sales tool shows which colleague knows the buyer. That is the mutual connection list between two people, or between a team and a person.

  • Fraud rings

    Banks look for accounts that share phones, addresses or cards within two hops. The same list overlap finds them.

  • A purpose-built graph store

    LinkedIn's engineering blog describes LIquid as a log-structured, in-memory inverted index of edges, built so that following edges costs about as much as following pointers.

  • Social graph caching at Facebook

    The TAO paper (USENIX ATC 2013) describes a distributed store made for a fixed set of social graph queries, which replaced memcache for many data types.

  • Who can reach whom in access control

    Permission systems ask whether a person reaches a document through groups inside groups. Short paths over nested sets, again.