Skip to content

Commit 55240e2

Browse files
authored
Merge pull request #457 from JohT/fix/missing-graph-visualization-and-anomaly-detection-report
Fix missing Graph visualizations with optional links and parametrized weight property
2 parents 107b946 + 586c5e3 commit 55240e2

File tree

6 files changed

+103
-65
lines changed

6 files changed

+103
-65
lines changed

domains/anomaly-detection/graphs/TopAuthority.cypher

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
MATCH (sourceForStatistics)-[dependencyForStatistics:DEPENDS_ON]->(targetForStatistics)
55
WHERE $projection_node_label IN labels(sourceForStatistics)
66
AND $projection_node_label IN labels(targetForStatistics)
7-
WITH max(coalesce(dependencyForStatistics.weight25PercentInterfaces, dependencyForStatistics.weight)) AS maxWeight
7+
WITH max(coalesce(dependencyForStatistics[$projection_weight_property])) AS maxWeight
88
,percentileDisc(sourceForStatistics.centralityPageRankToArticleRankDifference, 0.80) AS pageToArticleRankThreshold
99
,percentileDisc(targetForStatistics.centralityPageRankNormalized, 0.80) AS pageRankThreshold
1010
// Step 2: Query selected central node
@@ -26,12 +26,12 @@
2626
WITH *, "🏛️ authority #" + central.anomalyAuthorityRank + "\\n" + central.name AS centralNodeLabel
2727
WITH *, graphVizOutput + ["central [label=\"" + centralNodeLabel + "\"];"] AS graphVizOutput
2828
// Step 3: Query direct incoming dependencies to the central node
29-
MATCH (source)-[dependency:DEPENDS_ON]->(central)
29+
OPTIONAL MATCH (source)-[dependency:DEPENDS_ON]->(central)
3030
WHERE $projection_node_label IN labels(source)
3131
AND source.outgoingDependencies > 0
32-
ORDER BY dependency.weight DESC, source.name ASC
32+
ORDER BY dependency[$projection_weight_property] DESC, source.name ASC
3333
LIMIT 40
34-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
34+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
3535
WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth
3636
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes
3737
WITH *, CASE WHEN source.centralityPageRankToArticleRankDifference >= pageToArticleRankThreshold
@@ -56,12 +56,12 @@
5656
,collect(directInNode + "\"" + sourceId + "\" -> central [" + edgeAttributes + "];") AS directInEdges
5757
WITH *, graphVizOutput + directInEdges AS graphVizOutput
5858
// Step 4: Query direct outgoing dependencies from the central node
59-
MATCH (source)<-[dependency:DEPENDS_ON]-(central)
59+
OPTIONAL MATCH (source)<-[dependency:DEPENDS_ON]-(central)
6060
WHERE $projection_node_label IN labels(source)
6161
AND source.incomingDependencies > 0
62-
ORDER BY dependency.weight DESC, source.name ASC
62+
ORDER BY dependency[$projection_weight_property] DESC, source.name ASC
6363
LIMIT 40
64-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
64+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
6565
WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth
6666
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes
6767
// Use a lighter color for the target nodes of outgoing dependencies from the central node and their edges
@@ -90,16 +90,16 @@
9090
WITH *, incomingDependencyNodes + outgoingDependencyNodes AS directDependentNodes
9191
// Step 5: Query dependencies between direct dependencies outside the central node
9292
UNWIND directDependentNodes AS directDependentNode
93-
MATCH (directDependentNode)-[dependency:DEPENDS_ON]->(anotherDirectDependentNode)
93+
OPTIONAL MATCH (directDependentNode)-[dependency:DEPENDS_ON]->(anotherDirectDependentNode)
9494
WHERE anotherDirectDependentNode IN directDependentNodes
9595
AND anotherDirectDependentNode <> directDependentNode
96-
ORDER BY dependency.weight DESC, directDependentNode.name ASC
96+
ORDER BY dependency[$projection_weight_property] DESC, directDependentNode.name ASC
9797
WITH graphVizOutput
9898
,directDependentNode
9999
,dependency
100100
,collect(anotherDirectDependentNode)[0] AS firstLinkedDependentNode
101101
LIMIT 140
102-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
102+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
103103
// Use a fixed small pen width for secondary dependencies for better visibility of the more important direct dependency
104104
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=0.3" AS edgeAttributes
105105
// Use an even lighter color for secondary dependency edges

