@@ -322,6 +322,41 @@ calculateCommunityMetrics() {
322322 # gds.modularity.stream ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 100
323323}
324324
325+ # Calculates the Local Clustering Coefficient for each node in the projected graph.
326+ # It describes the likelihood that the neighbors of a node are also connected.
327+ #
328+ # Required Parameters:
329+ # - dependencies_projection=...
330+ # Name prefix for the in-memory projection name for dependencies. Example: "package"
331+ # - dependencies_projection_node=...
332+ # Label of the nodes that will be used for the projection. Example: "Package"
333+ # - dependencies_projection_weight_property=...
334+ # Name of the node property that contains the dependency weight. Example: "weight"
335+ calculateLocalClusteringCoefficient () {
336+ local COMMUNITY_DETECTION_CYPHER_DIR=" ${CYPHER_DIR} /Community_Detection"
337+ local PROJECTION_CYPHER_DIR=" ${CYPHER_DIR} /Dependencies_Projection"
338+
339+ local writePropertyName=" dependencies_projection_write_property=communityLocalClusteringCoefficient"
340+ local writeLabelName=" dependencies_projection_write_label=MaximumKCut"
341+
342+ # Statistics
343+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_10a_LocalClusteringCoefficient_Estimate.cypher" " ${@ } " " ${writePropertyName} "
344+
345+ # Run the algorithm and write the result into the in-memory projection ("mutate")
346+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_10c_LocalClusteringCoefficient_Mutate.cypher" " ${@ } " " ${writePropertyName} "
347+
348+ # Stream to CSV
349+ local nodeLabel
350+ nodeLabel=$( extractQueryParameter " dependencies_projection_node" " ${@ } " )
351+ execute_cypher " ${COMMUNITY_DETECTION_CYPHER_DIR} /Community_Detection_10d_LocalClusteringCoefficient_Stream_Aggregated.cypher" " ${@ } " " ${writePropertyName} " > " ${FULL_REPORT_DIRECTORY} /${nodeLabel} _Communities_Local_Clustering_Coefficient_Aggregated.csv"
352+ # execute_cypher "${PROJECTION_CYPHER_DIR}/Community_Detection_10d_LocalClusteringCoefficient_Stream.cypher" "${@}" > "${FULL_REPORT_DIRECTORY}/${nodeLabel}_Communities_Local_Clustering_Coefficient.csv"
353+
354+ # Update Graph (node properties and labels) using the already mutated property projection
355+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_9_Write_Mutated.cypher" " ${@ } " " ${writePropertyName} "
356+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_10_Delete_Label.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
357+ execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_11_Add_Label.cypher" " ${@ } " " ${writePropertyName} " " ${writeLabelName} "
358+ }
359+
325360# Write modularity for Leiden communities
326361#
327362# Required Parameters:
@@ -366,6 +401,7 @@ detectCommunities() {
366401 time detectCommunitiesWithLeiden " ${@ } "
367402 time detectCommunitiesWithKCoreDecomposition " ${@ } "
368403 time detectCommunitiesWithApproximateMaximumKCut " ${@ } "
404+ time calculateLocalClusteringCoefficient " ${@ } "
369405 compareCommunityDetectionResults " ${@ } "
370406 listAllResults " ${@ } "
371407}
0 commit comments