Skip to content

Commit f2c4adb

Browse files
authored
Merge pull request #461 from JohT/fix/execute-anomaly-graph-visualization-only-once
Fix anomaly Graph visualization executed twice and add DEPENDS_ON schema output
2 parents 55240e2 + c001aa2 commit f2c4adb

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Explore node labels and their relationships for a schema overview
2+
3+
MATCH (allNodes)
4+
WITH COUNT(allNodes) AS totalNodeCount
5+
MATCH (source)-[link]->(target)
6+
WITH totalNodeCount
7+
,labels(source) AS sourceLabels
8+
,labels(target) AS targetLabels
9+
,collect(DISTINCT type(link)) AS relationshipTypes
10+
,count(*) AS numberOfNodes
11+
UNWIND sourceLabels AS sourceLabel
12+
WITH *
13+
WHERE NOT sourceLabel STARTS WITH 'Mark4'
14+
WITH totalNodeCount
15+
,collect(DISTINCT sourceLabel) AS sourceLabels
16+
,targetLabels
17+
,relationshipTypes
18+
,numberOfNodes
19+
UNWIND targetLabels AS targetLabel
20+
WITH *
21+
WHERE NOT targetLabel STARTS WITH 'Mark4'
22+
WITH totalNodeCount
23+
,sourceLabels
24+
,collect(DISTINCT targetLabel) AS targetLabels
25+
,relationshipTypes
26+
,numberOfNodes
27+
RETURN apoc.text.join(sourceLabels, ',') AS sourceLabels
28+
,apoc.text.join(relationshipTypes, ',') AS relationshipTypes
29+
,apoc.text.join(targetLabels, ',') AS targetLabels
30+
,numberOfNodes
31+
,round(toFloat(numberOfNodes) / totalNodeCount * 100.0, 2) AS percentageOfTotalNodes
32+
ORDER BY numberOfNodes DESC
33+
LIMIT 200
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Explore DEPENDS_ON relationship node labels
2+
3+
MATCH (allNodes)
4+
WITH COUNT(allNodes) AS totalNodeCount
5+
MATCH (source)-[:DEPENDS_ON]->(target)
6+
WITH totalNodeCount
7+
,labels(source) AS sourceLabels
8+
,labels(target) AS targetLabels
9+
,count(*) AS numberOfNodes
10+
UNWIND sourceLabels AS sourceLabel
11+
WITH *
12+
WHERE NOT sourceLabel STARTS WITH 'Mark4'
13+
WITH totalNodeCount
14+
,collect(DISTINCT sourceLabel) AS sourceLabels
15+
,targetLabels
16+
,numberOfNodes
17+
UNWIND targetLabels AS targetLabel
18+
WITH *
19+
WHERE NOT targetLabel STARTS WITH 'Mark4'
20+
WITH totalNodeCount
21+
,sourceLabels
22+
,collect(DISTINCT targetLabel) AS targetLabels
23+
,numberOfNodes
24+
RETURN apoc.text.join(sourceLabels, ',') AS sourceLabels
25+
,apoc.text.join(targetLabels, ',') AS targetLabels
26+
,numberOfNodes
27+
,round(toFloat(numberOfNodes) / totalNodeCount * 100.0, 2) AS percentageOfTotalNodes
28+
ORDER BY numberOfNodes DESC, sourceLabels, targetLabels

domains/anomaly-detection/anomalyDetectionVisualization.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ ANOMALY_DETECTION_SCRIPT_DIR=${ANOMALY_DETECTION_SCRIPT_DIR:-$(CDPATH=. cd -- "$
2424
ANOMALY_DETECTION_GRAPHS_DIR=${ANOMALY_DETECTION_GRAPHS_DIR:-"${ANOMALY_DETECTION_SCRIPT_DIR}/graphs"} # Contains everything (scripts, queries, templates) to create the Markdown summary report for anomaly detection
2525

2626
# Delegate the execution to the responsible script.
27-
source "${ANOMALY_DETECTION_GRAPHS_DIR}/anomalyDetectionGraphVisualization.sh"
27+
source "${ANOMALY_DETECTION_GRAPHS_DIR}/anomalyDetectionGraphs.sh"

scripts/reports/OverviewCsv.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ execute_cypher "${OVERVIEW_CYPHER_DIR}/Number_of_elements_per_module_for_Typescr
5353
execute_cypher "${OVERVIEW_CYPHER_DIR}/Node_label_count.cypher" > "${FULL_REPORT_DIRECTORY}/Node_label_count.csv"
5454
execute_cypher "${OVERVIEW_CYPHER_DIR}/Node_label_combination_count.cypher" > "${FULL_REPORT_DIRECTORY}/Node_label_combination_count.csv"
5555
execute_cypher "${OVERVIEW_CYPHER_DIR}/Relationship_type_count.cypher" > "${FULL_REPORT_DIRECTORY}/Relationship_type_count.csv"
56+
execute_cypher "${OVERVIEW_CYPHER_DIR}/Dependency_node_labels.cypher" > "${FULL_REPORT_DIRECTORY}/Dependency_node_labels.csv"
5657

5758
# TODO Performance needs improvement. Included (limited) in OverviewGeneral Jupyter Notebook.
5859
# execute_cypher "${OVERVIEW_CYPHER_DIR}/Node_labels_and_their_relationships.cypher" > "${FULL_REPORT_DIRECTORY}/Node_labels_and_their_relationships.csv"

0 commit comments

Comments
 (0)