|
17 | 17 | ,coalesce(central.fqn, central.globalFqn, central.fileName, central.signature, central.name) AS targetName |
18 | 18 | ,[] AS graphVizOutput |
19 | 19 | WITH *, graphVizOutput + ["graph [label=\"" + graphLabel + targetName + "\\n\\n\"];"] AS graphVizOutput |
20 | | - WITH *, "🏛️ authority #" + central.anomalyAuthorityRank + "\\n" + central.name AS centralNodeLabel |
| 20 | + WITH *, "🏛️ authority #" + central.anomalyAuthorityRank + "\\n" + central.name AS centralNodeLabel |
21 | 21 | WITH *, graphVizOutput + ["central [label=\"" + centralNodeLabel + "\"];"] AS graphVizOutput |
22 | 22 | // Step 3: Query direct incoming dependencies to the central node |
23 | 23 | MATCH (source)-[dependency:DEPENDS_ON]->(central) |
24 | 24 | WHERE $projection_node_label IN labels(source) |
25 | 25 | AND source.outgoingDependencies > 0 |
26 | 26 | ORDER BY dependency.weight DESC, source.name ASC |
27 | | - LIMIT 60 |
28 | | - WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight |
29 | | - WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth |
30 | | - WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes |
31 | | - WITH *, CASE WHEN source.centralityPageRankToArticleRankDifference > pageToArticleRankThreshold THEN 5 ELSE 2 END AS scaledNodeBorder |
32 | | - WITH *, round(source.centralityPageRankNormalized * 0.66 + 0.2, 3) AS scaledNodeSize |
33 | | - WITH *, coalesce(scaledNodeSize, 0.5) AS scaledNodeSize |
34 | | - WITH *, "penwidth = " + scaledNodeBorder + "; " AS directInBorder |
35 | | - WITH *, "height = " + scaledNodeSize + "; " AS directInSize |
36 | | - WITH *, "\"" + source.name + "\" [" + directInBorder + directInSize + "]; " AS directInNode |
| 27 | + LIMIT 40 |
| 28 | + WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight |
| 29 | + WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth |
| 30 | + WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes |
| 31 | + WITH *, CASE WHEN source.centralityPageRankToArticleRankDifference > pageToArticleRankThreshold |
| 32 | + THEN 5 ELSE 2 END AS scaledNodeBorder |
| 33 | + WITH *, round(source.centralityPageRankNormalized * 1.0 + 1.0, 3) AS scaledNodeSize |
| 34 | + WITH *, round(source.centralityPageRankNormalized * 100.0, 2) + "%" AS labelValue |
| 35 | + // Add the last part of the element id to make the node name unique, even if the name itself isn't. |
| 36 | + WITH *, source.name + "_" + split(elementId(source), ':')[-1] AS sourceId |
| 37 | + WITH *, "penwidth = " + scaledNodeBorder + "; " AS directInBorder |
| 38 | + WITH *, "height = " + scaledNodeSize + "; " AS directInSize |
| 39 | + // Split long names like inner classes identified by a dollar sign ($) |
| 40 | + WITH *, replace(source.name, '$', '$\\n') AS sourceNameSplit |
| 41 | + WITH *, "label = \"" + sourceNameSplit + "\\n(" + labelValue + ")\"; " AS directInLabel |
| 42 | + WITH *, " [" + directInLabel + directInBorder + directInSize + "]; " AS directInNodeProperties |
| 43 | + WITH *, "\"" + sourceId + "\" " + directInNodeProperties AS directInNode |
37 | 44 | WITH maxWeight |
38 | 45 | ,pageToArticleRankThreshold |
39 | 46 | ,central |
40 | 47 | ,graphVizOutput |
41 | 48 | ,collect(source) AS incomingDependencyNodes |
42 | | - ,collect(directInNode + "\"" + source.name + "\" -> central [" + edgeAttributes + "];") AS directInEdges |
| 49 | + ,collect(directInNode + "\"" + sourceId + "\" -> central [" + edgeAttributes + "];") AS directInEdges |
43 | 50 | WITH *, graphVizOutput + directInEdges AS graphVizOutput |
44 | 51 | // Step 4: Query direct outgoing dependencies from the central node |
45 | 52 | MATCH (source)<-[dependency:DEPENDS_ON]-(central) |
46 | 53 | WHERE $projection_node_label IN labels(source) |
47 | 54 | AND source.incomingDependencies > 0 |
48 | 55 | ORDER BY dependency.weight DESC, source.name ASC |
49 | | - LIMIT 60 |
| 56 | + LIMIT 40 |
50 | 57 | WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight |
51 | 58 | WITH *, round((toFloat(weight) / toFloat(maxWeight) * 2.5) + 0.4, 1.0) AS penWidth |
52 | 59 | WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=" + penWidth AS edgeAttributes |
53 | 60 | // Use a lighter color for the target nodes of outgoing dependencies from the central node and their edges |
54 | 61 | WITH *, edgeAttributes + "; color = 5" AS edgeAttributes |
55 | | - WITH *, CASE WHEN source.centralityPageRankToArticleRankDifference > pageToArticleRankThreshold THEN 5 ELSE 2 END AS scaledNodeBorder |
56 | | - WITH *, round(source.centralityPageRankNormalized * 0.66 + 0.2, 3) AS scaledNodeSize |
57 | | - WITH *, coalesce(scaledNodeSize, 0.5) AS scaledNodeSize |
| 62 | + WITH *, CASE WHEN source.centralityPageRankToArticleRankDifference > pageToArticleRankThreshold |
| 63 | + THEN 5 ELSE 2 END AS scaledNodeBorder |
| 64 | + WITH *, round(source.centralityPageRankNormalized * 1.0 + 1.0, 3) AS scaledNodeSize |
| 65 | + WITH *, round(source.centralityPageRankNormalized * 100.0, 2) + "%" AS labelValue |
| 66 | + // Add the last part of the element id to make the node name unique, even if the name itself isn't. |
| 67 | + WITH *, source.name + "_" + split(elementId(source), ':')[-1] AS sourceId |
58 | 68 | WITH *, "penwidth = " + scaledNodeBorder + "; " AS directOutBorder |
59 | 69 | WITH *, "height = " + scaledNodeSize + "; " AS directOutSize |
60 | 70 | WITH *, "color = 5; fillcolor = 1; " AS directOutColors |
61 | | - WITH *, "\"" + source.name + "\" [" + directOutBorder + directOutSize + directOutColors + "]; " AS directOutNode |
| 71 | + // Split long names like inner classes identified by a dollar sign ($) |
| 72 | + WITH *, replace(source.name, '$', '$\\n') AS sourceNameSplit |
| 73 | + WITH *, "label = \"" + sourceNameSplit + "\\n(" + labelValue + ")\"; " AS directOutLabel |
| 74 | + WITH *, " [" + directOutLabel + directOutBorder + directOutSize + directOutColors + "]; " AS directOutNodeProperties |
| 75 | + WITH *, "\"" + sourceId + "\" " + directOutNodeProperties AS directOutNode |
62 | 76 | WITH maxWeight |
63 | 77 | ,pageToArticleRankThreshold |
64 | 78 | ,central |
65 | 79 | ,graphVizOutput |
66 | 80 | ,incomingDependencyNodes |
67 | 81 | ,collect(source) AS outgoingDependencyNodes |
68 | | - ,collect(directOutNode + "central -> \"" + source.name + "\" [" + edgeAttributes + "];") AS directOutEdges |
| 82 | + ,collect(directOutNode + "central -> \"" + sourceId + "\" [" + edgeAttributes + "];") AS directOutEdges |
69 | 83 | WITH *, graphVizOutput + directOutEdges AS graphVizOutput |
70 | 84 | WITH *, incomingDependencyNodes + outgoingDependencyNodes AS directDependentNodes |
71 | 85 | // Step 5: Query dependencies between direct dependencies outside the central node |
|
81 | 95 | ,directDependentNode |
82 | 96 | ,dependency |
83 | 97 | ,collect(anotherDirectDependentNode)[0] AS firstLinkedDependentNode |
84 | | - LIMIT 120 |
| 98 | + LIMIT 100 |
85 | 99 | WITH *, coalesce(dependency.weight25PercentInterfaces, dependency.weight, 1) AS weight |
86 | 100 | // Use a fixed small pen width for secondary dependencies for better visibility of the more important direct dependency |
87 | 101 | WITH *, "label=" + weight + "; weight=" + weight + "; penwidth=0.3" AS edgeAttributes |
88 | 102 | // Use an even lighter color for secondary dependency edges |
89 | 103 | WITH *, edgeAttributes + "; color = 3" AS edgeAttributes |
90 | | - WITH *, "\"" + directDependentNode.name + "\" -> \"" + firstLinkedDependentNode.name + "\"" AS directDependenciesEdge |
| 104 | + WITH *, directDependentNode.name + "_" + split(elementId(directDependentNode), ':')[-1] AS directDependentNodeId |
| 105 | + WITH *, firstLinkedDependentNode.name + "_" + split(elementId(firstLinkedDependentNode), ':')[-1] AS firstLinkedDependentNodeId |
| 106 | + WITH *, "\"" + directDependentNodeId + "\" -> \"" + firstLinkedDependentNodeId + "\"" AS directDependenciesEdge |
91 | 107 | WITH *, collect(directDependenciesEdge + " [" + edgeAttributes + "]") AS directDependenciesEdges |
92 | 108 | WITH *, graphVizOutput + directDependenciesEdges AS graphVizOutput |
93 | 109 | UNWIND graphVizOutput AS graphVizOutputLine |
|
0 commit comments