Skip to content

Commit 9d41fa9

Browse files
committed
Add cypher queries to explore code graph schemas
1 parent 8a46330 commit 9d41fa9

6 files changed

+72
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Get DEPENDS_ON relationships schema
2+
3+
MATCH (s)-[r:DEPENDS_ON]->(t)
4+
RETURN labels(s) AS sourceLabels
5+
,labels(t) AS targetLabels
6+
,keys(r) AS relationshipKeys
7+
,count(*) AS numberOfNodes
8+
ORDER BY sourceLabels, targetLabels, relationshipKeys
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// External declarations split by their module and their contained symbols
2+
3+
MATCH (s:ExternalDeclaration)
4+
WITH *
5+
,replace(split(s.globalFqn, '".')[0],'"', '') AS externalDeclarationModule
6+
,split(s.globalFqn, '".')[1] AS externalDeclarationSymbol
7+
RETURN externalDeclarationModule
8+
,count(DISTINCT externalDeclarationSymbol) AS externalDeclarationSymbols
9+
,collect(externalDeclarationSymbol)[0..4] AS someExternalDeclarationSymbols
10+
,count(*) as numberOfExternalDeclarations
11+
ORDER BY numberOfExternalDeclarations DESC, externalDeclarationModule ASC
12+
LIMIT 50
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Explore nodes grouped by their module (first part of globalFqn)
2+
3+
MATCH (n:TS)
4+
WHERE n.globalFqn IS NOT NULL
5+
UNWIND labels(n) AS nodeLabel
6+
WITH replace(split(n.globalFqn, '".')[0],'"', '') AS module
7+
,collect(split(n.globalFqn, '".')[1]) AS symbols
8+
,nodeLabel
9+
,count(DISTINCT n) as numberOfNodes
10+
WHERE nodeLabel <> 'TS'
11+
RETURN module
12+
,collect(DISTINCT nodeLabel) AS nodeLabels
13+
,sum(numberOfNodes) AS numberOfNodes
14+
,collect(symbols[0..4]) AS symbolExamples
15+
ORDER BY module ASC
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Explore nodes grouped by their module (first part of globalFqn) and their type of contained symbols
2+
3+
MATCH (n:TS)
4+
WHERE n.globalFqn IS NOT NULL
5+
UNWIND labels(n) AS nodeLabel
6+
WITH replace(split(n.globalFqn, '".')[0],'"', '') AS module
7+
,collect(split(n.globalFqn, '".')[1]) AS symbols
8+
,nodeLabel
9+
,count(DISTINCT n) as numberOfNodes
10+
WHERE nodeLabel <> 'TS'
11+
RETURN module
12+
,collect(DISTINCT nodeLabel) as nodeLabels
13+
,numberOfNodes
14+
,symbols[0..4] AS symbolExamples
15+
ORDER BY module ASC
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Explore node properties, the labels of their nodes and their count
2+
3+
MATCH (n)
4+
UNWIND keys(n) AS nodePropertyName
5+
UNWIND labels(n) AS nodeLabel
6+
RETURN nodePropertyName
7+
,collect(DISTINCT nodeLabel) AS nodeLabels
8+
,count(DISTINCT n) AS numberOfNodes
9+
,count(DISTINCT n[nodePropertyName]) AS numberOfDistinctValues
10+
,collect(DISTINCT n[nodePropertyName])[0..4] AS exampleValues
11+
ORDER BY nodePropertyName
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Get all relationships of one specific node to explore the schema
2+
3+
MATCH (s:TS:Module)-[r]->(t)
4+
RETURN labels(s) AS sourceLabels
5+
,keys(s) AS sourceKeys
6+
,labels(t) AS targetLabels
7+
,keys(t) AS targetKeys
8+
,type(r) AS relationshipType
9+
,keys(r) AS relationshipKeys
10+
,count(*) AS numberOfNodes
11+
ORDER BY sourceLabels, targetLabels, relationshipKeys

0 commit comments

Comments
 (0)