Skip to content

Commit 3c89fab

Browse files
committed
fixup! Add graph visualizations to anomaly detection
1 parent f7272ea commit 3c89fab

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

domains/anomaly-detection/graphs/TopCentral.template.gv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
//
55
strict digraph top_central_template {
66
//Begin-Template
7-
graph [layout = "fdp"; start = "7"; splines = "spline"; beautify = true;];
7+
graph [layout = "fdp"; start = "7"; splines = "spline"; beautify = true; pad = "0.8,0.1";];
88
graph [fontname = "Helvetica,Arial,sans-serif"; labelloc = "t";];
99
node [colorscheme = "bugn9"; color = 6; fillcolor = 3;]; # Alternative: color = "0.58 0.75 0.75"; fillcolor = "0.58 0.15 0.99"
1010
edge [colorscheme = "bugn9"; color = 7; ]; # Alternative: color = "0.58 0.75 0.85";
11-
node [fontsize = 10; style = "filled"; margin = "0.001,0.001"];
11+
node [fontsize = 8; style = "filled"; margin = "0.001,0.001"];
1212
edge [fontsize = 4; arrowsize = "0.4";];
1313

1414
central [shape = "doublecircle"; margin = "0.00001,0.00001";];
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This is a GraphViz dot template file for the visualization of a anomaly archetype graphs with a selected central node.
2+
// The main part of the template is marked by the comments "Begin-Template" and "End-Template".
3+
// It also contains a simple example graph.
4+
//
5+
strict digraph top_central_template {
6+
//Begin-Template
7+
graph [layout = "fdp"; start = "7"; splines = "spline"; beautify = true; pad = "0.8,0.1"];
8+
graph [fontname = "Helvetica,Arial,sans-serif"; labelloc = "t";];
9+
node [colorscheme = "bugn9"; color = 6; fillcolor = 3;];
10+
edge [colorscheme = "bugn9"; color = 7; ];
11+
node [shape = "circle"; fixedsize = true]
12+
node [fontsize = 8; style = "filled";];
13+
edge [fontsize = 4; arrowsize = "0.4";];
14+
15+
central [shape = "doublecircle"; fixedsize = false; margin = "0.000001,0.000001";];
16+
central [fontsize = 16;];
17+
central [color = 7; fillcolor = 5; penwidth = 3;];
18+
19+
limit_hint [color = 7; fillcolor = 5; penwidth = 2;]
20+
limit_hint [shape = "note"; fixedsize = false; fontsize = 10;]
21+
limit_hint [label = "limited\nnode count";]
22+
limit_hint -> central [dir = "back"; arrowtail = "inv"]; // Signals that the number of edges might have been limited
23+
24+
//End-Template
25+
"A" -> "central" [penwidth = 1.0; label = 1;];
26+
"A" -> "B" [penwidth = 3.0; label = 4;];
27+
"B" -> "central" [penwidth = 2.0; label = 2;];
28+
}

domains/anomaly-detection/graphs/TopOutlier.cypher

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
,coalesce(central.fqn, central.globalFqn, central.fileName, central.signature, central.name) AS targetName
1818
,[] AS graphVizOutput
1919
WITH *, graphVizOutput + ["graph [label=\"" + graphLabel + targetName + "\\n\\n\"];"] AS graphVizOutput
20-
WITH *, "🧩\\noutlier #" + central.anomalyOutlierRank + "\\n" + central.name AS centralNodeLabel
20+
WITH *, "🧩 outlier #" + central.anomalyOutlierRank + "\\n" + central.name AS centralNodeLabel
2121
WITH *, graphVizOutput + ["central [label=\"" + centralNodeLabel + "\"];"] AS graphVizOutput
2222
// Step 3: Query direct incoming dependencies to the central node
2323
MATCH (source)-[dependency:DEPENDS_ON]->(central)
@@ -29,9 +29,8 @@
2929
WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth
3030
WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes
3131
WITH *, CASE WHEN source.clusteringHDBSCANNormalizedDistanceToMedoid > clusterMedoidDistanceThreshold THEN 5 ELSE 2 END AS scaledNodeBorder
32-
WITH *, round((1.0 - source.clusteringHDBSCANProbability) * 1.8 - 0.2, 3) AS scaledNodeSize
32+
WITH *, round((1.0 - source.clusteringHDBSCANProbability) * 1.3 + 1.0, 3) AS scaledNodeSize
3333
WITH *, round(source.clusteringHDBSCANProbability * 100.0, 2) + "%" AS labelValue
34-
WITH *, coalesce(scaledNodeSize, 0.5) AS scaledNodeSize
3534
WITH *, source.name + "_" + split(elementId(source), ':')[-1] AS sourceId
3635
WITH *, "penwidth = " + scaledNodeBorder + "; " AS directInBorder
3736
WITH *, "height = " + scaledNodeSize + "; " AS directInSize
@@ -57,9 +56,8 @@
5756
// Use a lighter color for the target nodes of outgoing dependencies from the central node and their edges
5857
WITH *, edgeAttributes + "; color = 5" AS edgeAttributes
5958
WITH *, CASE WHEN source.clusteringHDBSCANNormalizedDistanceToMedoid > clusterMedoidDistanceThreshold THEN 5 ELSE 2 END AS scaledNodeBorder
60-
WITH *, round((1.0 - source.clusteringHDBSCANProbability) * 1.8 - 0.2, 3) AS scaledNodeSize
59+
WITH *, round((1.0 - source.clusteringHDBSCANProbability) * 1.3 + 1.0, 3) AS scaledNodeSize
6160
WITH *, round(source.clusteringHDBSCANProbability * 100.0, 2) + "%" AS labelValue
62-
WITH *, coalesce(scaledNodeSize, 0.5) AS scaledNodeSize
6361
WITH *, source.name + "_" + split(elementId(source), ':')[-1] AS sourceId
6462
WITH *, "penwidth = " + scaledNodeBorder + "; " AS directOutBorder
6563
WITH *, "height = " + scaledNodeSize + "; " AS directOutSize
@@ -68,7 +66,6 @@
6866
WITH *, " [" + directOutLabel + directOutBorder + directOutSize + directOutColors + "]; " AS directOutNodeProperties
6967
WITH *, "\"" + sourceId + "\" " + directOutNodeProperties AS directOutNode
7068
WITH maxWeight
71-
,clusterMedoidDistanceThreshold
7269
,central
7370
,graphVizOutput
7471
,incomingDependencyNodes
@@ -83,7 +80,6 @@
8380
AND anotherDirectDependentNode <> directDependentNode
8481
ORDER BY dependency.weight DESC, directDependentNode.name ASC
8582
WITH maxWeight
86-
,clusterMedoidDistanceThreshold
8783
,central
8884
,graphVizOutput
8985
,directDependentNode

domains/anomaly-detection/graphs/TopSized.template.gv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
//
55
strict digraph top_central_template {
66
//Begin-Template
7-
graph [layout = "fdp"; start = "7"; splines = "spline"; beautify = true;];
7+
graph [layout = "fdp"; start = "7"; splines = "spline"; beautify = true; pad = "0.8,0.1";];
88
graph [fontname = "Helvetica,Arial,sans-serif"; labelloc = "t";];
99
node [colorscheme = "bugn9"; color = 6; fillcolor = 3;]; # Alternative: color = "0.58 0.75 0.75"; fillcolor = "0.58 0.15 0.99"
1010
edge [colorscheme = "bugn9"; color = 7; ]; # Alternative: color = "0.58 0.75 0.85";
1111
node [shape = "circle";]
12-
node [fontsize = 10; style = "filled"; margin = "0.0001,0.0001"];
12+
node [fontsize = 8; style = "filled"; margin = "0.0001,0.0001"];
1313
edge [fontsize = 4; arrowsize = "0.4";];
1414

1515
central [shape = "doublecircle"; margin = "0.000001,0.000001";];

domains/anomaly-detection/graphs/anomalyDetectionGraphVisualization.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ anomaly_detection_graph_visualization() {
145145
create_graph_visualization "report_name=TopBottleneck" "template_name=TopCentral" "${@}"
146146
create_graph_visualization "report_name=TopAuthority" "template_name=TopSized" "${@}"
147147
create_graph_visualization "report_name=TopBridge" "template_name=TopCentral" "${@}"
148-
create_graph_visualization "report_name=TopOutlier" "template_name=TopSized" "${@}"
148+
create_graph_visualization "report_name=TopOutlier" "template_name=TopFixSized" "${@}"
149149
}
150150

151151

0 commit comments

Comments
 (0)