Skip to content

Commit 47ba715

Browse files
committed
Improve code unit name in graph algorithm result reports
1 parent 9142905 commit 47ba715

8 files changed

+44
-22
lines changed

cypher/Centrality/Centrality_10d_Bridges_Stream.cypher

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ CALL gds.bridges.stream($dependencies_projection + '-cleaned')
44
YIELD from, to
55
WITH gds.util.asNode(from) AS fromMember
66
,gds.util.asNode(to) AS toMember
7-
OPTIONAL MATCH (fromType:Type)-[:DECLARES]->(fromMember)
8-
WITH *, coalesce(fromType.fqn + ': ', '') +
7+
WITH *, coalesce(fromMember.declaringType + ': ', '') +
98
coalesce(fromMember.rootProjectName + '/', '') +
109
coalesce(fromMember.signature, fromMember.name) AS fromMemberNameWithDetails
11-
OPTIONAL MATCH (toType:Type)-[:DECLARES]->(toMember)
12-
WITH *, coalesce(toType.fqn + ': ', '') +
10+
WITH *, coalesce(toMember.declaringType + ': ', '') +
1311
coalesce(toMember.rootProjectName + '/', '') +
1412
coalesce(toMember.signature, toMember.name) AS toMemberNameWithDetails
1513
RETURN coalesce(fromMember.fqn, fromMemberNameWithDetails, fromMember.fileName, fromMember.name) AS fromMemberName
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Centrality 9d Hyperlink-Induced Topic Search (HITS) Stream Mutated. Requires "Add_file_name and_extension.cypher".
1+
// Centrality 9d Hyperlink-Induced Topic Search (HITS) Stream Mutated. Requires "Add_file_name and_extension.cypher", "Set_localRootPath_for_modules", "Set_declaring_type_on_method_nodes".
22

