1+ // Create filtered Type node projection without zero-degree nodes, external types, java types or duplicates. Variables: dependencies_projection
2+
3+ MATCH (internalType :Type )
4+ OPTIONAL MATCH (internalType )- [ typeDependency : DEPENDS_ON ] -> (dependentType :Type )
5+ WITH internalType
6+ ,typeDependency
7+ ,dependentType
8+ ,(NOT internalType .fqn CONTAINS '.' ) AS isPrimitiveInternalType
9+ ,(internalType .fqn STARTS WITH 'java.' ) AS isJavaInternalType
10+ ,exists ((internalType )- [ : RESOLVES_TO ] -> (:Type )) AS isDuplicateInternalType
11+ ,'ExternalType' in labels (internalType ) AS isExternalInternalType
12+ ,exists ((internalType )- [ : DEPENDS_ON ] -> (:Type )) AS hasOutgoingDependenciesInternal
13+ ,exists ((internalType )<- [ : DEPENDS_ON ] - (:Type )) AS hasIncomingDependenciesInternal
14+ ,(NOT dependentType .fqn CONTAINS '.' ) AS isPrimitiveTargetType
15+ ,(dependentType .fqn STARTS WITH 'java.' ) AS isJavaTargetType
16+ ,exists ((dependentType )- [ : RESOLVES_TO ] -> (:Type )) AS isDuplicateTargetType
17+ ,'ExternalType' in labels (dependentType ) AS isExternalTargetType
18+ ,exists ((dependentType )- [ : DEPENDS_ON ] -> (:Type )) AS hasOutgoingDependenciesTarget
19+ ,exists ((dependentType )<- [ : DEPENDS_ON ] - (:Type )) AS hasIncomingDependenciesTarget
20+ WHERE NOT isPrimitiveInternalType
21+ AND NOT isJavaInternalType
22+ AND NOT isDuplicateInternalType
23+ AND NOT isExternalInternalType
24+ AND (hasOutgoingDependenciesInternal OR hasIncomingDependenciesInternal )
25+ AND NOT isPrimitiveTargetType
26+ AND NOT isJavaTargetType
27+ AND NOT isDuplicateTargetType
28+ AND NOT isExternalTargetType
29+ AND (hasOutgoingDependenciesTarget OR hasIncomingDependenciesTarget )
30+ WITH gds .graph .project ($dependencies_projection + '-cleaned2' , internalType , dependentType , {
31+ sourceNodeProperties : internalType {.incomingDependencies , .outgoingDependencies }
32+ ,targetNodeProperties : dependentType { .incomingDependencies , .outgoingDependencies }
33+ ,relationshipProperties : typeDependency { .weight }
34+ ,relationshipType : 'DEPENDS_ON'
35+ }
36+ ) AS projection
37+ RETURN projection .graphName AS graphName
38+ ,projection .nodeCount AS nodeCount
39+ ,projection .relationshipCount AS relationshipCount
40+ ,projection .projectMillis AS projectMillis
0 commit comments