@@ -119,7 +119,7 @@ detectCommunitiesWithLeiden() {
119119# Label of the nodes that will be used for the projection. Example: "Package"
120120# - dependencies_projection_weight_property=...
121121# Name of the node property that contains the dependency weight. Example: "weight"
122- detectCommunitiesWithLouvain () {
122+ detectCommunitiesWithLouvainOld () {
123123 local COMMUNITY_DETECTION_CYPHER_DIR=" ${CYPHER_DIR} /Community_Detection"
124124
125125 # Statistics
@@ -129,15 +129,55 @@ detectCommunitiesWithLouvain() {
129129 # Stream to CSV
130130 local nodeLabel
131131 nodeLabel=$( extractQueryParameter " dependencies_projection_node" " ${@ } " )
132- execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1c_Louvain_Stream .cypher" " ${@ } " > " ${FULL_REPORT_DIRECTORY} /${nodeLabel} _Communities_Louvain.csv"
132+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1d_Louvain_Stream .cypher" " ${@ } " > " ${FULL_REPORT_DIRECTORY} /${nodeLabel} _Communities_Louvain.csv"
133133
134134 # Update Graph (node properties and labels)
135- execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1d_Louvain_Write_louvainCommunityId.cypher" " ${@ } "
136- execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1d_Louvain_Write_intermediateLouvainCommunityId.cypher" " ${@ } "
137- execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1e_Louvain_Label_Delete.cypher" " ${@ } "
138- execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1f_Louvain_Label.cypher" " ${@ } "
135+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1e_Louvain_Write_louvainCommunityId.cypher" " ${@ } "
136+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1e_Louvain_Write_intermediateLouvainCommunityId.cypher" " ${@ } "
137+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1f_Louvain_Label_Delete.cypher" " ${@ } "
138+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1g_Louvain_Label.cypher" " ${@ } "
139+ }
140+
141+ # Community Detection using the Louvain Algorithm
142+ #
143+ # Required Parameters:
144+ # - dependencies_projection=...
145+ # Name prefix for the in-memory projection name for dependencies. Example: "package"
146+ # - dependencies_projection_node=...
147+ # Label of the nodes that will be used for the projection. Example: "Package"
148+ # - dependencies_projection_weight_property=...
149+ # Name of the node property that contains the dependency weight. Example: "weight"
150+ detectCommunitiesWithLouvain () {
151+ local COMMUNITY_DETECTION_CYPHER_DIR=" ${CYPHER_DIR} /Community_Detection"
152+ local PROJECTION_CYPHER_DIR=" ${CYPHER_DIR} /Dependencies_Projection"
153+ local writePropertyName=" dependencies_projection_write_property=louvainCommunityId"
154+ local writePropertyNameIntermediateCommunities=" dependencies_projection_write_property=intermediateLouvainCommunityIds"
155+ local writeLabelName=" dependencies_projection_write_label=LouvainCommunity"
156+ local includeIntermediateCommunities=" dependencies_include_intermediate_communities=true"
157+ local excludeIntermediateCommunities=" dependencies_include_intermediate_communities=false"
158+
159+ # Statistics
160+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1a_Louvain_Estimate.cypher" " ${@ } " " ${writePropertyName} "
161+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1b_Louvain_Statistics.cypher" " ${@ } "
162+
163+ # Run the algorithm and write the result into the in-memory projection ("mutate")
164+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1c_Louvain_Mutate.cypher" " ${@ } " " ${writePropertyName} " " ${excludeIntermediateCommunities} "
165+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1c_Louvain_Mutate.cypher" " ${@ } " " ${writePropertyNameIntermediateCommunities} " " ${includeIntermediateCommunities} "
166+
167+ # Stream to CSV
168+ # TODO based on mutate both properties (communityId, intermediateCommunityId) possible?
169+ local nodeLabel
170+ nodeLabel=$( extractQueryParameter " dependencies_projection_node" " ${@ } " )
171+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_1d_Louvain_Stream.cypher" " ${@ } " > " ${FULL_REPORT_DIRECTORY} /${nodeLabel} _Communities_Louvain.csv"
172+
173+ # Update Graph (node properties and labels) using the already mutated property projection
174+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_9_Write_Mutated.cypher" " ${@ } " " ${writePropertyName} "
175+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_9_Write_Mutated.cypher" " ${@ } " " ${writePropertyNameIntermediateCommunities} "
176+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_10_Delete_Label.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
177+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_11_Add_Label.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
139178}
140179
180+
141181# Community Detection using the Weakly Connected Components Algorithm
142182#
143183# Required Parameters:
@@ -194,7 +234,7 @@ detectCommunitiesWithKCoreDecomposition() {
194234 execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_8_Stream_Mutated.cypher" " ${@ } " " ${writePropertyName} " > " ${FULL_REPORT_DIRECTORY} /${nodeLabel} _Communities_K_Core_Decomposition.csv"
195235
196236 # Update Graph (node properties and labels) using the already mutated property projection
197- execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_9_Write_Mutated.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
237+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_9_Write_Mutated.cypher" " ${@ } " " ${writePropertyName} "
198238 execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_10_Delete_Label.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
199239 execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_11_Add_Label.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
200240}
0 commit comments