Guest
Sign in to keep your graphs and progress.
Select an algorithm and generate steps to begin visualization
Which friendships are about to form?
Scores every unlinked pair by its neighbourhoods: common neighbours, Jaccard, Adamic–Adar, resource allocation and preferential attachment
Select an algorithm and generate steps to begin visualization
Link prediction estimates which pairs of vertices that are not linked yet are likely to become linked. The classic scores look at the neighbourhoods of the pair: common neighbours counts the friends they share, Jaccard divides that by all their friends, Adamic–Adar adds 1 / ln k for each shared friend of degree k, resource allocation adds 1 / k, and preferential attachment multiplies the two degrees. Liben-Nowell and Kleinberg compared these scores on co-authorship networks in 2007 and found that the simple neighbourhood scores, Adamic–Adar above all, predict new links far better than chance.
The visualizer lists every pair of vertices without an edge and how many share at least one neighbour, then scores the best pairs one by one. The pair is drawn large, its common neighbours green with the paths through them, and every vertex shows its degree as a badge, because the scores weigh the shared friends by how many links they have. A shared friend who knows few people says much more than one who knows everybody. In the example X and Y share two quiet friends and score 2.89, while A and B share three friends including the hub H of degree 6 and score only 2.38. Preferential attachment, which ignores shared friends, favours the hub pair H and X. At the end the three best pairs by Adamic–Adar are drawn as dashed predicted links.
Link prediction is behind "people you may know" in social networks, product and content recommendations, and the search for missing links in incomplete data: protein interactions not yet tested, possible drug targets, collaborators who have not met. In knowledge graphs it fills in missing facts. Neo4j Graph Data Science offers the neighbourhood scores as functions and full link prediction pipelines that feed them, with node embeddings, into a classifier. To judge any score, hide a share of the known links and check how high the hidden ones rank. Graph neural networks learn such scores instead of fixing them by hand.
Five neighbourhood scores for every pair that is not linked.
LinkPrediction(G):
for each pair a, b that is not linked:
Z = common neighbours of a and b
CN = |Z|, Jaccard = |Z| / |Γ(a) ∪ Γ(b)|
AA = sum of 1 / ln k(z) over z in Z
RA = sum of 1 / k(z) over z in Z
PA = k(a) * k(b)
rank the pairs by AA
return the top pairs as predicted linksk(z) is the degree of z and Γ(a) the neighbours of a. A common neighbour always has degree at least 2, so ln k(z) is never 0. Adamic–Adar and resource allocation give a rare common friend more weight than a busy one, while preferential attachment ignores common friends entirely.
A small social network with a hub, loaded on this page.
Example graph: H knows A, B, C, D, E and F. A and B both know C and D. E knows X. X and Y both know M and N. 11 vertices, 15 edges.
Predicted links by Adamic–Adar: X – Y (2.89), A – B (2.38) and C – D (2.38). Common neighbours and Jaccard would rank A – B first, so the choice of score matters.
Time: O(Σ deg(z)²) for the pairs at distance 2 · Space: O(n + m + candidates)
Every local score except preferential attachment is 0 unless the pair shares a neighbour, so only pairs at distance 2 need scoring. They are generated by taking, for each vertex z, every pair of its neighbours, which costs the sum of the squared degrees. Scoring all n² pairs, as this page does to count them, is only feasible on small graphs.
Beyond the local neighbourhood scores.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Katz index or personalised PageRank | Links between vertices more than two steps apart should be predicted too. They count longer walks, damped by their length. | O(m) per source and iteration |
| Embeddings and a classifier | There is labelled history to learn from. Node embeddings and the scores on this page become features of a model trained on past links. | training plus O(d) per pair |
| Graph neural networks (SEAL and others) | Large training data and the need for the best accuracy. The network learns its own score from the subgraph round each pair. | GPU training |
Related algorithms: Node Similarity (Jaccard), Clustering Coefficient, Katz Centrality, Louvain Community Detection, Leiden Community Detection
Built by Mohammed Islam Hadjoudj · Work with me