UltipaDocs
Try Playground
  • Introduction
  • Managing HDC Graphs
  • Managing Distributed Projections
  • Installing Algorithms
  • Running Algorithms
    • Degree Centrality
    • Closeness Centrality
    • Harmonic Centrality
    • Graph Centrality
    • Betweenness Centrality
    • Eigenvector Centrality
    • Katz Centrality
    • CELF
    • PageRank
    • ArticleRank
    • TextRank
    • HITS
    • SybilRank
    • Jaccard Similarity
    • Overlap Similarity
    • Cosine Similarity
    • Pearson Correlation Coefficient
    • Euclidean Distance
    • K-Hop All
    • Bipartite Graph
    • HyperANF
    • Connected Component
    • Triangle Counting
    • Induced Subgraph
    • k-Core
    • k-Truss
    • p-Cohesion
    • k-Edge Connected Components
    • Local Clustering Coefficient
    • Topological Sort
    • Schema Overview
    • Dijkstra's Single-Source Shortest Path
    • Delta-Stepping Single-Source Shortest Path
    • Shortest Path Faster Algorithm (SPFA)
    • Minimum Spanning Tree
    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
    • Adamic-Adar Index
    • Common Neighbors
    • Preferential Attachment
    • Resource Allocation
    • Total Neighbors
    • Louvain
    • Leiden
    • Label Propagation
    • HANP
    • k-Means
    • kNN (k-Nearest Neighbors)
    • K-1 Coloring
    • Conductance
      • Random Walk
      • Node2Vec Walk
      • Node2Vec
      • Struc2Vec Walk
      • Struc2Vec
      • LINE
      • Fast Random Projection
      • Summary of Graph Embedding
      • Gradient Descent
      • Backpropagation
      • Skip-gram
      • Skip-gram Optimization
  1. Docs
  2. /
  3. Graph Analytics & Algorithms
  4. /
  5. Topological Link Prediction

Adamic-Adar Index

HDC

Overview

The Adamic-Adar Index (AA Index) is a node similarity metric named after its creators Lada Adamic and Eytan Adar. It measures the strength of potential connection between two nodes based on their common neighbors.

  • L.A. Adamic, E. Adar, Friends and Neighbors on the Web (2003)

The core idea behind the AA Index is that common neighbors with lower degrees contribute more valuable information about the similarity between two nodes than those with higher degrees. The index is calculated using the following formula:

where N(u) is the set of nodes adjacent to u. For each common neighbor u of the two nodes, the AA Index first calculates the reciprocal of the logarithm of its degree |N(u)|, and then sums these values across all common neighbors.

A higher AA Index score indicates greater similarity between the nodes, while a score of 0 indicates no similarity between two nodes.

In this example, N(D) ∩ N(E) = {B, F}, where 1log|N(B)| = 1log4 = 1.6610, 1log|N(F)| = 1log3 = 2.0959, thus AA(D,E) = 1.6610 + 2.0959 = 3.7569.

Considerations

  • The AA Index algorithm treats all edges as undirected, ignoring their original direction.

Example Graph

Run the following statements on an empty graph to define its structure and insert data:

INSERT (A:default {_id: "A"}),
       (B:default {_id: "B"}),
       (C:default {_id: "C"}),
       (D:default {_id: "D"}),
       (E:default {_id: "E"}),
       (F:default {_id: "F"}),
       (G:default {_id: "G"}),
       (A)-[:default]->(B),
       (B)-[:default]->(E),
       (C)-[:default]->(B),
       (C)-[:default]->(D),
       (C)-[:default]->(F),
       (D)-[:default]->(B),
       (D)-[:default]->(E),
       (F)-[:default]->(D),
       (F)-[:default]->(G);

Creating HDC Graph

To load the entire graph to the HDC server hdc-server-1 as my_hdc_graph:

CREATE HDC GRAPH my_hdc_graph ON "hdc-server-1" OPTIONS {
  nodes: {"*": ["*"]},
  edges: {"*": ["*"]},
  direction: "undirected",
  load_id: true,
  update: "static"
}

Parameters

Algorithm name: topological_link_prediction

Name
Type
Spec
Default
Optional
Description
ids[]_id//NoSpecifies the first group of nodes for computation by their _id. If unset, all nodes in the graph are used as the first group of nodes.
uuids[]_uuid//NoSpecifies the first group of nodes for computation by their _uuid. If unset, all nodes in the graph are used as the first group of nodes.
ids2[]_id//NoSpecifies the second group of nodes for computation by their _id. If unset, all nodes in the graph are used as the second group of nodes.
uuids2[]_uuid//NoSpecifies the second group of nodes for computation by their _uuid. If unset, all nodes in the graph are used as the second group of nodes.
typeStringAdamic_AdarAdamic_AdarYesSpecifies the similarity type; for AA Index, keep it as Adamic_Adar.
return_id_uuidStringuuid, id, bothuuidYesIncludes _uuid, _id, or both to represent nodes in the results.
limitInteger≥-1-1YesLimits the number of results returned. Set to -1 to include all results.

File Writeback

CALL algo.topological_link_prediction.write("my_hdc_graph", {
  ids: ["C"],
  ids2: ["A","E","G"],
  return_id_uuid: "id"
}, {
  file: {
    filename: "aa"
  }
})

Result:

File: aa
_id1,_id2,result
C,A,1.66096
C,E,3.32193
C,G,2.0959

Full Return

CALL algo.topological_link_prediction.run("my_hdc_graph", {
  ids: ["C"],
  ids2: ["A","C","E","G"],
  type: "Adamic_Adar",
  return_id_uuid: "id"
}) YIELD aa
RETURN aa

Result:

_id1_id2result
CA1.660964
CE3.321928
CG2.095903

Stream Return

CALL algo.topological_link_prediction.stream("my_hdc_graph", {
  ids: ["C"],
  ids2: ["A", "B", "D", "E", "F", "G"],
  type: "Adamic_Adar",
  return_id_uuid: "id"
}) YIELD aa
FILTER aa.result >= 2
RETURN aa

Result:

_id1_id2result
CD3.756867
CE3.321928
CG2.095903