Skip to content

Commit 80ffe0f

Browse files
committed
fmt
1 parent 15cf6dc commit 80ffe0f

File tree

3 files changed

+51
-56
lines changed

3 files changed

+51
-56
lines changed

Diff for: algorithms/Centrality/pagerank/global/unweighted/tg_pagerank.gsql

+49-55
Original file line numberDiff line numberDiff line change
@@ -50,65 +50,59 @@ CREATE QUERY tg_pagerank (STRING v_type, STRING e_type, FLOAT max_change=0.001,
5050
importance of traversal vs. random teleport
5151
*/
5252

53-
TYPEDEF TUPLE<VERTEX Vertex_ID, FLOAT score> Vertex_Score;
54-
HeapAccum<Vertex_Score>(top_k, score DESC) @@top_scores_heap;
55-
SetAccum<VERTEX> @@top_vertices; # vertices with top score
56-
MaxAccum<FLOAT> @@max_diff = 9999; # max score change in an iteration
57-
SumAccum<FLOAT> @sum_recvd_score = 0; # sum of scores each vertex receives FROM neighbors
58-
SumAccum<FLOAT> @sum_score = 1; # initial score for every vertex is 1.
59-
SetAccum<EDGE> @@edge_set; # list of all edges, if display is needed
60-
FILE f (file_path);
53+
TYPEDEF TUPLE<VERTEX Vertex_ID, FLOAT score> Vertex_Score;
54+
HeapAccum<Vertex_Score>(top_k, score DESC) @@top_scores_heap;
55+
SetAccum<VERTEX> @@top_vertices; # vertices with top score
56+
MaxAccum<FLOAT> @@max_diff = 9999; # max score change in an iteration
57+
SumAccum<FLOAT> @sum_recvd_score = 0; # sum of scores each vertex receives FROM neighbors
58+
SumAccum<FLOAT> @sum_score = 1; # initial score for every vertex is 1.
59+
SetAccum<EDGE> @@edge_set; # list of all edges, if display is needed
60+
FILE f (file_path);
6161

62-
# PageRank iterations
63-
Start = {v_type}; # Start with all vertices of specified type(s)
64-
WHILE @@max_diff > max_change
65-
LIMIT maximum_iteration DO
62+
# PageRank iterations
63+
Start = {v_type}; # Start with all vertices of specified type(s)
64+
WHILE @@max_diff > max_change LIMIT maximum_iteration DO
6665
@@max_diff = 0;
67-
V = SELECT s
68-
FROM Start:s -(e_type:e)- v_type:t
69-
ACCUM
70-
t.@sum_recvd_score += s.@sum_score/(s.outdegree(e_type))
71-
POST-ACCUM
72-
s.@sum_score = (1.0-damping) + damping * s.@sum_recvd_score,
73-
s.@sum_recvd_score = 0,
74-
@@max_diff += abs(s.@sum_score - s.@sum_score');
75-
END; # END WHILE loop
66+
V = SELECT s FROM Start:s -(e_type:e)- v_type:t
67+
ACCUM
68+
t.@sum_recvd_score += s.@sum_score/(s.outdegree(e_type))
69+
POST-ACCUM
70+
s.@sum_score = (1.0 - damping) + damping * s.@sum_recvd_score,
71+
s.@sum_recvd_score = 0,
72+
@@max_diff += abs(s.@sum_score - s.@sum_score');
73+
END; # END WHILE loop
7674

77-
# Output
78-
IF file_path != "" THEN
79-
f.println("Vertex_ID", "PageRank");
80-
END;
81-
V = SELECT s
82-
FROM Start:s
83-
POST-ACCUM
84-
IF result_attribute != "" THEN
85-
s.setAttr(result_attribute, s.@sum_score)
86-
END,
87-
88-
IF file_path != "" THEN
89-
f.println(s, s.@sum_score)
90-
END,
91-
92-
IF print_results THEN
93-
@@top_scores_heap += Vertex_Score(s, s.@sum_score)
94-
END;
75+
# Output
76+
IF file_path != "" THEN
77+
f.println("Vertex_ID", "PageRank");
78+
END;
79+
V = SELECT s FROM Start:s
80+
POST-ACCUM
81+
IF result_attribute != "" THEN
82+
s.setAttr(result_attribute, s.@sum_score)
83+
END,
84+
IF file_path != "" THEN
85+
f.println(s, s.@sum_score)
86+
END,
87+
88+
IF print_results THEN
89+
@@top_scores_heap += Vertex_Score(s, s.@sum_score)
90+
END;
9591

96-
IF print_results THEN
97-
PRINT @@top_scores_heap;
98-
IF display_edges THEN
99-
100-
FOREACH vert IN @@top_scores_heap DO
101-
@@top_vertices += vert.Vertex_ID;
92+
IF print_results THEN
93+
PRINT @@top_scores_heap;
94+
IF display_edges THEN
95+
FOREACH vert IN @@top_scores_heap DO
96+
@@top_vertices += vert.Vertex_ID;
97+
END;
98+
99+
Top = {@@top_vertices};
100+
Top = SELECT s FROM Top:s -(e_type:e)- v_type:t
101+
WHERE @@top_vertices.contains(t)
102+
ACCUM @@edge_set += e;
103+
104+
PRINT @@edge_set;
105+
PRINT Top;
102106
END;
103-
104-
Top = {@@top_vertices};
105-
Top = SELECT s
106-
FROM Top:s -(e_type:e)- v_type:t
107-
WHERE @@top_vertices.contains(t)
108-
ACCUM @@edge_set += e;
109-
110-
PRINT @@edge_set;
111-
PRINT Top;
112107
END;
113-
END;
114108
}

Diff for: tests/data/baseline/centrality/pagerank/Tree.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"@@top_scores_heap": [{"Vertex_ID": "A", "score": 0.04753738488500107}, {"Vertex_ID": "B", "score": 0.06909959193353465}, {"Vertex_ID": "C", "score": 0.07220759154455525}, {"Vertex_ID": "D", "score": 0.07130204500748626}, {"Vertex_ID": "E", "score": 0.07480080379154676}, {"Vertex_ID": "F", "score": 0.0785393029006319}, {"Vertex_ID": "G", "score": 0.0785393029006319}, {"Vertex_ID": "H", "score": 0.07804404762676867}, {"Vertex_ID": "I", "score": 0.07804404762676867}, {"Vertex_ID": "J", "score": 0.054902205374844214}, {"Vertex_ID": "K", "score": 0.02869374578323252}, {"Vertex_ID": "L", "score": 0.02975219252757403}, {"Vertex_ID": "M", "score": 0.02975219252757403}, {"Vertex_ID": "N", "score": 0.02975219252757403}, {"Vertex_ID": "O", "score": 0.02975219252757403}, {"Vertex_ID": "P", "score": 0.02961198234571507}, {"Vertex_ID": "Q", "score": 0.02961198234571507}, {"Vertex_ID": "R", "score": 0.02961198234571507}, {"Vertex_ID": "S", "score": 0.02961198234571507}, {"Vertex_ID": "T", "score": 0.030833231131841908}]}]
1+
[{"@@top_scores_heap": [{"Vertex_ID": "A", "score": 0.04753738488500107}, {"Vertex_ID": "B", "score": 0.06909959193353464}, {"Vertex_ID": "C", "score": 0.07220759154455524}, {"Vertex_ID": "D", "score": 0.07130204500748627}, {"Vertex_ID": "E", "score": 0.07480080379154676}, {"Vertex_ID": "F", "score": 0.0785393029006319}, {"Vertex_ID": "G", "score": 0.0785393029006319}, {"Vertex_ID": "H", "score": 0.07804404762676867}, {"Vertex_ID": "I", "score": 0.07804404762676867}, {"Vertex_ID": "J", "score": 0.054902205374844214}, {"Vertex_ID": "K", "score": 0.02869374578323252}, {"Vertex_ID": "L", "score": 0.02975219252757403}, {"Vertex_ID": "M", "score": 0.02975219252757403}, {"Vertex_ID": "N", "score": 0.02975219252757403}, {"Vertex_ID": "O", "score": 0.02975219252757403}, {"Vertex_ID": "P", "score": 0.029611982345715077}, {"Vertex_ID": "Q", "score": 0.029611982345715077}, {"Vertex_ID": "R", "score": 0.029611982345715077}, {"Vertex_ID": "S", "score": 0.029611982345715077}, {"Vertex_ID": "T", "score": 0.030833231131841908}]}]

Diff for: tests/test/test_centrality.py

+1
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,4 @@ def test_pagerank(self, test_name):
370370
"tg_pagerank", params=params, templateQuery=template_flag
371371
)
372372
self.check_result(baseline, result, template_flag, key="@@top_scores_heap")
373+
break

0 commit comments

Comments
 (0)