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
1 parent
3036de3
commit 8503c01
Showing
2 changed files
with
7 additions
and
29 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
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,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 |