apoc.meta.nodes.count
Function
apoc.meta.nodes.count(nodes LIST<STRING>, config MAP<STRING, ANY>)
- returns the sum of the NODE
values with the given labels in the LIST<STRING>
.
This function is not considered safe to run from multiple threads. It is therefore not supported by the parallel runtime (introduced in Neo4j 5.13). For more information, see the Cypher Manual → Parallel runtime. |
Config parameters
This procedure supports the following config parameters:
Name | Type | Default | Description |
---|---|---|---|
includeRels |
LIST<STRING> |
[] |
Relationship types to include. Default is to include all relationship types.
Add the suffix |
Name | Type | Default | Description |
---|---|---|---|
rels |
LIST<STRING> |
[] |
deprecated, use |
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (n:MyCountLabel {id: 1}), (:MyCountLabel {id: 2}), (m:ThirdLabel {id: 3})
WITH n,m
CREATE (n)-[:MY_COUNT_REL]->(m), (n)-[:ANOTHER_MY_COUNT_REL]->(m), (n)<-[:ANOTHER_MY_COUNT_REL]-(m)
We can return all nodes with a label MyCountLabel
or a label ThirdLabel
RETURN apoc.meta.nodes.count(['MyCountLabel', 'ThirdLabel']) AS count;
count |
---|
3 |
The following example returns all nodes with a label MyCountLabel
and a relationship MY_COUNT_REL
through the config parameter includeRels
:
RETURN apoc.meta.nodes.count(['MyCountLabel'], {includeRels: ['MY_COUNT_REL']}) AS count;
count |
---|
1 |
The following example returns all nodes with an outgoing relationship MY_COUNT_REL
(with the suffix >
):
RETURN apoc.meta.nodes.count(['MyCountLabel'], {includeRels: ['MY_COUNT_REL>']}) AS count;
count |
---|
1 |
The following example returns all nodes with an incoming relationship MY_COUNT_REL
(with the suffix <
):
RETURN apoc.meta.nodes.count(['MyCountLabel'], {includeRels: ['MY_COUNT_REL<']}) AS count;
count |
---|
0 |