0
votes

Lets say i have these nodes with these relations (A,B) are nodes and Rs are Relation Names:

A-R1->B
A-R2->B
A-R3->B

Now i do not actually know if one or any R has relation between these 2 nodes. how can i specify if any relation exists between these 2 nodes regardless of knowing what relation is it?

Also if there are any relation exists between these two nodes is it possible to know what relation is it?

1

1 Answers

2
votes

how can i specify if any relation exists between these 2 nodes regardless of knowing what relation is it?

I believe that a simple MATCH will be sufficient. The below query returns all relationships between a node named "A" and a node named "B", if exists.

MATCH ({name : "A"})-[r]->({name : "B"})
RETURN r

Also if there are any relation exists between these two nodes is it possible to know what relation is it?

The type() function returns a string representation of the relationship type. Then the below query will return the string representing the type of each relationship between A and B.

MATCH ({name : "A"})-[r]->({name : "B"})
RETURN type(r) as type