Total Neighbors
|
This feature is not available in Aura Graph Analytics. |
Total Neighbors computes the closeness of nodes, based on the number of unique neighbors that they have. It is based on the idea that the more connected a node is, the more likely it is to receive new links.
History and explanation
Total Neighbors is computed using the following formula:
where N(x) is the set of nodes adjacent to x, and N(y) is the set of nodes adjacent to y.
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 the closeness between two nodes.
Syntax
RETURN gds.linkprediction.totalNeighbors(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 used to compute similarity between |
|
String |
BOTH |
yes |
The relationship direction used to compute similarity between |
Total Neighbors algorithm sample
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)
MATCH (p1:Person {name: 'Michael'})
MATCH (p2:Person {name: 'Karin'})
RETURN gds.linkprediction.totalNeighbors(p1, p2) AS score
score |
|---|
4.0 |
We can also compute the score of a pair of nodes, based on a specific relationship type.
FRIENDS relationship:MATCH (p1:Person {name: 'Michael'})
MATCH (p2:Person {name: 'Karin'})
RETURN gds.linkprediction.totalNeighbors(p1, p2, {relationshipQuery: "FRIENDS"}) AS score
score |
|---|
2.0 |