forked from ldbc/ldbc_snb_interactive_v1_impls
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
MATCH (person:Person)-[:KNOWS*2]-(friend)-[:IS_LOCATED_IN]->(city:Place) | ||
WHERE id(person) == $personId AND id(friend) != $personId AND NOT (friend)-[:KNOWS]-(person) | ||
WITH person, city, friend, datetime({friend.Person.birthday}) as birthday | ||
WITH person, city, friend, datetime(friend.Person.birthday) as birthday | ||
WHERE (birthday.month==$month AND birthday.day>=21) OR | ||
(birthday.month==($month%12)+1 AND birthday.day<22) | ||
WITH DISTINCT friend, city, person | ||
OPTIONAL MATCH (friend)<-[:POST_HAS_CREATOR]-(post:Post) | ||
WITH friend, city, collect(post) AS posts, person | ||
OPTIONAL MATCH (person)-[:HAS_INTEREST]->()<-[:HAS_TAG]-(post) | ||
WITH friend, | ||
city, | ||
size(posts) AS postCount, | ||
size([p IN posts WHERE (p)-[:HAS_TAG]->()<-[:HAS_INTEREST]-(person)]) AS commonPostCount | ||
count(*) AS postCount, | ||
count(post) AS commonPostCount | ||
RETURN toInteger(substr(id(friend), 2)) AS personId, | ||
friend.Person.firstName AS personFirstName, | ||
friend.Person.lastName AS personLastName, | ||
commonPostCount - (postCount - commonPostCount) AS commonInterestScore, | ||
friend.Person.gender AS personGender, | ||
city.Place.name AS personCityName | ||
ORDER BY commonInterestScore DESC, personId ASC | ||
LIMIT 10 | ||
LIMIT 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
MATCH p = allShortestPaths((person1)-[:KNOWS*..15]-(person2)) | ||
WHERE id(person1) == $person1 and id(person2) == $person2 | ||
WITH nodes(p) AS pathNodes | ||
RETURN | ||
WITH | ||
[n IN pathNodes | id(n)] AS personIdsInPath, | ||
reduce(weight=0.0, idx IN range(1,size(pathNodes)-1) | [prev IN [pathNodes[idx-1]] | [curr IN [pathNodes[idx]] | weight + size((curr)<-[:COMMENT_HAS_CREATOR]-(:`Comment`)-[:REPLY_OF_POST]->(:Post)-[:POST_HAS_CREATOR]->(prev))*1.0 + size((prev)<-[:COMMENT_HAS_CREATOR]-(:`Comment`)-[:REPLY_OF_POST]->(:Post)-[:POST_HAS_CREATOR]->(curr))*1.0 + size((prev)-[:COMMENT_HAS_CREATOR]-(:`Comment`)-[:REPLY_OF_COMMENT]-(:`Comment`)-[:COMMENT_HAS_CREATOR]-(curr))*0.5] ][0][0]) AS pathWight | ||
ORDER BY pathWight DESC | ||
[idx IN range(1, size(pathNodes)-1) | [prev IN [pathNodes[idx-1]] | [curr IN [pathNodes[idx]] | [prev, curr]]]] AS vertList | ||
UNWIND vertList AS c | ||
WITH c[0][0][0] AS prev, c[0][0][1] AS curr, personIdsInPath | ||
MATCH (curr)<-[:COMMENT_HAS_CREATOR]-(:`Comment`)-[:REPLY_OF_POST]->(:Post)-[:POST_HAS_CREATOR]->(prev) | ||
WITH count(*) AS cnt1, prev, curr, personIdsInPath | ||
MATCH (prev)<-[:COMMENT_HAS_CREATOR]-(:`Comment`)-[:REPLY_OF_POST]->(:Post)-[:POST_HAS_CREATOR]->(curr) | ||
WITH count(*) AS cnt2, cnt1, prev, curr, personIdsInPath | ||
MATCH (prev)-[:COMMENT_HAS_CREATOR]-(:`Comment`)-[:REPLY_OF_COMMENT]-(:`Comment`)-[:COMMENT_HAS_CREATOR]-(curr) | ||
WITH count(*) AS cnt3, cnt1, cnt2, personIdsInPath | ||
RETURN personIdsInPath, sum(cnt1 + cnt2 + 0.5 * cnt3) AS pathWeight | ||
ORDER BY pathWeight DESC |