Every computer science student learns the basics of graph theory–a set of mathematical abstractions for modeling networks and the connections within them. But few developers ever work with network data on the scale of Facebook’s social graph, with its more than 1 billion users and hundreds of billions of connections, or edges, between them. So in 2012, when Facebook engineers started thinking in earnest about ways to efficiently process all the network data they’d amassed, they found themselves in uncharted territory.

“As far as I know, there’s been no work to be cited working with graphs as large as a half a trillion or a trillion edges,” says Facebook engineer Avery Ching.

But Facebook still wanted to be able to measure basic statistics about their users’ connections, and efficiently do computations like measuring affinities between users to suggest potential friends, or finding mutual friends of sets of users. To make this possible, they turned to an open source graph theory toolkit called Apache Giraph, derived from code originally donated to the Apache Software Foundation by Yahoo.

Making Giraph work at Facebook’s scale required a bit of engineering, which Facebook documented on a company blog and contributed back to the open source effort, but Giraph’s overall computing model proved to be the ticket to parallelizing huge network graph computations across Facebook’s servers.

“It was really easy for us to use,” Ching says. “The model itself was very expressive–it allowed you to do a lot of different things.”

Giraph is based on what’s called the bulk synchronous parallel model, a class of parallel computing algorithm developed in the 1980s by researchers led by Harvard computer science professor Leslie Valiant. BSP algorithms take place across multiple computers over a series of steps, and at each step, each computer does a bit of computation and, if it wishes, sends messages about its results to others in the system, which they can incorporate into their computations at the next step.

In Giraph’s case, the individual computations are done as if from the perspective of the individual nodes, or vertices, of a graph. And at the end of each step, each node can choose whether to send a message to its immediate neighbors. Before Giraph, that model had been proposed in a Google paper describing an internal tool called Pregel, and Facebook engineers found it’s an easy way to describe many graph theory problems in a way that makes them possible to parallelize, by having different computers handle simultaneous computation on behalf of different sets of nodes.