@@ -165,6 +165,40 @@ detectCommunitiesWithWeaklyConnectedComponents() {
165165 execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_3f_WeaklyConnectedComponents_Label.cypher" " ${@ } "
166166}
167167
168+
169+ # Community Detection using the K-Core Decomposition Algorithm
170+ #
171+ # Required Parameters:
172+ # - dependencies_projection=...
173+ # Name prefix for the in-memory projection name for dependencies. Example: "package"
174+ # - dependencies_projection_node=...
175+ # Label of the nodes that will be used for the projection. Example: "Package"
176+ # - dependencies_projection_weight_property=...
177+ # Name of the node property that contains the dependency weight. Example: "weight"
178+ detectCommunitiesWithKCoreDecomposition () {
179+ local COMMUNITY_DETECTION_CYPHER_DIR=" ${CYPHER_DIR} /Community_Detection"
180+ local PROJECTION_CYPHER_DIR=" ${CYPHER_DIR} /Dependencies_Projection"
181+ local writePropertyName=" dependencies_projection_write_property=communityKCoreDecompositionValue"
182+ local writeLabelName=" dependencies_projection_write_label=KCoreDecomposition"
183+
184+ # Statistics
185+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_5a_K_Core_Decomposition_Estimate.cypher" " ${@ } " " ${writePropertyName} "
186+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_5b_K_Core_Decomposition_Statistics.cypher" " ${@ } "
187+
188+ # Run the algorithm and write the result into the in-memory projection ("mutate")
189+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_5c_K_Core_Decomposition_Mutate.cypher" " ${@ } " " ${writePropertyName} "
190+
191+ # Stream to CSV
192+ local nodeLabel
193+ nodeLabel=$( extractQueryParameter " dependencies_projection_node" " ${@ } " )
194+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_8_Stream_Mutated.cypher" " ${@ } " " ${writePropertyName} " > " ${FULL_REPORT_DIRECTORY} /${nodeLabel} _Communities_K_Core_Decomposition.csv"
195+
196+ # 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} "
198+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_10_Delete_Label.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
199+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_11_Add_Label.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
200+ }
201+
168202# ---------------------------------------------------------------
169203
170204# Artifact Query Parameters
@@ -180,6 +214,7 @@ time detectCommunitiesWithLeiden "${ARTIFACT_PROJECTION}" "${ARTIFACT_NODE}" "${
180214time detectCommunitiesWithLouvain " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} "
181215time detectCommunitiesWithWeaklyConnectedComponents " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} "
182216time detectCommunitiesWithLabelPropagation " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} " " ${ARTIFACT_GAMMA} "
217+ time detectCommunitiesWithKCoreDecomposition " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} " " ${ARTIFACT_GAMMA} "
183218
184219# ---------------------------------------------------------------
185220
@@ -196,6 +231,7 @@ time detectCommunitiesWithLeiden "${PACKAGE_PROJECTION}" "${PACKAGE_NODE}" "${PA
196231time detectCommunitiesWithLouvain " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} "
197232time detectCommunitiesWithWeaklyConnectedComponents " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} "
198233time detectCommunitiesWithLabelPropagation " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} " " ${PACKAGE_GAMMA} "
234+ time detectCommunitiesWithKCoreDecomposition " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} " " ${PACKAGE_GAMMA} "
199235
200236# Package Community Detection - Special CSV Queries after update
201237execute_cypher " ${CYPHER_DIR} /Community_Detection/Compare_Community_Detection_Results.cypher" > " ${FULL_REPORT_DIRECTORY} /Compare_Community_Detection_Results.csv"
@@ -216,6 +252,7 @@ time detectCommunitiesWithLeiden "${TYPE_PROJECTION}" "${TYPE_NODE}" "${TYPE_WEI
216252time detectCommunitiesWithLouvain " ${TYPE_PROJECTION} " " ${TYPE_NODE} " " ${TYPE_WEIGHT} "
217253time detectCommunitiesWithWeaklyConnectedComponents " ${TYPE_PROJECTION} " " ${TYPE_NODE} " " ${TYPE_WEIGHT} "
218254time detectCommunitiesWithLabelPropagation " ${TYPE_PROJECTION} " " ${TYPE_NODE} " " ${TYPE_WEIGHT} " " ${TYPE_GAMMA} "
255+ time detectCommunitiesWithKCoreDecomposition " ${TYPE_PROJECTION} " " ${TYPE_NODE} " " ${TYPE_WEIGHT} " " ${TYPE_GAMMA} "
219256
220257# Type Community Detection - Special CSV Queries after update
221258execute_cypher " ${CYPHER_DIR} /Community_Detection/Which_type_community_spans_several_artifacts_and_how_are_the_types_distributed.cypher" > " ${FULL_REPORT_DIRECTORY} /Type_Communities_Leiden_That_Span_Multiple_Artifacts.csv"
0 commit comments