

{"id":348,"date":"2021-12-07T11:22:37","date_gmt":"2021-12-07T10:22:37","guid":{"rendered":"https:\/\/project.inria.fr\/tcypher\/?page_id=348"},"modified":"2021-12-07T11:29:10","modified_gmt":"2021-12-07T10:29:10","slug":"transitive-friendship","status":"publish","type":"page","link":"https:\/\/project.inria.fr\/tcypher\/transitive-friendship\/","title":{"rendered":"Transitive friendship"},"content":{"rendered":"<p>Return pairs of users who became friends after a sequence of paiwise transitive friendships between intermediate users.<\/p>\n<p><a href=\"https:\/\/project.inria.fr\/tcypher\/files\/2021\/12\/query_2-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-325 size-large aligncenter\" src=\"https:\/\/project.inria.fr\/tcypher\/files\/2021\/12\/query_2-1-1024x576.png\" alt=\"\" width=\"900\" height=\"506\" srcset=\"https:\/\/project.inria.fr\/tcypher\/files\/2021\/12\/query_2-1-1024x576.png 1024w, https:\/\/project.inria.fr\/tcypher\/files\/2021\/12\/query_2-1-300x169.png 300w, https:\/\/project.inria.fr\/tcypher\/files\/2021\/12\/query_2-1-768x432.png 768w, https:\/\/project.inria.fr\/tcypher\/files\/2021\/12\/query_2-1-150x84.png 150w, https:\/\/project.inria.fr\/tcypher\/files\/2021\/12\/query_2-1.png 1280w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n<h5>T-Cypher query:<\/h5>\n<p style=\"padding-left: 30px;\"><span style=\"color: #000000;\"><strong>RANGE_SLICE<\/strong> <\/span>[2010-01-01T08:01:01Z; 2013-01-01T08:01:01Z] <span style=\"color: #000000;\"><strong>ON R<\/strong><\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #000000;\"><strong>MATCH<\/strong><\/span> (p1:Person) \u2013[<span style=\"color: #000000;\"><strong>PAIR-CONTINUOUS<\/strong><\/span>(path:knows*2..7)]-&gt;(p2:Person)<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #000000;\"><strong>RETURN<\/strong><\/span> p1, p2, <span style=\"color: #000000;\"><strong>DURATION<\/strong><\/span>(path@T)<\/p>\n<hr \/>\n<h5>Interpretation:<\/h5>\n<p>In this query, a temporal path of type pairwise-continuous is used to indicate that A became friends with B then B became friends with C while the friendship AB is still valid. The same reasoning holds for relationships BC and CD. A friendship between B and C is first established, and lead to a frienship between C and D.<\/p>\n<p>It can be noticed that Cypher query is more verbose than the original T-Cypher query. That is, the translation consists of decomposing the T-Cypher query into 6 subqueries such as each sub query represents the original query but with a fixed length falling between 2 and 7. Then, each subquery is then translated based on the translation rules of queries with rigid patterns (fixed length).<\/p>\n<hr \/>\n<h5>Cypher query:<\/h5>\n<p style=\"padding-left: 30px;\">MATCH (p1:`Person`)-[r0:`knows`]-&gt;(n0)-[r1:`knows`]-&gt;(p2:`Person`) WHERE (((myFunctions.min([r0.tEnd, 1357027261000]) &#8211; myFunctions.max([r0.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r1.tEnd, 1357027261000]) &#8211; myFunctions.max([r1.tStart, 1262332861000])) &gt; 0) AND r0.tStart &lt; r1.tStart AND r0.tEnd &gt; r1.tStart AND r0.tEnd &lt; r1.tEnd) RETURN p1, p2, myFunctions.duration([myFunctions.min([r0.tStart, r1.tStart]), myFunctions.max([r0.tEnd, r1.tEnd])]) AS `DURATION(path@T)`<\/p>\n<p style=\"padding-left: 30px;\">UNION<\/p>\n<p style=\"padding-left: 30px;\">MATCH (p1:`Person`)-[r0:`knows`]-&gt;(n0)-[r1:`knows`]-&gt;(n1)-[r2:`knows`]-&gt;(p2:`Person`) WHERE (((myFunctions.min([r0.tEnd, 1357027261000]) &#8211; myFunctions.max([r0.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r1.tEnd, 1357027261000]) &#8211; myFunctions.max([r1.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r2.tEnd, 1357027261000]) &#8211; myFunctions.max([r2.tStart, 1262332861000])) &gt; 0) AND r0.tStart &lt; r1.tStart AND r0.tEnd &gt; r1.tStart AND r0.tEnd &lt; r1.tEnd AND r1.tStart &lt; r2.tStart AND r1.tEnd &gt; r2.tStart AND r1.tEnd &lt; r2.tEnd) RETURN p1, p2, myFunctions.duration([myFunctions.min([r0.tStart, r1.tStart, r2.tStart]), myFunctions.max([r0.tEnd, r1.tEnd, r2.tEnd])]) AS `DURATION(path@T)`<\/p>\n<p style=\"padding-left: 30px;\">UNION<\/p>\n<p style=\"padding-left: 30px;\">MATCH (p1:`Person`)-[r0:`knows`]-&gt;(n0)-[r1:`knows`]-&gt;(n1)-[r2:`knows`]-&gt;(n2)-[r3:`knows`]-&gt;(p2:`Person`) WHERE (((myFunctions.min([r0.tEnd, 1357027261000]) &#8211; myFunctions.max([r0.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r1.tEnd, 1357027261000]) &#8211; myFunctions.max([r1.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r2.tEnd, 1357027261000]) &#8211; myFunctions.max([r2.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r3.tEnd, 1357027261000]) &#8211; myFunctions.max([r3.tStart, 1262332861000])) &gt; 0) AND r0.tStart &lt; r1.tStart AND r0.tEnd &gt; r1.tStart AND r0.tEnd &lt; r1.tEnd AND r1.tStart &lt; r2.tStart AND r1.tEnd &gt; r2.tStart AND r1.tEnd &lt; r2.tEnd AND r2.tStart &lt; r3.tStart AND r2.tEnd &gt; r3.tStart AND r2.tEnd &lt; r3.tEnd) RETURN p1, p2, myFunctions.duration([myFunctions.min([r0.tStart, r1.tStart, r2.tStart, r3.tStart]), myFunctions.max([r0.tEnd, r1.tEnd, r2.tEnd, r3.tEnd])]) AS `DURATION(path@T)`<\/p>\n<p style=\"padding-left: 30px;\">UNION<\/p>\n<p style=\"padding-left: 30px;\">MATCH (p1:`Person`)-[r0:`knows`]-&gt;(n0)-[r1:`knows`]-&gt;(n1)-[r2:`knows`]-&gt;(n2)-[r3:`knows`]-&gt;(n3)-[r4:`knows`]-&gt;(p2:`Person`) WHERE (((myFunctions.min([r0.tEnd, 1357027261000]) &#8211; myFunctions.max([r0.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r1.tEnd, 1357027261000]) &#8211; myFunctions.max([r1.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r2.tEnd, 1357027261000]) &#8211; myFunctions.max([r2.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r3.tEnd, 1357027261000]) &#8211; myFunctions.max([r3.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r4.tEnd, 1357027261000]) &#8211; myFunctions.max([r4.tStart, 1262332861000])) &gt; 0) AND r0.tStart &lt; r1.tStart AND r0.tEnd &gt; r1.tStart AND r0.tEnd &lt; r1.tEnd AND r1.tStart &lt; r2.tStart AND r1.tEnd &gt; r2.tStart AND r1.tEnd &lt; r2.tEnd AND r2.tStart &lt; r3.tStart AND r2.tEnd &gt; r3.tStart AND r2.tEnd &lt; r3.tEnd AND r3.tStart &lt; r4.tStart AND r3.tEnd &gt; r4.tStart AND r3.tEnd &lt; r4.tEnd) RETURN p1, p2, myFunctions.duration([myFunctions.min([r0.tStart, r1.tStart, r2.tStart, r3.tStart, r4.tStart]), myFunctions.max([r0.tEnd, r1.tEnd, r2.tEnd, r3.tEnd, r4.tEnd])]) AS `DURATION(path@T)`<\/p>\n<p style=\"padding-left: 30px;\">UNION<\/p>\n<p style=\"padding-left: 30px;\">MATCH (p1:`Person`)-[r0:`knows`]-&gt;(n0)-[r1:`knows`]-&gt;(n1)-[r2:`knows`]-&gt;(n2)-[r3:`knows`]-&gt;(n3)-[r4:`knows`]-&gt;(n4)-[r5:`knows`]-&gt;(p2:`Person`) WHERE (((myFunctions.min([r0.tEnd, 1357027261000]) &#8211; myFunctions.max([r0.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r1.tEnd, 1357027261000]) &#8211; myFunctions.max([r1.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r2.tEnd, 1357027261000]) &#8211; myFunctions.max([r2.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r3.tEnd, 1357027261000]) &#8211; myFunctions.max([r3.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r4.tEnd, 1357027261000]) &#8211; myFunctions.max([r4.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r5.tEnd, 1357027261000]) &#8211; myFunctions.max([r5.tStart, 1262332861000])) &gt; 0) AND r0.tStart &lt; r1.tStart AND r0.tEnd &gt; r1.tStart AND r0.tEnd &lt; r1.tEnd AND r1.tStart &lt; r2.tStart AND r1.tEnd &gt; r2.tStart AND r1.tEnd &lt; r2.tEnd AND r2.tStart &lt; r3.tStart AND r2.tEnd &gt; r3.tStart AND r2.tEnd &lt; r3.tEnd AND r3.tStart &lt; r4.tStart AND r3.tEnd &gt; r4.tStart AND r3.tEnd &lt; r4.tEnd AND r4.tStart &lt; r5.tStart AND r4.tEnd &gt; r5.tStart AND r4.tEnd &lt; r5.tEnd) RETURN p1, p2, myFunctions.duration([myFunctions.min([r0.tStart, r1.tStart, r2.tStart, r3.tStart, r4.tStart, r5.tStart]), myFunctions.max([r0.tEnd, r1.tEnd, r2.tEnd, r3.tEnd, r4.tEnd, r5.tEnd])]) AS `DURATION(path@T)`<\/p>\n<p style=\"padding-left: 30px;\">UNION<\/p>\n<p style=\"padding-left: 30px;\">MATCH (p1:`Person`)-[r0:`knows`]-&gt;(n0)-[r1:`knows`]-&gt;(n1)-[r2:`knows`]-&gt;(n2)-[r3:`knows`]-&gt;(n3)-[r4:`knows`]-&gt;(n4)-[r5:`knows`]-&gt;(n5)-[r6:`knows`]-&gt;(p2:`Person`) WHERE (((myFunctions.min([r0.tEnd, 1357027261000]) &#8211; myFunctions.max([r0.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r1.tEnd, 1357027261000]) &#8211; myFunctions.max([r1.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r2.tEnd, 1357027261000]) &#8211; myFunctions.max([r2.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r3.tEnd, 1357027261000]) &#8211; myFunctions.max([r3.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r4.tEnd, 1357027261000]) &#8211; myFunctions.max([r4.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r5.tEnd, 1357027261000]) &#8211; myFunctions.max([r5.tStart, 1262332861000])) &gt; 0 OR (myFunctions.min([r6.tEnd, 1357027261000]) &#8211; myFunctions.max([r6.tStart, 1262332861000])) &gt; 0) AND r0.tStart &lt; r1.tStart AND r0.tEnd &gt; r1.tStart AND r0.tEnd &lt; r1.tEnd AND r1.tStart &lt; r2.tStart AND r1.tEnd &gt; r2.tStart AND r1.tEnd &lt; r2.tEnd AND r2.tStart &lt; r3.tStart AND r2.tEnd &gt; r3.tStart AND r2.tEnd &lt; r3.tEnd AND r3.tStart &lt; r4.tStart AND r3.tEnd &gt; r4.tStart AND r3.tEnd &lt; r4.tEnd AND r4.tStart &lt; r5.tStart AND r4.tEnd &gt; r5.tStart AND r4.tEnd &lt; r5.tEnd AND r5.tStart &lt; r6.tStart AND r5.tEnd &gt; r6.tStart AND r5.tEnd &lt; r6.tEnd) RETURN p1, p2, myFunctions.duration([myFunctions.min([r0.tStart, r1.tStart, r2.tStart, r3.tStart, r4.tStart, r5.tStart, r6.tStart]), myFunctions.max([r0.tEnd, r1.tEnd, r2.tEnd, r3.tEnd, r4.tEnd, r5.tEnd, r6.tEnd])]) AS `DURATION(path@T)`<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Return pairs of users who became friends after a sequence of paiwise transitive friendships between intermediate users. T-Cypher query: RANGE_SLICE [2010-01-01T08:01:01Z; 2013-01-01T08:01:01Z] ON R MATCH (p1:Person) \u2013[PAIR-CONTINUOUS(path:knows*2..7)]-&gt;(p2:Person) RETURN p1, p2, DURATION(path@T) Interpretation: In this query, a temporal path of type pairwise-continuous is used to indicate that A became friends with\u2026<\/p>\n<p> <a class=\"continue-reading-link\" href=\"https:\/\/project.inria.fr\/tcypher\/transitive-friendship\/\"><span>Continue reading<\/span><i class=\"crycon-right-dir\"><\/i><\/a> <\/p>\n","protected":false},"author":2118,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-348","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/project.inria.fr\/tcypher\/wp-json\/wp\/v2\/pages\/348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/project.inria.fr\/tcypher\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/project.inria.fr\/tcypher\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/project.inria.fr\/tcypher\/wp-json\/wp\/v2\/users\/2118"}],"replies":[{"embeddable":true,"href":"https:\/\/project.inria.fr\/tcypher\/wp-json\/wp\/v2\/comments?post=348"}],"version-history":[{"count":3,"href":"https:\/\/project.inria.fr\/tcypher\/wp-json\/wp\/v2\/pages\/348\/revisions"}],"predecessor-version":[{"id":354,"href":"https:\/\/project.inria.fr\/tcypher\/wp-json\/wp\/v2\/pages\/348\/revisions\/354"}],"wp:attachment":[{"href":"https:\/\/project.inria.fr\/tcypher\/wp-json\/wp\/v2\/media?parent=348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}