apoc.node.degree.out

Details

Syntax

apoc.node.degree.out(node [, relTypes ])

Description

Returns the total number of outgoing RELATIONSHIP values from the given NODE.

Arguments

Name

Type

Description

node

NODE

The node for which to count the total number of outgoing relationships.

relTypes

STRING

The relationship type to restrict the count to. The default is: ``.

Returns

INTEGER

Usage Examples

The examples in this section are based on the following sample graph:

MERGE (michael:Person {name: "Michael"})
WITH michael
CALL {
    WITH michael
    UNWIND range(0, 100) AS id
    MERGE (p:Person {name: "Person" + id})
    MERGE (michael)-[:KNOWS]-(p)
    RETURN count(*) AS friends
}

CALL {
    WITH michael
    UNWIND range(0, 50) AS id
    MERGE (p:Person {name: "Person" + id})
    MERGE (michael)-[:FOLLOWS]-(p)
    RETURN count(*) AS follows
}

RETURN friends, follows;
Results
friends follows

101

51

apoc.node.degree.out
MATCH (p:Person {name: "Person1"})
RETURN apoc.node.degree.out(p) AS output
Using Cypher’s COUNT subquery and pattern matching
MATCH (p:Person {name: "Person1"})
RETURN COUNT { (p)-->() } AS output
Results
output

0

apoc.node.degree.out
MATCH (p:Person {name: "Michael"})
RETURN apoc.node.degree.out(p) AS output
Using Cypher’s COUNT subquery and pattern matching
MATCH (p:Person {name: "Michael"})
RETURN COUNT { (p)-->() } AS output
Results
output

152

apoc.node.degree.out
MATCH (p:Person {name: "Michael"})
RETURN apoc.node.degree.out(p, "KNOWS") AS output
Using Cypher’s COUNT subquery and pattern matching
MATCH (p:Person {name: "Michael"})
RETURN COUNT { (p)-[:KNOWS]->() } AS output
Results
output

101