ALL_DIFFERENT predicate¶
The ALL_DIFFERENT predicate checks if all graph elements in a list are pairwise different from one another.
Syntax¶
- all_different_predicate
all_different_predicate ::=
ALL_DIFFERENT '(' element_variable_reference (',' element_variable_reference)+ ')'
Parameters¶
element_variable_reference¶
The reference to a variable that represents a graph element that is checked for pairwise difference.
Examples¶
The following examples are based on the example dataset.
Check if all nodes are pairwise different¶
'''
USE movie
MATCH (v@Director)->(w@Movie), (n@Actor)->(m@Movie), (u@`User`)->(p@Movie)
WHERE NOT ALL_DIFFERENT(w, m, p)
RETURN element_id(w)=element_id(m) AS wm, element_id(w)=element_id(p) AS wp, element_id(m)=element_id(p) AS mp
LIMIT 1
'''
The preceding statement selects movies directed by directors, movies acted by actors, and movies rated by users, and then checks if these movies are pairwise different.
Return:
+-------+-------+------+
| wm | wp | mp |
+-------+-------+------+
| false | false | true |
+-------+-------+------+