apoc.meta.nodes.count
Function APOC Core
apoc.meta.nodes.count([labels], $config) - Returns the sum of the nodes with a label present in the list.
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 | relationships |
---|
We can return all nodes with a label MyCountLabel
and a relationship MY_COUNT_REL
through the config param includeRels
RETURN apoc.meta.nodes.count(['MyCountLabel'], {includeRels: ['MY_COUNT_REL']}) AS count;
count | relationships |
---|
Moreover, we can return all nodes with a outcome
relationship MY_COUNT_REL
(with the suffix >
):
RETURN apoc.meta.nodes.count(['MyCountLabel'], {includeRels: ['MY_COUNT_REL>']}) AS count;
count | relationships |
---|
otherwise with an incoming
relationship MY_COUNT_REL
(with the suffix <
):
RETURN apoc.meta.nodes.count(['MyCountLabel'], {includeRels: ['MY_COUNT_REL<']}) AS count;
count | relationships |
---|