Function difference()
calculates the elements that exist in the 1st array but not in the 2nd array and returns them as a new array, namely, returns the difference of these two arrays (repeated elements are allowed in the difference).
Arguments:
- 1st array <array>
- 2nd array <array>
Returns:
- Difference <array>
If the two arrays are non-homologous, Cartesian Product will be applied when the function is called in a WITH clause, or aliases will be trimmed when called in a RETURN clause.
Common Usage
Example: Find the neighbors of Card CA001, and remove the nodes that are also neighbors of Card CA002, and return as array
khop().src({_id == "CA001"}).depth(1) as n1
khop().src({_id == "CA002"}).depth(1) as n2
with collect(n1) as a1, collect(n2) as a2
return difference(a1, a2)