33
CALL gds.graph.nodeProperties.stream(
44
$dependencies_projection + '-cleaned'
@@ -10,10 +10,13 @@ CALL gds.graph.nodeProperties.stream(
1010
YIELD nodeId, propertyValue
1111
WITH gds.util.asNode(nodeId) AS codeUnit
1212
,collect(propertyValue) AS values
13-
RETURN DISTINCT coalesce(codeUnit.fqn, codeUnit.fileName, codeUnit.signature, codeUnit.name) AS codeUnitName
14-
,codeUnit.name AS shortCodeUnitName
15-
,values[0] AS centralityHyperlinkInducedTopicSearchAuthority
16-
,values[1] AS centralityHyperlinkInducedTopicSearchHub
13+
WITH *, coalesce(codeUnit.declaringType + ': ', '') +
14+
coalesce(codeUnit.rootProjectName + '/', '') +
15+
coalesce(codeUnit.signature, codeUnit.name) AS codeUnitNameWithDetails
16+
RETURN DISTINCT coalesce(codeUnit.fqn, codeUnitNameWithDetails, codeUnit.fileName, codeUnit.name) AS codeUnitName
17+
,codeUnit.name AS shortCodeUnitName
18+
,values[0] AS centralityHyperlinkInducedTopicSearchAuthority
19+
,values[1] AS centralityHyperlinkInducedTopicSearchHub
1720
,codeUnit.incomingDependencies AS incomingDependencies
1821
,codeUnit.outgoingDependencies AS outgoingDependencies
1922
ORDER BY centralityHyperlinkInducedTopicSearchAuthority DESCENDING, codeUnitName ASCENDING
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Read a property from the projection. Variables: dependencies_projection, dependencies_projection_write_property. Requires "Add_file_name and_extension.cypher".
1+
// Read a property from projected nodes unordered. Variables: dependencies_projection, dependencies_projection_write_property. Requires "Add_file_name and_extension.cypher", "Set_localRootPath_for_modules", "Set_declaring_type_on_method_nodes".
22

33
CALL gds.graph.nodeProperties.stream(
44
$dependencies_projection + '-cleaned'
@@ -8,7 +8,10 @@ YIELD nodeId, nodeProperty, propertyValue
88
WITH gds.util.asNode(nodeId) AS codeUnit
99
,nodeProperty AS propertyName
1010
,propertyValue
11-
RETURN DISTINCT coalesce(codeUnit.fqn, codeUnit.fileName, codeUnit.signature, codeUnit.name) AS codeUnitName
11+
WITH *, coalesce(codeUnit.declaringType + ': ', '') +
12+
coalesce(codeUnit.rootProjectName + '/', '') +
13+
coalesce(codeUnit.signature, codeUnit.name) AS codeUnitNameWithDetails
14+
RETURN DISTINCT coalesce(codeUnit.fqn, codeUnitNameWithDetails, codeUnit.fileName, codeUnit.name) AS codeUnitName
1215
,codeUnit.name AS shortCodeUnitName
1316
,propertyName
1417
,propertyValue
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
// Read a property from the projection into the Graph. Variables: dependencies_projection, dependencies_projection_write_property. Requires "Add_file_name and_extension.cypher".
1+
// Read a property from projected nodes extended by some details. Variables: dependencies_projection, dependencies_projection_write_property. Requires "Add_file_name and_extension.cypher", "Set_localRootPath_for_modules", "Set_declaring_type_on_method_nodes".
22

33
CALL gds.graph.nodeProperties.stream(
44
$dependencies_projection + '-cleaned'
55
,[$dependencies_projection_write_property]
66
)
77
YIELD nodeId, nodeProperty, propertyValue
88
WITH gds.util.asNode(nodeId) AS codeUnit
9-
,nodeProperty AS propertyName
9+
,nodeProperty AS propertyName
1010
,propertyValue
11-
OPTIONAL MATCH (artifact:Artifact)-[:CONTAINS]->(codeUnit)
12-
RETURN DISTINCT coalesce(codeUnit.fqn, codeUnit.fileName, codeUnit.name) AS codeUnitName
11+
WITH *, coalesce(codeUnit.declaringType + ': ', '') +
12+
coalesce(codeUnit.rootProjectName + '/', '') +
13+
coalesce(codeUnit.signature, codeUnit.name) AS codeUnitNameWithDetails
14+
OPTIONAL MATCH (project:Artifact|Project)-[:CONTAINS]->(codeUnit)
15+
RETURN DISTINCT coalesce(codeUnit.fqn, codeUnitNameWithDetails, codeUnit.fileName, codeUnit.name) AS codeUnitName
1316
,codeUnit.name AS shortCodeUnitName
1417
,propertyName
1518
,propertyValue
16-
,coalesce(codeUnit.communityLeidenId, 0) AS communityId // optional, might be null
17-
,coalesce(codeUnit.centralityPageRank, 0.01) AS centrality // optional, might be null
18-
,artifact.name AS owningArtifactName
19+
,coalesce(codeUnit.communityLeidenId, 0) AS communityId // optional, might be null
20+
,coalesce(codeUnit.centralityPageRank, 0.00001) AS centrality // optional, might be null
21+
,project.name AS owningProject

cypher/Dependencies_Projection/Dependencies_8_Stream_Mutated_Grouped.cypher

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Read a property from the projection. Variables: dependencies_projection, dependencies_projection_write_property. Requires "Add_file_name and_extension.cypher".
1+
// Read a property from projected nodes. Variables: dependencies_projection, dependencies_projection_write_property. Requires "Add_file_name and_extension.cypher", "Set_localRootPath_for_modules", "Set_declaring_type_on_method_nodes".
22

33
CALL gds.graph.nodeProperties.stream(
44
$dependencies_projection + '-cleaned'
@@ -8,9 +8,12 @@ YIELD nodeId, nodeProperty, propertyValue
88
WITH gds.util.asNode(nodeId) AS codeUnit
99
,nodeProperty AS propertyName
1010
,propertyValue
11+
WITH *, coalesce(codeUnit.declaringType + ': ', '') +
12+
coalesce(codeUnit.rootProjectName + '/', '') +
13+
coalesce(codeUnit.signature, codeUnit.name) AS codeUnitNameWithDetails
1114
WITH propertyName
1215
,propertyValue
13-
,coalesce(codeUnit.fqn, codeUnit.fileName, codeUnit.name) AS codeUnitName
16+
,coalesce(codeUnit.fqn, codeUnitNameWithDetails, codeUnit.fileName, codeUnit.name) AS codeUnitName
1417
,codeUnit.name AS shortCodeUnitName
1518
WITH propertyName
1619
,propertyValue

cypher/Dependencies_Projection/Dependencies_8_Stream_Mutated_Value_Descending.cypher

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Read a property from the projection and order it by its value descending. Variables: dependencies_projection, dependencies_projection_write_property. Requires "Add_file_name and_extension.cypher".
1+
// Read a property from projected nodes ordered by their value descending. Variables: dependencies_projection, dependencies_projection_write_property. Requires "Add_file_name and_extension.cypher", "Set_localRootPath_for_modules", "Set_declaring_type_on_method_nodes".
22

33
CALL gds.graph.nodeProperties.stream(
44
$dependencies_projection + '-cleaned'
@@ -8,7 +8,10 @@ YIELD nodeId, nodeProperty, propertyValue
88
WITH gds.util.asNode(nodeId) AS codeUnit
99
,nodeProperty AS propertyName
1010
,propertyValue
11-
RETURN DISTINCT coalesce(codeUnit.fqn, codeUnit.fileName, codeUnit.signature, codeUnit.name) AS codeUnitName
11+
WITH *, coalesce(codeUnit.declaringType + ': ', '') +
12+
coalesce(codeUnit.rootProjectName + '/', '') +
13+
coalesce(codeUnit.signature, codeUnit.name) AS codeUnitNameWithDetails
14+
RETURN DISTINCT coalesce(codeUnit.fqn, codeUnitNameWithDetails, codeUnit.fileName, codeUnit.name) AS codeUnitName
1215
,codeUnit.name AS shortCodeUnitName
1316
,propertyName
1417
,propertyValue
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Set property "declaringType" on Method nodes.
2+
3+
MATCH (javaType:Type)-[:DECLARES]->(javaMethod:Method)
4+
SET javaMethod.declaringType = javaType.fqn
5+
RETURN count(DISTINCT javaMethod) AS numberOfMethods
6+
,count(DISTINCT javaType) AS numberOfTypes

scripts/prepareAnalysis.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Outgoing_Typescript_Module_
112112
execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Incoming_Java_Package_Dependencies.cypher"
113113
execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Outgoing_Java_Package_Dependencies.cypher"
114114

115+
# Preparation - Add Java Method node property "declaringType"
116+
execute_cypher "${TYPES_CYPHER_DIR}/Set_declaring_type_on_method_nodes.cypher"
117+
115118
# Preparation - Label external types and annotations
116119
# "external" means that there is no byte code available, not a primitive type and not a java type
117120
# "annotation" means that there is a ANNOTATED_BY to that external type

0 commit comments

Comments
 (0)