Skip to content

Commit 6c8fb8f

Browse files
update template query
1 parent 60818ce commit 6c8fb8f

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

GDBMS_ALGO/centrality/weighted_degree_cent.gsql

+27-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
CREATE TEMPLATE QUERY GDBMS_ALGO.centrality.weighted_degree_cent(STRING v_type, STRING e_type, STRING reverse_e_type, string weight_attribute, BOOL in_degree = TRUE, BOOL out_degree = TRUE, INT top_k=100, BOOL print_results = TRUE, STRING result_attribute = "",STRING file_path = "") SYNTAX V1 {
2-
32
/*
43
First Author: <First Author Name>
54
First Commit Date: <First Commit Date>
@@ -22,18 +21,20 @@ CREATE TEMPLATE QUERY GDBMS_ALGO.centrality.weighted_degree_cent(STRING v_type,
2221
for undirected graph, you only need to set e_type and in_degree
2322

2423
Publications:
25-
<link>
24+
NA
2625

2726
TigerGraph Documentation:
28-
<link>
27+
https://docs.tigergraph.com/graph-ml/current/centrality-algorithms/weighted-degree-centrality
2928

3029
Parameters:
3130
v_type:
32-
vertex types to traverse
31+
Vertex types to traverse
3332
e_type:
34-
edge types to traverse
33+
Edge types to traverse
3534
reverse_e_type:
36-
for indegree use
35+
For indegree use
36+
weight_attribute:
37+
The edge weight attribute name
3738
in_degree:
3839
If True, count incoming relationships
3940
out_degree:
@@ -43,27 +44,28 @@ CREATE TEMPLATE QUERY GDBMS_ALGO.centrality.weighted_degree_cent(STRING v_type,
4344
print_results:
4445
If True, print the results
4546
result_attribute:
46-
attribute to write result to
47+
Attribute to write result to
4748
file_path:
48-
file to write CSV output to
49-
*/
49+
File to write CSV output to
50+
*/
5051

5152
TYPEDEF TUPLE<VERTEX Vertex_ID, FLOAT score> Vertex_Score;
5253
HeapAccum<Vertex_Score>(top_k, score DESC) @@top_scores_heap;
53-
SumAccum<INT> @sum_degree_score;
54+
SumAccum<FLOAT> @sum_degree_score;
5455
FILE f (file_path);
5556

5657
all = {v_type};
5758
IF in_degree THEN
5859
sll = SELECT s
59-
FROM all:s-(reverse_e_type:e)-:t
60-
ACCUM s.@sum_degree_score+=e.getAttr(weight_attribute,"INT");
60+
FROM all:s -(reverse_e_type:e)- :t
61+
ACCUM s.@sum_degree_score += e.getAttr(weight_attribute, "FLOAT");
6162
END;
6263
IF out_degree THEN
6364
sll = SELECT s
64-
FROM all:s-(e_type:e)-:t
65-
ACCUM s.@sum_degree_score+=e.getAttr(weight_attribute,"INT");
65+
FROM all:s -(e_type:e)- :t
66+
ACCUM s.@sum_degree_score += e.getAttr(weight_attribute, "FLOAT");
6667
END;
68+
6769
#Output
6870
IF file_path != "" THEN
6971
f.println("Vertex_ID", "Degree");
@@ -72,17 +74,17 @@ CREATE TEMPLATE QUERY GDBMS_ALGO.centrality.weighted_degree_cent(STRING v_type,
7274
Start = SELECT s
7375
FROM all:s
7476
POST-ACCUM
75-
IF result_attribute != "" THEN
76-
s.setAttr(result_attribute, s.@sum_degree_score)
77-
END,
78-
79-
IF print_results THEN
80-
@@top_scores_heap += Vertex_Score(s, s.@sum_degree_score)
81-
END,
82-
83-
IF file_path != "" THEN
84-
f.println(s, s.@sum_degree_score)
85-
END;
77+
IF result_attribute != "" THEN
78+
s.setAttr(result_attribute, s.@sum_degree_score)
79+
END,
80+
81+
IF print_results THEN
82+
@@top_scores_heap += Vertex_Score(s, s.@sum_degree_score)
83+
END,
84+
85+
IF file_path != "" THEN
86+
f.println(s, s.@sum_degree_score)
87+
END;
8688

8789
IF print_results THEN
8890
PRINT @@top_scores_heap AS top_scores;

0 commit comments

Comments
 (0)