# Change Nickname

Current Nickname:

Apply New License

License Detail

Please complete this required field.

• Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

The MAC address of the server you want to deploy.

Please complete this required field.

Please complete this required field.

Cancel
Apply
 ID Product Status Cores Applied Validity Period(days) Effective Date Excpired Date Mac Address Apply Comment Review Comment
Close
Profile
• Full Name:
• Phone:
• Company:
• Company Email:
• Country:
• Language:
Change Password
Apply

You have no license application record.

Apply
Certificate Issued at Valid until Serial No. File
Serial No. Valid until

Not having one? Apply now! >>>

Product Created On ID Amount (USD) Invoice
Product Created On ID Amount (USD) Invoice

No Invoice

# 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:

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) = $\frac{1}{\mathrm{|N\left(B\right)|}}$ + $\frac{1}{\mathrm{|N\left(F\right)|}}$ = $\frac{1}{4}$ + $\frac{1}{3}$ = 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` / / No ID/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` / / No ID/UUID of the second set of nodes to calculate; each node in `ids`/`uuids` will be paired with each node in `ids2`/`uuids2`
type string `Resource_Allocation` `Adamic_Adar` No Type of similarity; for Resource Allocation, keep it as `Resource_Allocation`
limit int >=-1 `-1` Yes Number of results to return, `-1` to return all results

## Example

The example graph is as follows:

### File Writeback

Spec Content
filename `node1`,`node2`,`num`
``````algo(topological_link_prediction).params({
uuids: [3],
uuids2: [1,5,7],
type: 'Resource_Allocation'
}).write({
file:{
filename: 'ra'
}
})
``````

Results: File ra

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

### Direct Return

Alias Ordinal Type
Description
Columns
0 []perNodePair Node pair and its similarity `node1`, `node2`, `num`
``````algo(topological_link_prediction).params({
ids: 'C',
ids2: ['A','C','E','G'],
type: 'Resource_Allocation'
}) as ra
return ra
``````

Results: ra

node1 node2 num
3 1 0.25
3 5 0.5
3 7 0.333333333333333

### Stream Return

Alias Ordinal Type
Description
Columns
0 []perNodePair Node pair and its similarity `node1`, `node2`, `num`
``````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

node1 node2 num
3 4 0.583333333333333
3 5 0.5
3 7 0.333333333333333
Please complete the following information to download this book