11// Anomaly Detection DeepDive: Overview of analyzed code units and the number of anomalies detected. Requires all other labels/*.cypher queries to run first. Variables: projection_language, projection_node_label
22
3- MATCH (codeUnit )
4- WHERE $projection_node_label IN labels (codeUnit )
5- AND (codeUnit .incomingDependencies IS NOT NULL
6- OR codeUnit .outgoingDependencies IS NOT NULL )
3+ MATCH (codeUnit )
4+ WHERE $projection_node_label IN labels (codeUnit )
5+ AND (codeUnit .incomingDependencies > 0
6+ OR codeUnit .outgoingDependencies > 0 )
7+ AND coalesce (codeUnit .testMarkerInteger , 0 ) = 0
8+ OPTIONAL MATCH (codeUnit )- [ dependency : DEPENDS_ON ] - (target )
9+ WHERE $projection_node_label IN labels (target )
10+ AND (target .incomingDependencies > 0
11+ OR target .outgoingDependencies > 0 )
12+ AND coalesce (target .testMarkerInteger , 0 ) = 0
13+ WITH count (dependency ) AS relationshipCount
14+ ,collect (DISTINCT codeUnit ) AS codeUnits
15+ UNWIND codeUnits AS codeUnit
716 WITH sum (codeUnit .anomalyLabel ) AS anomalyCount
817 ,sum (sign (codeUnit .anomalyAuthorityRank )) AS authorityCount
918 ,sum (sign (codeUnit .anomalyBottleneckRank )) AS bottleNeckCount
1019 ,sum (sign (codeUnit .anomalyBridgeRank )) AS bridgeCount
1120 ,sum (sign (codeUnit .anomalyHubRank )) AS hubCount
1221 ,sum (sign (codeUnit .anomalyOutlierRank )) AS outlierCount
22+ ,count (codeUnit ) AS nodeCount
23+ ,relationshipCount
1324 //,collect(codeUnit.name)[0..4] AS exampleNames
14- RETURN anomalyCount AS `Anomalies`
15- ,authorityCount AS `Authorities`
16- ,bottleNeckCount AS `Bottlenecks`
17- ,bridgeCount AS `Bridges`
18- ,hubCount AS `Hubs`
19- ,outlierCount AS `Outliers`
20- //,exampleNames
25+ RETURN anomalyCount AS `Anomalies`
26+ ,authorityCount AS `Authorities`
27+ ,bottleNeckCount AS `Bottlenecks`
28+ ,bridgeCount AS `Bridges`
29+ ,hubCount AS `Hubs`
30+ ,outlierCount AS `Outliers`
31+ ,nodeCount AS `CodeUnits`
32+ ,relationshipCount AS `Dependencies`
33+ ,round (toFloat (relationshipCount ) / (nodeCount * (nodeCount - 1 )), 6 ) AS `GraphDensity`
34+ //,exampleNames
0 commit comments