Same Community
This feature is not available in GDS Sessions. |
Same Community is a way of determining whether two nodes belong to the same community. These communities could be computed by using one of the Community detection.
This feature is in the alpha tier. For more information on feature tiers, see API Tiers.
History and explanation
If two nodes belong to the same community, there is a greater likelihood that there will be a relationship between them in future, if there isn’t already.
A value of 0 indicates that two nodes are not in the same community. A value of 1 indicates that two nodes are in the same community.
The library contains a function to calculate closeness between two nodes.
Syntax
RETURN gds.alpha.linkprediction.sameCommunity(node1:Node, node2:Node, communityProperty:String)
Name | Type | Default | Optional | Description |
---|---|---|---|---|
|
Node |
null |
no |
A node |
|
Node |
null |
no |
Another node |
|
String |
'community' |
yes |
The property that contains the community to which nodes belong |
Same Community algorithm sample
CREATE (zhen:Person {name: 'Zhen', community: 1}),
(praveena:Person {name: 'Praveena', community: 2}),
(michael:Person {name: 'Michael', community: 1}),
(arya:Person {name: 'Arya', partition: 5}),
(karin:Person {name: 'Karin', partition: 5}),
(jennifer:Person {name: 'Jennifer'})
MATCH (p1:Person {name: 'Michael'})
MATCH (p2:Person {name: 'Zhen'})
RETURN gds.alpha.linkprediction.sameCommunity(p1, p2) AS score
score |
---|
1.0 |
MATCH (p1:Person {name: 'Michael'})
MATCH (p2:Person {name: 'Praveena'})
RETURN gds.alpha.linkprediction.sameCommunity(p1, p2) AS score
score |
---|
0.0 |
If one of the nodes doesn’t have a community, this means it doesn’t belong to the same community as any other node.
MATCH (p1:Person {name: 'Michael'})
MATCH (p2:Person {name: 'Jennifer'})
RETURN gds.alpha.linkprediction.sameCommunity(p1, p2) AS score
score |
---|
0.0 |
By default, the community is read from the community
property, but it is possible to explicitly state which property to read from.
partition
property:MATCH (p1:Person {name: 'Arya'})
MATCH (p2:Person {name: 'Karin'})
RETURN gds.alpha.linkprediction.sameCommunity(p1, p2, 'partition') AS score
score |
---|
1.0 |