Return pairs of users who became friends when studying at the same university.
T-Cypher query:
RIGHT_SLICE 2010-01-01T01:01:01Z ON R
MATCH (p1:Person)-[k:knows]-(p2:Person),
(p1)-[s1:studyIn]->(u:University)<-[s2:studyIn]-(p2)
WHERE s1@T EQUALS s2@T AND s2@T STARTS k@T
RETURN p1, p2
Interpretation:
The right slice indicates that the time intervals of all the relationship variables of the query should end after 2010-01-01T01:01:01Z. Expression ‘s1@T EQUALS s2@T’ indicates that both users studied during the same period of time in the same university. Whereas, expession s2@T STARTS k@T indicates that the friendship have started when both users started studying at the same university and continued to hold after graduation.
Cypher query:
MATCH (p1:`Person`)-[r0:`knows`]-(p2:`Person`),
(p1)-[r1:`studyIn`]->(u:`University`)<-[r2:`studyIn`]-(p2)
WHERE (r1.tStart = r2.tStart AND r1.tEnd = r2.tEnd AND k.tStart < s1.tEnd AND r0.tEnd >= 1262332800000 AND r1.tEnd >= 1262332800000 AND r2.tEnd >= 1262332800000)
RETURN p1, p2