cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-hop traverse for contact tracing considering descending temporal property values

GeoMahdi
Node

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

3X_8_0_80ac180644e75f4fca07ed87330bc2997eb09cd4.png

1 REPLY 1

At this time the filtering will be post-expansion. APOC functions will be used for getting adjacent relationships:

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)
// ensure each adjacent pair of rels is temporally ascending
WITH p, apoc.coll.pairsMin(relationships(p)) as adjacentRels
WHERE all(pair IN adjacentRels WHERE pair[0].time <= pair[1].time)
RETURN p