Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ic14 #50

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nebula/queries/interactive-complex-10.ngql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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({epochMillis: 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
Expand Down
34 changes: 6 additions & 28 deletions nebula/queries/interactive-complex-14.ngql
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
MATCH p = allShortestPaths((person1:Person)-[:KNOWS*0..10]-(person2:Person))
WHERE id(person1) == $person1Id AND id(person2) == $person2Id
WITH collect(p) as paths
UNWIND paths as path1
WITH path1, relationships(path1) as rels_in_path
WITH
[n in nodes(path1) | id(n) ] as personIdsInPath,
[r in rels_in_path |
reduce(w=0.0, v in [
(a:Person)<-[:HAS_CREATOR]-(:Comment)-[:REPLY_OF]->(:Post)-[:HAS_CREATOR]->(b:Person)
WHERE
(id(a) == id(startNode(r)) and id(b) == id(endNode(r))) OR (id(a)== id(endNode(r)) and id(b) == id(startNode(r)))
| 1.0] | w+v)
] as weight1,
[r in rels_in_path |
reduce(w=0.0,v in [
(a:Person)<-[:HAS_CREATOR]-(:Comment)-[:REPLY_OF]->(:Comment)-[:HAS_CREATOR]->(b:Person)
WHERE
(id(a) == id(startNode(r)) and id(b) == id(endNode(r))) OR (id(a)== id(endNode(r)) and id(b) == id(startNode(r)))
| 0.5] | w+v)
] as weight2
WITH
personIdsInPath,
reduce(w=0.0,v in weight1| w+v) as w1,
reduce(w=0.0,v in weight2| w+v) as w2
MATCH p = allShortestPaths((person1)-[:KNOWS*..15]-(person2))
WHERE id(person1) == $person1 and id(person2) == $person2
WITH nodes(p) AS pathNodes
RETURN
personIdsInPath,
(w1+w2) as pathWeight
ORDER BY pathWeight desc
[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