domains/anomaly-detection/graphs/TopBottleneck.cypher

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
MATCH (sourceForStatistics)-[dependencyForStatistics:DEPENDS_ON]->(targetForStatistics)
55
WHERE $projection_node_label IN labels(sourceForStatistics)
66
AND $projection_node_label IN labels(targetForStatistics)
7-
WITH max(coalesce(dependencyForStatistics.weight25PercentInterfaces, dependencyForStatistics.weight)) AS maxWeight
8-
,percentileDisc(sourceForStatistics.centralityBetweenness, 0.90) AS betweennessThreshold
7+
WITH max(coalesce(dependencyForStatistics[$projection_weight_property])) AS maxWeight
8+
,percentileDisc(sourceForStatistics.centralityBetweenness, 0.90) AS betweennessThreshold
99
// Step 2: Query selected central node
1010
MATCH (central)
1111
WHERE $projection_node_label IN labels(central)
@@ -23,12 +23,12 @@
2323
WITH *, "🔒 bottleneck #" + central.anomalyBottleneckRank + "\\n" + central.name AS centralNodeLabel
2424
WITH *, graphVizOutput + ["central [label=\"" + centralNodeLabel + "\"];"] AS graphVizOutput
2525
// Step 3: Query direct incoming dependencies to the central node
26-
MATCH (source)-[dependency:DEPENDS_ON]->(central)
26+
OPTIONAL MATCH (source)-[dependency:DEPENDS_ON]->(central)
2727
WHERE $projection_node_label IN labels(source)
2828
AND source.outgoingDependencies > 0
29-
ORDER BY dependency.weight DESC, source.name ASC
29+
ORDER BY dependency[$projection_weight_property] DESC, source.name ASC
3030
LIMIT 40
31-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
31+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
3232
WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth
3333
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes
3434
WITH *, CASE WHEN source.centralityBetweenness >= betweennessThreshold
@@ -50,12 +50,12 @@
5050
,collect(directInNode + "\"" + sourceId + "\" -> central [" + edgeAttributes + "];") AS directInEdges
5151
WITH *, graphVizOutput + directInEdges AS graphVizOutput
5252
// Step 4: Query direct outgoing dependencies from the central node
53-
MATCH (source)<-[dependency:DEPENDS_ON]-(central)
53+
OPTIONAL MATCH (source)<-[dependency:DEPENDS_ON]-(central)
5454
WHERE $projection_node_label IN labels(source)
5555
AND source.incomingDependencies > 0
56-
ORDER BY dependency.weight DESC, source.name ASC
56+
ORDER BY dependency[$projection_weight_property] DESC, source.name ASC
5757
LIMIT 40
58-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
58+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
5959
WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth
6060
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes
6161
// Use a lighter color for the target nodes of outgoing dependencies from the central node and their edges
@@ -72,9 +72,7 @@
7272
WITH *, "label = \"" + sourceNameSplit + "\\n(" + labelValue + ")\"; " AS directOutLabel
7373
WITH *, " [" + directOutLabel + directOutBorder + directOutColor + "]; " AS directOutNodeProperties
7474
WITH *, "\"" + sourceId + "\" " + directOutNodeProperties AS directOutNode
75-
WITH maxWeight
76-
,betweennessThreshold
77-
,central
75+
WITH central
7876
,graphVizOutput
7977
,incomingDependencyNodes
8078
,collect(source) AS outgoingDependencyNodes
@@ -83,16 +81,16 @@
8381
WITH *, incomingDependencyNodes + outgoingDependencyNodes AS directDependentNodes
8482
// Step 5: Query dependencies between direct dependencies outside the central node
8583
UNWIND directDependentNodes AS directDependentNode
86-
MATCH (directDependentNode)-[dependency:DEPENDS_ON]->(anotherDirectDependentNode)
84+
OPTIONAL MATCH (directDependentNode)-[dependency:DEPENDS_ON]->(anotherDirectDependentNode)
8785
WHERE anotherDirectDependentNode IN directDependentNodes
8886
AND anotherDirectDependentNode <> directDependentNode
89-
ORDER BY dependency.weight DESC, directDependentNode.name ASC
87+
ORDER BY dependency[$projection_weight_property] DESC, directDependentNode.name ASC
9088
WITH graphVizOutput
9189
,directDependentNode
9290
,dependency
9391
,collect(anotherDirectDependentNode)[0] AS firstLinkedDependentNode
9492
LIMIT 140
95-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
93+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
9694
// Use a fixed small pen width for secondary dependencies for better visibility of the more important direct dependency
9795
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=0.3" AS edgeAttributes
9896
// Use an even lighter color for secondary dependency edges

