This section describes the Resource Allocation algorithm in the Neo4j Graph Algorithms library.
Resource Allocation is a measure used to compute the closeness of nodes based on their shared neighbors.
The Resource Allocation algorithm is experimental and not officially supported. 
This section includes:
The Resource Allocation algorithm was introduced in 2009 by Tao Zhou, Linyuan Lü, and YiCheng Zhang as part of a study to predict links in various networks. It is computed using the following formula:
where N(u)
is the set of nodes adjacent to u
.
A value of 0 indicates that two nodes are not close, while higher values indicate nodes are closer.
The library contains a function to calculate closeness between two nodes.
The following will create a sample graph:
MERGE (zhen:Person {name: "Zhen"})
MERGE (praveena:Person {name: "Praveena"})
MERGE (michael:Person {name: "Michael"})
MERGE (arya:Person {name: "Arya"})
MERGE (karin:Person {name: "Karin"})
MERGE (zhen)[:FRIENDS](arya)
MERGE (zhen)[:FRIENDS](praveena)
MERGE (praveena)[:WORKS_WITH](karin)
MERGE (praveena)[:FRIENDS](michael)
MERGE (michael)[:WORKS_WITH](karin)
MERGE (arya)[:FRIENDS](karin)
The following will return the Resource Allocation score for Michael and Karin:
MATCH (p1:Person {name: 'Michael'})
MATCH (p2:Person {name: 'Karin'})
RETURN algo.linkprediction.resourceAllocation(p1, p2) AS score
score 

0.5 
We can also compute the score of a pair of nodes based on a specific relationship type.
The following will return the Resource Allocation score for Michael and Karin based only on the FRIENDS
relationships:
MATCH (p1:Person {name: 'Michael'})
MATCH (p2:Person {name: 'Karin'})
RETURN algo.linkprediction.resourceAllocation(p1, p2, {relationshipQuery: "FRIENDS"}) AS score
score 

0.0 
The following will run the algorithm and return the result:
RETURN algo.linkprediction.resourceAllocation(node1:Node, node2:Node, {
relationshipQuery: null,
direction: "BOTH"
})
Name  Type  Default  Optional  Description 


Node 
null 
no 
A node 

Node 
null 
no 
Another node 

String 
null 
yes 
The relationship type to use to compute similarity between 

String 
BOTH 
yes 
The direction of relationship type to use to compute similarity between 