I am trying to do multi-hop contact tracing in a fictive location-based social network where people can make check-ins to places. I want to find people who make check-ins to a place where a proven infected user (130314) already made check-in. I want to continue the process down the path of check-ins to find out people in the path, but in a temporally ascending order. How can I write the query in a way that middle check-ins are temporally ascending (or descending). This is the code I wrote before and the result:
match p=((up:User{un:"130314"})-[r:CHECKIN*1..6]-(uc:User))
WITH head(relationships(p))as rf,last(relationships(p))as rl,p
WHERE all(rm in relationships(p)
WHERE rm.time.day = 5 AND duration.inSeconds(rf.time, rm.time).seconds <= 10800 AND rl.time > rf.time AND NOT rm.time < rf.time)
return p
