liveBook · Manning

Adamic-Adar index

As explained in Graph Algorithms for Data Science

The Adamic-Adar index is a link-prediction metric that scores node pairs by weighting common neighbors more highly when they have lower degree.

The Adamic-Adar index predicts future links by giving more weight to common neighbors with lower degree. A common friend with two connections is treated as a stronger signal than one connected to 1,000 people. section 10.3.4

Calculate the score in three steps:

  • Find every common neighbor shared by nodes x and y. section 10.3.4
  • Calculate the degree of each common neighbor. section 10.3.4
  • Sum the inverse logarithm of those degrees; lower-degree neighbors contribute more. section 10.3.4

Social-network intuition

If A and B share C and D, and both common friends have 1,000 friends, their Adamic-Adar score is weaker than when C and D have only two friends each. The same reasoning can describe overlap in a Twitch network. section 10.3.4

Listing 10.6 Calculating the Adamic-Adar index between pairs of nodes in the train and test sets
run_query("""
MATCH (s1:Stream)-[r:TEST_TRAIN|NEGATIVE_TEST_TRAIN]->(s2:Stream)
OPTIONAL MATCH (s1)-[:FEATURE_REL]-(neighbor)-[:FEATURE_REL]-(s2)
WITH r, collect(distinct neighbor) AS commonNeighbors             #1
UNWIND commonNeighbors AS cn
WITH r, count{ (cn)-[:FEATURE_REL]-() } AS neighborDegree         #2
WITH r, sum(1 / log(neighborDegree)) AS adamicAdar                #3
SET r.adamicAdar = adamicAdar;                                    #4
""")

The Cypher implementation finds common neighbors for train and test pairs, counts each neighbor’s degree, sums inverse logarithmic degrees, and stores the result as adamicAdar. section 10.3.4

Pairs with no common neighbors can produce missing adamicAdar values. A dataset may replace those values with the mean Adamic-Adar value, approximately 8.097444 in the demonstrated data. section 10.4.1

How Graph Algorithms for Data Science covers it

How deep it goes
Defines the score, explains its intuition, gives three calculation steps, and demonstrates Cypher implementation without formal derivation.
Examples
Uses social-friend examples, a Twitch overlap network, train/test graph pairs, and missing-value handling.
What you can do after
Apply it via Cypher, impute missing scores, and interpret its importance in a link-prediction classifier.
How it connects
Connects link prediction with common neighbors, node degree, preferential attachment, and network distance.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.