Link Graph Encyclopedia

Foundations

Paths, distance and reachability

How many clicks separate two sites, and whether one can reach the other at all. Breadth-first search answers both, and geometric centralities are built on the answer.

A path from uu to vv is a sequence of arcs that starts at uu, follows links, and ends at vv. The distance d(u,v)d(u, v) is the length of the shortest such path, counted in arcs. On the web it is the minimum number of clicks a reader needs to get from one site to another. If no path exists, vv is unreachable from uu and d(u,v)=∞d(u, v) = \infty.

Distances matter because a family of rankings, the geometric centralities, score a node by how close the rest of the graph is to it: closeness centrality and harmonic centrality. Betweenness centrality also rests on shortest paths, counting how many of them pass through a node.

Distance is not symmetric

In a directed graph d(u,v)d(u, v) and d(v,u)d(v, u) can differ, and one can be infinite while the other is not. In the running example, d(E,G)=2d(\text{E}, \text{G}) = 2 through C, but d(G,E)=∞d(\text{G}, \text{E}) = \infty: G links nowhere and nothing links to E.

Here is every distance in the running example. Row uu, column vv gives d(u,v)d(u, v); a dash means unreachable.

from \ to A B C D E F G
A 0 1 1 – – – 2
B 2 0 1 – – – 2
C 1 2 0 – – – 1
D 1 2 1 0 – – 2
E 2 3 1 1 0 1 2
F – – – – – 0 –
G – – – – – – 0

Most of the table is dashes. Unreachable pairs are the norm in web graphs, not an edge case, and any measure built on distance must decide what to do with them. Closeness centrality handles them badly and harmonic centrality handles them well, which is the main reason the second replaced the first.

Reachability

The set of nodes reachable from uu is its forward ball of infinite radius; the set of nodes that can reach uu is its backward ball. Reachability decomposes a graph into strongly connected components: groups in which every node reaches every other. On the web those components arrange themselves into the bow tie shape.

In the running example, E reaches everything, while F and G reach only themselves. Column C is full except for F and G: every node that links anywhere eventually reaches C.

Breadth-first search (BFS) computes all distances from one source in time proportional to the number of arcs it touches:

dist[s] = 0; queue = [s]
while queue not empty:
    u = queue.pop_front()
    for v in successors(u):
        if dist[v] is unset:
            dist[v] = dist[u] + 1
            queue.push_back(v)

BFS visits nodes in order of distance, so the first time it reaches vv it has found a shortest path. Each arc is examined once, so one BFS costs O(n+m)O(n + m). Running BFS on the transposed graph (see adjacency) gives the distances to ss from everywhere, which is what in-link-based centralities need.

All-pairs distances are out of reach

A geometric centrality needs the distances between all pairs, which naively means one BFS per node: O(n(n+m))O(n(n + m)). For Common Crawl’s domain graph, with n≈1.2×108n \approx 1.2 \times 10^8 and m≈2.5×109m \approx 2.5 \times 10^9, that is about 3×10173 \times 10^{17} arc visits. At a billion visits per second it would take nearly ten years.

Two ideas make geometric centralities feasible at that scale anyway:

Diameter and typical distance

The diameter is the largest finite distance between any two nodes. It is a fragile statistic: one long chain of pages sets it. Network scientists prefer the distance distribution, the fraction of reachable pairs at each distance, and the effective diameter, the distance within which 90% of reachable pairs lie. Web graphs and social networks have small typical distances, the small-world property, and the neighbourhood function entry shows how to measure the whole distribution at scale. On Facebook’s 2011 friendship graph, 721 million users were on average 4.74 friendships apart, a figure computed with HyperANF.

Weighted distance

When arcs carry lengths, BFS gives way to Dijkstra’s algorithm, which costs O(m+nlog⁡n)O(m + n \log n) with a good priority queue. Link graphs rarely use weighted distances; the meaningful weights on links, such as how much importance they transfer, enter through random walks instead.

References

Edit this entry on GitHub