Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-06-2021 02:00 AM
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
12-06-2021 02:53 PM
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
All the sessions of the conference are now available online