Let say I have a nodes with values a multiples of 10. I want to find the first GAP in the values. Here is how I would do it in numpy :
> np.where(np.diff([11,21,31,51,61,71,91]) > 10)[0][0] + 2
> 4 i.e. 41
How would I do this in Cypher... ?
match (n) where n.val % 10 = 1
with n.val
order by val ....???
I'm using RedisGraph.
PS> if no GAP it should return the next value i.e. biggest + 10, if possible !
I'm not sure if this is the most performant solution, but you can accomplish this using a combination of
collect()
and list comprehensions:To additionally return the next-biggest value if no gaps are found, change the RETURN clause to use a CASE statement: