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

Resource Allocation

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

Overview

The Resource Allocation algorithm operates under the assumption that nodes transmit resources to each other through their shared neighbors, who act as transmitters. In its basic form, we consider each transmitter possessing a single unit of resource, which is evenly distributed among its neighbors. Consequently, the similarity between two nodes can be gauged by the magnitude of resources that one node transmits to the other. This concept was introduced by Tao Zhou, Linyuan Lü, and Yi-Cheng Zhang in 2009:

  • T. Zhou, L. Lü, Y. Zhang, Predicting Missing Links via Local Information (2009)

It is computed 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 Resource Allocation first calculates the reciprocal of its degree |N(u)|, then sums up these reciprocal values for all common neighbors.

When calculating the degree for nodes in the graphset:

  • edges connecting two same nodes will be counted only once;
  • self-loop will be ignored.

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

In this example, N(D) ∩ N(E) = {B, F}, RA(D,E) = 1|N(B)| + 1|N(F)| = 14 + 13 = 0.5833.

Considerations

  • The Resource Allocation 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
typestringResource_AllocationAdamic_AdarNoType of similarity; for Resource Allocation, keep it as Resource_Allocation
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: 'Resource_Allocation'
}).write({
  file:{ 
    filename: 'ra'
  }
})

Results: File ra

File
C,A,0.250000
C,E,0.500000
C,G,0.333333

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: 'Resource_Allocation'
}) as ra 
return ra 

Results: ra

node1node2num
310.25
350.5
370.333333333333333

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: 'Resource_Allocation'
}).stream() as ra
where ra.num >= 0.3
return ra

Results: ra

node1node2num
340.583333333333333
350.5
370.333333333333333