Skip to content

Commit 8486b5c

Browse files
committed
Add dependencyDegree/Weighted/Rank to code unit nodes
1 parent d45913c commit 8486b5c

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Set "dependencyDegree" and "dependencyDegreeWeighted" on all nodes containing a property for incoming or outgoing dependencies. Requires all "Set_Incoming*.cypher" and "Set_Outgoing*.cypher".
2+
3+
MATCH (dependency)
4+
WHERE (dependency.incomingDependencies IS NOT NULL OR dependency.outgoingDependencies IS NOT NULL)
5+
WITH dependency
6+
,coalesce(dependency.incomingDependencies, 0) AS inDegree
7+
,coalesce(dependency.outgoingDependencies, 0) AS outDegree
8+
,coalesce(dependency.incomingDependenciesWeight, 0) AS inDegreeWeighted
9+
,coalesce(dependency.outgoingDependenciesWeight, 0) AS outDegreeWeighted
10+
SET dependency.dependencyDegree = inDegree + outDegree
11+
,dependency.dependencyDegreeWeighted = inDegreeWeighted + outDegreeWeighted
12+
RETURN count(*) AS writtenNodes
13+
,max(dependency.dependencyDegree) AS maxDependencyDegree
14+
,max(dependency.dependencyDegreeWeighted) AS maxDependencyDegreeWeighted
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Set "dependencyDegreeRank" on all nodes containing a "dependencyDegree" property. Requires "Set_Degree.cypher".
2+
3+
MATCH (dependency)
4+
WHERE dependency.dependencyDegree IS NOT NULL
5+
WITH dependency.dependencyDegree AS degree, collect(dependency) AS group
6+
ORDER BY degree DESC
7+
WITH collect({degree: degree, nodes: group}) AS groups
8+
UNWIND range(0, size(groups) - 1) AS rowIndex
9+
WITH rowIndex
10+
,groups[rowIndex] AS group
11+
UNWIND group.nodes AS dependency
12+
SET dependency.dependencyDegreeRank = rowIndex + 1
13+
RETURN count(*) AS writtenNodes
14+
,max(dependency.dependencyDegreeRank) AS maxDependencyDegreeRank

domains/anomaly-detection/labels/AnomalyDetectionTopAnomalies.cypher

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ OPTIONAL MATCH (projectRoot:Directory)<-[:HAS_ROOT]-(proj:TS:Project)-[:CONTAINS
2121
,coalesce(codeUnit.anomalyBridgeRank, 0) AS bridgeRank
2222
,coalesce(codeUnit.anomalyHubRank, 0) AS hubRank
2323
,coalesce(codeUnit.anomalyOutlierRank, 0) AS outlierRank
24+
,coalesce(codeUnit.dependencyDegreeRank, 0) AS degreeRank
2425
,codeUnit.anomalyTopFeature1 AS topFeature1
2526
,codeUnit.anomalyTopFeature2 AS topFeature2
2627
,codeUnit.anomalyTopFeature3 AS topFeature3

scripts/prepareAnalysis.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Outgoing_Typescript_Module_
121121
execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Incoming_Java_Package_Dependencies.cypher"
122122
execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Outgoing_Java_Package_Dependencies.cypher"
123123

124+
# Preparation - Language agnostic node properties "dependencyDegree", "dependencyDegreeWeighted", "dependencyDegreeRank"
125+
execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Dependency_Degree.cypher"
126+
execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Dependency_DegreeRank.cypher"
127+
124128
# Preparation - Add Java Method node property "declaringType"
125129
execute_cypher "${TYPES_CYPHER_DIR}/Set_declaring_type_on_method_nodes.cypher"
126130

0 commit comments

Comments
 (0)