Skip to content

Commit

Permalink
fix ic14 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Nov 23, 2022
1 parent 3036de3 commit 8503c01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
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

0 comments on commit 8503c01

Please sign in to comment.