66
77# Note that "scripts/prepareAnalysis.sh" is required to run prior to this script.
88
9- # Requires executeQueryFunctions.sh
9+ # Requires executeQueryFunctions.sh, parseCsvFunctions.sh
1010
1111# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
1212set -o errexit -o pipefail
@@ -32,6 +32,9 @@ echo "communityCsv: CYPHER_DIR=${CYPHER_DIR}"
3232# Define functions to execute a cypher query from within the given file (first and only argument)
3333source " ${SCRIPTS_DIR} /executeQueryFunctions.sh"
3434
35+ # Define function(s) (e.g. is_csv_column_greater_zero) to parse CSV format strings from Cypher query results.
36+ source " ${SCRIPTS_DIR} /parseCsvFunctions.sh"
37+
3538# Create report directory
3639REPORT_NAME=" community-csv"
3740FULL_REPORT_DIRECTORY=" ${REPORTS_DIRECTORY} /${REPORT_NAME} "
@@ -50,11 +53,13 @@ mkdir -p "${FULL_REPORT_DIRECTORY}"
5053# Name of the node property that contains the dependency weight. Example: "weight"
5154createProjection () {
5255 local PROJECTION_CYPHER_DIR=" ${CYPHER_DIR} /Dependencies_Projection"
56+ local projectionResult
5357
5458 execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_1_Delete_Projection.cypher" " ${@ } "
5559 execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_2_Delete_Subgraph.cypher" " ${@ } "
5660 execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_4_Create_Undirected_Projection.cypher" " ${@ } "
57- execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_5_Create_Subgraph.cypher" " ${@ } "
61+ projectionResult=$( execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_5_Create_Subgraph.cypher" " ${@ } " )
62+ is_csv_column_greater_zero " ${projectionResult} " " relationshipCount"
5863}
5964
6065# Community Detection Preparation for Types
@@ -66,9 +71,11 @@ createProjection() {
6671# Name prefix for the in-memory projection name for dependencies. Example: "package"
6772createTypeProjection () {
6873 local PROJECTION_CYPHER_DIR=" ${CYPHER_DIR} /Dependencies_Projection"
74+ local projectionResult
6975
7076 execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_2_Delete_Subgraph.cypher" " ${@ } "
71- execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_4c_Create_Undirected_Type_Projection.cypher" " ${@ } "
77+ projectionResult=$( execute_cypher " ${PROJECTION_CYPHER_DIR} /Dependencies_4c_Create_Undirected_Type_Projection.cypher" " ${@ } " )
78+ is_csv_column_greater_zero " ${projectionResult} " " relationshipCount"
7279}
7380
7481# Community Detection using the Louvain Algorithm
@@ -411,10 +418,12 @@ ARTIFACT_KCUT="dependencies_maxkcut=5" # default = 2
411418
412419# Artifact Community Detection
413420echo " communityCsv: $( date +' %Y-%m-%dT%H:%M:%S%z' ) Processing artifact dependencies..."
414- createProjection " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} "
415- detectCommunities " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} " " ${ARTIFACT_GAMMA} " " ${ARTIFACT_KCUT} "
416- writeLeidenModularity " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} "
417-
421+ if createProjection " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} " ; then
422+ detectCommunities " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} " " ${ARTIFACT_GAMMA} " " ${ARTIFACT_KCUT} "
423+ writeLeidenModularity " ${ARTIFACT_PROJECTION} " " ${ARTIFACT_NODE} " " ${ARTIFACT_WEIGHT} "
424+ else
425+ echo " communityCsv: No data. Artifact analysis skipped."
426+ fi
418427# ---------------------------------------------------------------
419428
420429# Package Query Parameters
@@ -426,13 +435,15 @@ PACKAGE_KCUT="dependencies_maxkcut=20" # default = 2
426435
427436# Package Community Detection
428437echo " communityCsv: $( date +' %Y-%m-%dT%H:%M:%S%z' ) : Processing package dependencies..."
429- createProjection " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} "
430- detectCommunities " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} " " ${PACKAGE_GAMMA} " " ${PACKAGE_KCUT} "
431- writeLeidenModularity " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} "
432-
433- # Package Community Detection - Special CSV Queries after update
434- execute_cypher " ${CYPHER_DIR} /Community_Detection/Which_package_community_spans_several_artifacts_and_how_are_the_packages_distributed.cypher" > " ${FULL_REPORT_DIRECTORY} /Package_Communities_Leiden_That_Span_Multiple_Artifacts.csv"
435-
438+ if createProjection " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} " ; then
439+ detectCommunities " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} " " ${PACKAGE_GAMMA} " " ${PACKAGE_KCUT} "
440+ writeLeidenModularity " ${PACKAGE_PROJECTION} " " ${PACKAGE_NODE} " " ${PACKAGE_WEIGHT} "
441+
442+ # Package Community Detection - Special CSV Queries after update
443+ execute_cypher " ${CYPHER_DIR} /Community_Detection/Which_package_community_spans_several_artifacts_and_how_are_the_packages_distributed.cypher" > " ${FULL_REPORT_DIRECTORY} /Package_Communities_Leiden_That_Span_Multiple_Artifacts.csv"
444+ else
445+ echo " communityCsv: No data. Package analysis skipped."
446+ fi
436447# ---------------------------------------------------------------
437448
438449# Type Query Parameters
@@ -444,12 +455,16 @@ TYPE_KCUT="dependencies_maxkcut=100" # default = 2
444455
445456# Type Community Detection
446457echo " communityCsv: $( date +' %Y-%m-%dT%H:%M:%S%z' ) Processing type dependencies..."
447- createTypeProjection " ${TYPE_PROJECTION} "
448- detectCommunities " ${TYPE_PROJECTION} " " ${TYPE_NODE} " " ${TYPE_WEIGHT} " " ${TYPE_GAMMA} " " ${TYPE_KCUT} "
449-
450- # Type Community Detection - Special CSV Queries after update
451- execute_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"
452- execute_cypher " ${CYPHER_DIR} /Community_Detection/Type_communities_with_few_members_in_foreign_packages.cypher" > " ${FULL_REPORT_DIRECTORY} /Type_communities_with_few_members_in_foreign_packages.csv"
453- execute_cypher " ${CYPHER_DIR} /Community_Detection/Type_communities_that_span_the_most_packages_with_type_statistics.cypher" > " ${FULL_REPORT_DIRECTORY} /Type_communities_that_span_the_most_packages_with_type_statistics.csv"
458+ if createTypeProjection " ${TYPE_PROJECTION} " ; then
459+ detectCommunities " ${TYPE_PROJECTION} " " ${TYPE_NODE} " " ${TYPE_WEIGHT} " " ${TYPE_GAMMA} " " ${TYPE_KCUT} "
460+
461+ # Type Community Detection - Special CSV Queries after update
462+ execute_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"
463+ execute_cypher " ${CYPHER_DIR} /Community_Detection/Type_communities_with_few_members_in_foreign_packages.cypher" > " ${FULL_REPORT_DIRECTORY} /Type_communities_with_few_members_in_foreign_packages.csv"
464+ execute_cypher " ${CYPHER_DIR} /Community_Detection/Type_communities_that_span_the_most_packages_with_type_statistics.cypher" > " ${FULL_REPORT_DIRECTORY} /Type_communities_that_span_the_most_packages_with_type_statistics.csv"
465+ else
466+ echo " communityCsv: No data. Type analysis skipped."
467+ fi
468+ # ---------------------------------------------------------------
454469
455- echo " communityCsv: $( date +' %Y-%m-%dT%H:%M:%S%z' ) Successfully finished"
470+ echo " communityCsv: $( date +' %Y-%m-%dT%H:%M:%S%z' ) Successfully finished. "
0 commit comments