Skip to content

Commit b5ce907

Browse files
committed
Add general overview with node and relationship types
1 parent 8d70d7f commit b5ce907

File tree

6 files changed

+773
-0
lines changed

6 files changed

+773
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Node count for each label combination. Sums up to the total number of nodes.
2+
3+
MATCH (allNodes)
4+
WITH COUNT(allNodes) AS totalNodeCount
5+
MATCH (nodesAndTheirLabels)
6+
WITH totalNodeCount
7+
,labels(nodesAndTheirLabels) AS nodeLabels
8+
,nodesAndTheirLabels
9+
UNWIND nodeLabels AS nodeLabel
10+
WITH totalNodeCount
11+
,nodeLabel
12+
,nodesAndTheirLabels
13+
WHERE NOT nodeLabel STARTS WITH 'Mark4'
14+
WITH totalNodeCount
15+
,collect(nodeLabel) AS nodeLabels
16+
,nodesAndTheirLabels
17+
WITH totalNodeCount
18+
,nodeLabels
19+
,count(nodesAndTheirLabels) AS nodesWithThatLabels
20+
,toFloat(count(nodesAndTheirLabels)) / totalNodeCount * 100.0 AS nodesWithThatLabelsPercent
21+
RETURN nodeLabels, nodesWithThatLabels, nodesWithThatLabelsPercent
22+
ORDER BY nodesWithThatLabels DESC
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Node count for each label separate. Doesn_t sum up to the number of total labels since one node can have multiple labels.
2+
3+
MATCH (allNodes)
4+
WITH COUNT(allNodes) AS totalNodeCount
5+
MATCH (nodesAndTheirLabels)
6+
WITH totalNodeCount
7+
,labels(nodesAndTheirLabels) AS nodeLabels
8+
,nodesAndTheirLabels
9+
UNWIND nodeLabels AS nodeLabel
10+
WITH totalNodeCount
11+
,nodeLabel
12+
,count(nodesAndTheirLabels) AS nodesWithThatLabel
13+
,toFloat(count(nodesAndTheirLabels)) / totalNodeCount * 100.0 AS nodesWithThatLabelPercent
14+
WHERE NOT nodeLabel STARTS WITH 'Mark4'
15+
RETURN nodeLabel, nodesWithThatLabel, nodesWithThatLabelPercent
16+
ORDER BY nodesWithThatLabel DESC, nodeLabel ASC
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// List node labels and their relationship types, their count and their density.
2+
3+
MATCH (nodeByLabel)
4+
WITH labels(nodeByLabel) AS nodeLabels
5+
,collect(nodeByLabel) AS nodesWithThatLabels
6+
,count(nodeByLabel) AS numberOfNodesWithThatLabels
7+
UNWIND nodesWithThatLabels AS nodeWithThatLabels
8+
MATCH (nodeWithThatLabels)-[relation]->(target)
9+
WITH nodeLabels AS sourceLabels
10+
,numberOfNodesWithThatLabels AS numberOfNodesWithSameLabelsAsSource
11+
,type(relation) AS relationType
12+
,labels(target) AS targetLabels
13+
,count(DISTINCT relation) AS numberOfRelationships
14+
WITH sourceLabels
15+
,relationType
16+
,targetLabels
17+
,numberOfRelationships
18+
,numberOfNodesWithSameLabelsAsSource
19+
,count{ MATCH (targetWithLabel) WHERE labels(targetWithLabel) = targetLabels } AS numberOfNodesWithSameLabelsAsTarget
20+
RETURN sourceLabels
21+
,relationType
22+
,targetLabels
23+
,numberOfRelationships
24+
,numberOfNodesWithSameLabelsAsSource
25+
,numberOfNodesWithSameLabelsAsTarget
26+
,toFloat(numberOfRelationships)
27+
/ ( numberOfNodesWithSameLabelsAsSource * numberOfNodesWithSameLabelsAsTarget)
28+
* 100 AS densityInPercent
29+
ORDER BY numberOfRelationships DESC
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Relationship count for each type separate. Sums up to the total number of relationships (100%).
2+
3+
MATCH ()-[allRelationships]-()
4+
WITH COUNT(DISTINCT allRelationships) AS totalRelationshipCount
5+
MATCH ()-[relationshipsAndTheirTypes]-()
6+
WITH totalRelationshipCount
7+
,type(relationshipsAndTheirTypes) AS relationshipType
8+
,count(DISTINCT relationshipsAndTheirTypes) AS nodesWithThatRelationshipType
9+
,toFloat(
10+
count(DISTINCT relationshipsAndTheirTypes))
11+
/ totalRelationshipCount * 100.0 AS nodesWithThatRelationshipTypePercent
12+
RETURN relationshipType
13+
,nodesWithThatRelationshipType
14+
,nodesWithThatRelationshipTypePercent
15+
ORDER BY nodesWithThatRelationshipType DESC, relationshipType ASC

0 commit comments

Comments
 (0)