forked from gaolk/graph-database-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpg-twitter-distributed.gsql
executable file
·31 lines (26 loc) · 1.3 KB
/
pg-twitter-distributed.gsql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use graph twitter
drop query pagerank
CREATE DISTRIBUTED QUERY pagerank (int iteration, float dampingFactor)
FOR GRAPH twitter
{
# In each iteration, compute a score for each vertex:
# score = dampingFactor + (1-dampingFactor)* sum(received scores from its neighbors).
# The pageRank algorithm stops after running iteration iterations
# This implementation is based on https://graphsql.atlassian.net/wiki/display/UGH/Query+Example%3A+PageRank
# To only measure the execution time, we do not print a large number of results. only the max difference is returned
MaxAccum<float> @@maxDifference = 3.1415926;
SumAccum<float> @received_score = 0; # sum of scores each vertex receives from neighbors
SumAccum<float> @score = 1; # initial score for every vertex is 1.
AllV = {MyNode.*}; # Start with all vertices of type Page
WHILE TRUE LIMIT iteration DO
#@@maxDifference = 0;
AllV = SELECT s
FROM AllV:s-(MyEdge)->:t
ACCUM t.@received_score += s.@score/s.outdegree()
POST-ACCUM t.@score = dampingFactor + (1-dampingFactor) * t.@received_score,
t.@received_score = 0;
#@@maxDifference += abs(t.@score - t.@score');
END; # end while loop
PRINT @@maxDifference; # print the results
} # end query
install query pagerank