apoc.node.relationship.exists
Syntax |
|
||
Description |
Returns a |
||
Arguments |
Name |
Type |
Description |
|
|
The node to check for the specified relationship types. |
|
|
|
The relationship types to check for on the given node. Relationship types are represented using APOC’s rel-direction-pattern syntax; |
|
Returns |
|
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;
friends | follows |
---|---|
101 |
51 |
apoc.node.relationship.exists
MATCH (p1:Person {name: "Michael"})
RETURN apoc.node.relationship.exists(p1) AS output;
Using Cypher’s EXISTS {}
MATCH (p1:Person {name: "Michael"})
RETURN EXISTS {
(p1)--()
} AS output
output |
---|
true |
apoc.node.relationship.exists
MATCH (p1:Person {name: "Person40"})
RETURN apoc.node.relationship.exists(p1, "FOLLOWS>") AS output;
Using Cypher’s EXISTS {}
MATCH (p1:Person {name: "Person40"})
RETURN EXISTS {
(p1)-[:FOLLOWS]->()
} AS output
output |
---|
false |
apoc.node.relationship.exists
MATCH (p1:Person {name: "Person40"})
RETURN apoc.node.relationship.exists(p1, "<FOLLOWS") AS output;
Using Cypher’s EXISTS {}
MATCH (p1:Person {name: "Person40"})
RETURN EXISTS {
(p1)<-[:FOLLOWS]-()
} AS output
output |
---|
true |