apoc.node.relationships.exist

Function APOC Core

apoc.node.relationships.exist(node, rel-direction-pattern) - returns a map with rel-pattern, boolean for the given relationship patterns

Signature

apoc.node.relationships.exist(node :: NODE?, types =  :: STRING?) :: (MAP?)

Input parameters

Name Type Default

node

NODE?

null

types

STRING?

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;
Table 1. Results
friends follows

101

51

MATCH (p1:Person {name: "Person60"})
RETURN apoc.node.relationships.exist(p1, "KNOWS|FOLLOWS") AS output;
Table 2. Results
output

{KNOWS: TRUE, FOLLOWS: FALSE}

MATCH (p1:Person {name: "Michael"})
RETURN apoc.node.relationships.exist(p1, "KNOWS>|<FOLLOWS") AS output;
Table 3. Results
output

{KNOWS>: TRUE, <FOLLOWS: FALSE}