UltipaDocs
Try Playground
  • Introduction
    • Show Algorithms
    • Install and Uninstall
    • Run Algorithms
    • Algorithm Results and Statistics
    • Degree Centrality
    • Closeness Centrality
    • Harmonic Centrality
    • Graph Centrality
    • Betweenness Centrality
    • Eigenvector Centrality
    • CELF
    • PageRank
    • ArticleRank
    • 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
      • GraphSAGE
      • GraphSAGE Train
      • 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

Preferential Attachment

✓ File Writeback ✕ Property Writeback ✓ Direct Return ✓ Stream Return ✕ Stats

Overview

Preferential attachment is a common phenomenon in complex network where nodes with more connections are more likely to establish new connections. When both nodes possess a large number of connections, the probability of them forming a connection is significantly higher. This phenomenon was utilized by A. Barabási and R. Albert in their proposed BA model for generating random scale-free networks in 2002:

  • R. Albert, A. Barabási, Statistical mechanics of complex networks (2001)

The Preferential Attachment algorithm gauges the similarity between two nodes by calculating the product of the number of neighbors each node has. It is computed using the following formula:

where N(x) and N(y) are the sets of adjacent nodes to nodes x and y respectively.

Higher Preferential Attachment scores indicate greater similarity between nodes, while a score of 0 indicates no similarity between two nodes.

In this example, PA(D,E) = |N(D)| * |N(E)| = |{B, C, E, F}| * |{B, D, F}| = 4 * 3 = 12.

Considerations

  • The Preferential Attachment algorithm ignores the direction of edges but calculates them as undirected edges.

Syntax

  • Command: algo(topological_link_prediction)
  • Parameters:
Name
Type
Spec
Default
Optional
Description
ids / uuids[]_id / []_uuid//NoID/UUID of the first set of nodes to calculate; each node in ids/uuids will be paired with each node in ids2/uuids2
ids2 / uuids2[]_id / []_uuid//NoID/UUID of the second set of nodes to calculate; each node in ids/uuids will be paired with each node in ids2/uuids2
typestringPreferential_AttachmentAdamic_AdarNoType of similarity; for Preferential Attachment, keep it as Preferential_Attachment
limitint>=-1-1YesNumber of results to return, -1 to return all results

Example

The example graph is as follows:

File Writeback

SpecContent
filenamenode1,node2,num
UQL
algo(topological_link_prediction).params({
  uuids: [3],
  uuids2: [1,5,7],
  type: 'Preferential_Attachment'
}).write({
  file:{ 
    filename: 'pa'
  }
})

Results: File pa

File
C,A,3.000000
C,E,6.000000
C,G,3.000000

Direct Return

Alias OrdinalType
Description
Columns
0[]perNodePairNode pair and its similaritynode1, node2, num
UQL
algo(topological_link_prediction).params({
  ids: 'C',
  ids2: ['A','C','E','G'],
  type: 'Preferential_Attachment'
}) as pa 
return pa 

Results: pa

node1node2num
313
356
373

Stream Return

Alias OrdinalType
Description
Columns
0[]perNodePairNode pair and its similaritynode1, node2, num
UQL
find().nodes() as n
with collect(n._id) as nID
algo(topological_link_prediction).params({
  ids: 'C',
  ids2: nID,
  type: 'Preferential_Attachment'
}).stream() as pa
where pa.num >= 2
return pa

Results: pa

node1node2num
3212
3412
356
369