Link Graph Encyclopedia

Computing at scale

Node orderings

Renumbering a graph's nodes changes nothing about its structure and everything about its cost. Good orders shrink compressed graphs, speed up PageRank through cache locality and balance parallel work.

A graph’s nodes need integer ids, and any permutation of the ids describes the same graph. Rankings do not care which permutation you pick, apart from how ties are broken. Computers care a great deal. Compression depends on the gaps between consecutive successor ids, and a PageRank pass depends on whether the scores it reads sit near each other in memory. Choosing the order is often the cheapest large speed-up available.

Why order matters

Name order

The first good order for web graphs was free: sort pages by URL, with host names reversed so that pages of the same host, and hosts of the same domain, sit together (see reversed domain names). Most links on the web are internal to a site, so most links connect nodes with nearby ids. Common Crawl numbers its domain graph’s vertices in reversed-name order.

At the domain level the trick loses most of its force. The links that name order makes local, links within a site, are gone; what remains are links between unrelated domains. Common Crawl’s 2026 domain graph records an average distance of about 19.8 million ids between a node and its successors, and an average log₂ gap between consecutive successors of 10.8, which is why it costs 15 bits per link where page graphs cost 2 or 3.

Orders built from structure

When names carry no locality, as in social networks, or too little, as in domain graphs, the order must come from the links themselves:

Costs and trade-offs

Computing a good order costs a few passes over the graph, sometimes many more for LLP, but it is done once and amortised over every later use. Reordering is a permutation: the graph must be rewritten with new ids, and every id-indexed side file (names, ranks, labels) must be permuted to match. Different goals favour different orders. The best order for compression is not always the best for parallel PageRank, and an order tuned for one graph’s structure ages as the graph changes.

Orders and ties

Rankings are invariant under renumbering except for ties. Common Crawl sorts its ranks file by score with a stable sort, so domains with equal scores appear in vertex-id order, which is reversed-name order. Harmonic centrality has only 5.9 million distinct values across 119.7 million domains, so ties are common, and their order is alphabetical by reversed name. Renumber the graph and the tied positions change while the scores do not (see ranks and scores).

A rule of thumb

If a graph algorithm is slow, check the order before optimising the code. A random or crawl-order numbering can make the same PageRank computation several times slower than a locality-preserving one, and make the compressed graph twice as large or more. The fix needs no change to the algorithm at all.

References

Edit this entry on GitHub