[フレーム]
Docs
Neo4j DBMS
Neo4j Aura
Neo4j Tools
Neo4j Graph Data Science
Cypher Query Language
Generative AI
Create applications
Connect data sources
Labs
GenAI Ecosystem
Developer Tools
Frameworks & Integrations
RDF & Linked Data
Get Help
Community Forum
Discord Chat
Product Support
Neo4j Developer Blog
Neo4j Videos
GraphAcademy
Beginners Courses
Data Scientist Courses
Generative AI Courses
Neo4j Certification
Get Started Free
Search
Skip to content
Raise an issue

Resource Allocation

This feature is not available as a Cypher procedure or function in Aura Graph Analytics.

Resource Allocation is a measure used to compute the closeness of nodes based on their shared neighbors.

This feature is in the alpha tier. For more information on feature tiers, see API Tiers.

History and explanation

The Resource Allocation algorithm was introduced in 2009 by Tao Zhou, Linyuan Lü, and Yi-Cheng Zhang as part of a study to predict links in various networks. It is computed using the following formula:

resource allocation

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.

Syntax

The following will run the algorithm and return the result:
RETURN gds.alpha.linkprediction.resourceAllocation(node1:Node, node2:Node, {
 relationshipQuery:String,
 direction:String
})
Table 1. Parameters
Name Type Default Optional Description

node1

Node

null

no

A node

node2

Node

null

no

Another node

relationshipQuery

String

null

yes

The relationship type to use to compute similarity between node1 and node2

direction

String

BOTH

yes

The relationship direction used to compute similarity between node1 and node2. Possible values are OUTGOING, INCOMING and BOTH.

Resource Allocation algorithm sample

The following will create a sample graph:
CREATE
 (zhen:Person {name: 'Zhen'}),
 (praveena:Person {name: 'Praveena'}),
 (michael:Person {name: 'Michael'}),
 (arya:Person {name: 'Arya'}),
 (karin:Person {name: 'Karin'}),
 (zhen)-[:FRIENDS]->(arya),
 (zhen)-[:FRIENDS]->(praveena),
 (praveena)-[:WORKS_WITH]->(karin),
 (praveena)-[:FRIENDS]->(michael),
 (michael)-[:WORKS_WITH]->(karin),
 (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 gds.alpha.linkprediction.resourceAllocation(p1, p2) AS score
Table 2. Results
score

0.3333333333333333

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 gds.alpha.linkprediction.resourceAllocation(p1, p2, {relationshipQuery: "FRIENDS"}) AS score
Table 3. Results
score

0.0

AltStyle によって変換されたページ (->オリジナル) /