apoc.node.relationship.types

Details

Syntax

apoc.node.relationship.types(node [, relTypes ])

Description

Returns a LIST<STRING> of distinct RELATIONSHIP types for the given NODE.

Arguments

Name

Type

Description

node

NODE

The node to return the connected relationship types from.

relTypes

STRING

If not empty, provides an allow list of relationship types to be returned. Relationship types are represented using APOC’s rel-direction-pattern syntax; [<]RELATIONSHIP_TYPE1[>]|[<]RELATIONSHIP_TYPE2[>]|…​. The default is: ``.

Returns

LIST<ANY>

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

MATCH (p1:Person {name: "Person30"})
RETURN apoc.node.relationship.types(p1) AS output;
Results
output

["KNOWS", "FOLLOWS"]

MATCH (p1:Person {name: "Person30"})
RETURN apoc.node.relationship.types(p1, "FOLLOWS") AS output;
Results
output

["FOLLOWS"]