domains/anomaly-detection/graphs/TopBridge.cypher

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
MATCH (sourceForStatistics)-[dependencyForStatistics:DEPENDS_ON]->(targetForStatistics)
55
WHERE $projection_node_label IN labels(sourceForStatistics)
66
AND $projection_node_label IN labels(targetForStatistics)
7-
WITH max(coalesce(dependencyForStatistics.weight25PercentInterfaces, dependencyForStatistics.weight)) AS maxWeight
7+
WITH max(coalesce(dependencyForStatistics[$projection_weight_property])) AS maxWeight
88
// Step 2: Query selected central node
99
MATCH (central)
1010
WHERE $projection_node_label IN labels(central)
@@ -19,12 +19,12 @@
1919
WITH *, "🌉 bridge #" + central.anomalyBridgeRank + "\\n" + central.name AS centralNodeLabel
2020
WITH *, graphVizOutput + ["central [label=\"" + centralNodeLabel + "\"];"] AS graphVizOutput
2121
// Step 3: Query direct incoming dependencies to the central node
22-
MATCH (source)-[dependency:DEPENDS_ON]->(central)
22+
OPTIONAL MATCH (source)-[dependency:DEPENDS_ON]->(central)
2323
WHERE $projection_node_label IN labels(source)
2424
AND source.outgoingDependencies > 0
25-
ORDER BY dependency.weight DESC, source.name ASC
25+
ORDER BY dependency[$projection_weight_property] DESC, source.name ASC
2626
LIMIT 40
27-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
27+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
2828
WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth
2929
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes
3030
// Add the last part of the element id to the node name to make it unique.
@@ -41,12 +41,12 @@
4141
,collect(directInNode + "\"" + sourceId + "\" -> central [" + edgeAttributes + "];") AS directInEdges
4242
WITH *, graphVizOutput + directInEdges AS graphVizOutput
4343
// Step 4: Query direct outgoing dependencies from the central node
44-
MATCH (source)<-[dependency:DEPENDS_ON]-(central)
44+
OPTIONAL MATCH (source)<-[dependency:DEPENDS_ON]-(central)
4545
WHERE $projection_node_label IN labels(source)
4646
AND source.incomingDependencies > 0
47-
ORDER BY dependency.weight DESC, source.name ASC
47+
ORDER BY dependency[$projection_weight_property] DESC, source.name ASC
4848
LIMIT 40
49-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
49+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
5050
WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth
5151
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes
5252
// Use a lighter color for the target nodes of outgoing dependencies from the central node and their edges
@@ -70,16 +70,16 @@
7070
WITH *, incomingDependencyNodes + outgoingDependencyNodes AS directDependentNodes
7171
// Step 5: Query dependencies between direct dependencies outside the central node
7272
UNWIND directDependentNodes AS directDependentNode
73-
MATCH (directDependentNode)-[dependency:DEPENDS_ON]->(anotherDirectDependentNode)
73+
OPTIONAL MATCH (directDependentNode)-[dependency:DEPENDS_ON]->(anotherDirectDependentNode)
7474
WHERE anotherDirectDependentNode IN directDependentNodes
7575
AND anotherDirectDependentNode <> directDependentNode
76-
ORDER BY dependency.weight DESC, directDependentNode.name ASC
76+
ORDER BY dependency[$projection_weight_property] DESC, directDependentNode.name ASC
7777
WITH graphVizOutput
7878
,directDependentNode
7979
,dependency
8080
,collect(anotherDirectDependentNode)[0] AS firstLinkedDependentNode
8181
LIMIT 140
82-
WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight
82+
WITH *, coalesce(dependency[$projection_weight_property], 1) AS weight
8383
// Use a fixed small pen width for secondary dependencies for better visibility of the more important direct dependency
8484
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=0.3" AS edgeAttributes
8585
// Use an even lighter color for secondary dependency edges

0 commit comments

Comments
 (0)