apoc.nodes.relationship.types
Function
apoc.nodes.relationship.types(nodes ANY, types STRING)
- returns a LIST<STRING>
of distinct RELATIONSHIP
types from the given LIST<NODE>
values.
Input parameters
Name | Type | Default | Description |
---|---|---|---|
nodes |
ANY |
null |
|
types |
STRING |
"" |
If not empty, provides an allow list of the |
Output parameters
Name | Type | Description |
---|---|---|
value |
LIST<MAP> |
A |
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 |
MATCH (p1:Person)
WHERE p1.name IN ["Michael", "Person30", "Person60"]
WITH collect(p1) AS people
UNWIND apoc.nodes.relationship.types(people, "KNOWS>|FOLLOWS") AS output
RETURN output;
output |
---|
{node: (:Person {name: "Michael"}), types: ["KNOWS", "FOLLOWS"]} |
{node: (:Person {name: "Person30"}), types: ["FOLLOWS"]} |
{node: (:Person {name: "Person60"}), types: []} |