-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommunity_Detection_9_Community_Metrics.cypher
44 lines (43 loc) · 1.98 KB
/
Community_Detection_9_Community_Metrics.cypher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Community Metrics. Requires "Add_file_name and_extension.cypher".
CALL gds.conductance.stream(
$dependencies_projection + '-cleaned', {
relationshipWeightProperty: $dependencies_projection_weight_property
,communityProperty: $dependencies_projection_write_property
})
YIELD community AS communityId, conductance
WITH collect({communityId: communityId, conductance: conductance}) AS conductances
CALL gds.modularity.stream(
$dependencies_projection + '-cleaned', {
relationshipWeightProperty: $dependencies_projection_weight_property
,communityProperty: $dependencies_projection_write_property
})
YIELD communityId, modularity
WITH conductances
,collect({communityId: communityId, modularity: modularity}) AS modularities
MATCH (member)
WHERE member[$dependencies_projection_write_property] IS NOT NULL
AND $dependencies_projection_node IN LABELS(member)
WITH conductances
,modularities
,member[$dependencies_projection_write_property] AS communityId
,coalesce(member.fqn, member.fileName, member.name) AS memberName
,member.name AS shortMemberName
WITH conductances
,modularities
,communityId
,count(DISTINCT memberName) AS memberCount
,collect(DISTINCT shortMemberName) AS shortMemberNames
,collect(DISTINCT memberName) AS memberNames
,reduce(memberConductance = 0, conductance IN conductances |
CASE conductance.communityId WHEN communityId THEN conductance.conductance
ELSE memberConductance END) AS conductance
,reduce(memberModularity = 0, modularity IN modularities |
CASE modularity.communityId WHEN communityId THEN modularity.modularity
ELSE memberModularity END) AS modularity
RETURN communityId
,conductance
,modularity
,memberCount
,shortMemberNames[0..9] AS someMemberNamesShort
,memberNames[0..9] AS someMemberNames
ORDER BY communityId ASCENDING