1. A method comprising: receiving a query graph that includes a plurality of query nodes; selecting a first query node from among the plurality of query nodes; storing a first data structure that is accessible to a first plurality of threads; for each thread in the first plurality of threads: assigning, to said each thread, a different set of nodes in a particular graph; identifying, in the set of nodes assigned to said each thread, one or more nodes that match the first query node; storing, in the first data structure, one or more node identities of the one or more nodes identified by said each thread; selecting, from among the plurality of query nodes, a second query node that is different than the first query node; storing a second data structure that is accessible to a second plurality of threads; for each thread in the second plurality of threads: assigning, to said each thread, a different set of nodes identified in the first data structure; identifying, in the particular graph, one or more neighbor nodes, of each node that is identified in the first data structure and is assigned to said each thread, that match the second query node; storing, in the second data structure, one or more identities of the one or more neighbor nodes identified by said each thread; wherein the method is performed by one or more computing devices.