Skip to content

Commit 62e455a

Browse files
Merge pull request #142 from tigergraph/GML-1574
[GML-1574] fix(files): sync files with algos repository;
2 parents 4d91fb1 + 85a7d71 commit 62e455a

File tree

13 files changed

+187
-8
lines changed

13 files changed

+187
-8
lines changed

GDBMS_ALGO/centrality/closeness.gsql

-1
This file was deleted.

GDBMS_ALGO/classification/knn.gsql

-1
This file was deleted.

GDBMS_ALGO/graphML/weisfeiler_lehman

-1
This file was deleted.

GDBMS_ALGO/similarity/cosine_nbor_ss.gsql

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
CREATE TEMPLATE QUERY GDBMS_ALGO.topological_link_prediction.common_neighbors(VERTEX v_source, VERTEX v_target, SET<STRING> e_type_set, BOOL print_results = TRUE) SYNTAX V1 {
2+
3+
/*
4+
First Author: <First Author Name>
5+
First Commit Date: <First Commit Date>
6+
7+
Recent Author: <Recent Commit Author Name>
8+
Recent Commit Date: <Recent Commit Date>
9+
10+
11+
Repository:
12+
https://github.com/tigergraph/gsql-graph-algorithms/tree/master/algorithms/Topological%20Link%20Prediction
13+
14+
Maturity:
15+
production
16+
17+
Description:
18+
This query calculates the number of common neighbors between two vertices.
19+
The higher the number, the closer two vertices are.
20+
21+
Publications:
22+
NA
23+
24+
TigerGraph Documentation:
25+
https://docs.tigergraph.com/graph-ml/current/link-prediction/common-neighbors
26+
27+
Parameters:
28+
v_source:
29+
Input vertex one
30+
v_target:
31+
Input vertex two
32+
e_type_set:
33+
edge types to traverse. If all edge types are desired, pass in "ALL" to the set.
34+
print_results:
35+
if True, print result (True by default)
36+
*/
37+
38+
avs = {v_source};
39+
bvs = {v_target};
40+
41+
IF "ALL" NOT IN e_type_set THEN # Specific edge types defined
42+
# Get neighbors of source vertices
43+
na = SELECT n
44+
FROM avs -(e_type_set)- :n;
45+
46+
nb = SELECT n
47+
FROM bvs -(e_type_set)- :n;
48+
49+
ELSE # Use any edge types
50+
# Get neighbors of source vertices
51+
na = SELECT n
52+
FROM avs -()- :n;
53+
54+
nb = SELECT n
55+
FROM bvs -()- :n;
56+
END;
57+
# Get neighbors in common
58+
u = na INTERSECT nb;
59+
60+
IF print_results THEN
61+
PRINT u.size() as closeness;
62+
END;
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
CREATE TEMPLATE QUERY GDBMS_ALGO.topological_link_prediction.preferential_attachment(VERTEX v_source, VERTEX v_target, SET<STRING> e_type_set, BOOL print_results = TRUE) SYNTAX V1 {
2+
3+
/*
4+
First Author: <First Author Name>
5+
First Commit Date: <First Commit Date>
6+
7+
Recent Author: <Recent Commit Author Name>
8+
Recent Commit Date: <Recent Commit Date>
9+
10+
11+
Repository:
12+
https://github.com/tigergraph/gsql-graph-algorithms/tree/master/algorithms/Topological%20Link%20Prediction
13+
14+
Maturity:
15+
production
16+
17+
Description:
18+
This query calculates the preferential attachment value between two vertices.
19+
The higher the number, the closer two vertices are.
20+
21+
Preferential attachment is calculated by multiplying the number of each input vertices neighbors together.
22+
23+
Publications:
24+
NA
25+
26+
TigerGraph Documentation:
27+
https://docs.tigergraph.com/graph-ml/current/link-prediction/preferential-attachment
28+
29+
Parameters:
30+
v_source:
31+
Input vertex one
32+
v_target:
33+
Input vertex two
34+
e_type_set:
35+
edge types to traverse. If all edge types are desired, pass in "ALL" to the set.
36+
print_results:
37+
if True, print result (True by default)
38+
*/
39+
40+
avs = {v_source};
41+
bvs = {v_target};
42+
43+
# See if user specified edge types to traverse
44+
IF "ALL" NOT IN e_type_set THEN
45+
na = SELECT n
46+
FROM avs -(e_type_set)- :n; # Get neighbors of vertex A
47+
48+
nb = SELECT n
49+
FROM bvs -(e_type_set)- :n; // Get neighbors of vertex B
50+
51+
ELSE // traverse all edge types
52+
na = SELECT n
53+
FROM avs -()- :n; // Get neighbors of vertex A
54+
55+
nb = SELECT n
56+
FROM bvs -()- :n; // Get neighbors of vertex B
57+
END;
58+
59+
IF print_results THEN
60+
PRINT na.size()*nb.size() as closeness; // calculate and return closeness value
61+
END;
62+
}

GDBMS_ALGO/topological_link_prediction/same_community.gsql

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
CREATE TEMPLATE QUERY GDBMS_ALGO.topological_link_prediction.total_neighbors(VERTEX v_source, VERTEX v_target, SET<STRING> e_type_set, BOOL print_results = TRUE) SYNTAX V1 {
2+
3+
/*
4+
First Author: <First Author Name>
5+
First Commit Date: <First Commit Date>
6+
7+
Recent Author: <Recent Commit Author Name>
8+
Recent Commit Date: <Recent Commit Date>
9+
10+
11+
Repository:
12+
https://github.com/tigergraph/gsql-graph-algorithms/tree/master/algorithms/Topological%20Link%20Prediction
13+
14+
Maturity:
15+
production
16+
17+
Description:
18+
This query calculates the number of total neighbors of two vertices.
19+
The higher the number, the closer two vertices are.
20+
21+
Publications:
22+
NA
23+
24+
TigerGraph Documentation:
25+
https://docs.tigergraph.com/graph-ml/current/link-prediction/total-neighbors
26+
27+
Parameters:
28+
v_source:
29+
Input vertex one
30+
v_target:
31+
Input vertex two
32+
e_type_set:
33+
edge types to traverse. If all edge types are desired, pass in "ALL" to the set.
34+
print_results:
35+
if True, print result (True by default)
36+
*/
37+
38+
avs = {v_source};
39+
bvs = {v_target};
40+
41+
IF "ALL" NOT IN e_type_set THEN # Specific edge types defined as parameters
42+
na = SELECT n
43+
FROM avs -(e_type_set)- :n; # Get vertex A's neighbors
44+
45+
nb = SELECT n
46+
FROM bvs -(e_type_set)- :n; # Get vertex B's neighbors
47+
48+
ELSE # Use all edge types
49+
na = SELECT n
50+
FROM avs -()- :n; # Get vertex A's neighbors
51+
52+
nb = SELECT n
53+
FROM bvs -()- :n; # Get vertex B's neighbors
54+
END;
55+
u = na UNION nb; # Get all neighbors
56+
IF print_results THEN
57+
PRINT u.size() as closeness;
58+
END;
59+
}

algorithms/Centrality/betweenness/tg_betweenness_cent.gsql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE QUERY tg_betweenness_cent(SET<STRING> v_type_set, SET<STRING> e_type_set, STRING reverse_e_type,INT max_hops = 10,
1+
CREATE QUERY tg_betweenness_cent(SET<STRING> v_type_set, SET<STRING> e_type_set, SET<STRING> reverse_e_type,INT max_hops = 10,
22
INT top_k = 100, BOOL print_results = True, STRING result_attribute = "",
33
STRING file_path = "", BOOL display_edges = FALSE) SYNTAX V1 {
44

algorithms/Centrality/closeness/exact/tg_closeness_cent.gsql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE QUERY tg_closeness_cent(SET<STRING> v_type_set, SET<STRING> e_type_set, STRING reverse_e_type,INT max_hops = 10,
1+
CREATE QUERY tg_closeness_cent(SET<STRING> v_type_set, SET<STRING> e_type_set, SET<STRING> reverse_e_type,INT max_hops = 10,
22
INT top_k = 100, BOOL wf = TRUE, BOOL print_results = True, STRING result_attribute = "",
33
STRING file_path = "", BOOL display_edges = FALSE) SYNTAX V1 {
44

algorithms/Community/k_means/tg_kmeans_sub.gsql

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ CREATE QUERY tg_kmeans_sub(int k, float max_change = 1.0, string v_type, string
7373
IF random == TRUE THEN
7474
FOREACH i IN range[0,k-1] DO
7575
FOREACH j IN range[0,99] DO
76-
@@centroids_array[i][j] = rand_int(-2,5)-0.123*0.4;
76+
@@centroids_array[i][j] = tg_rand_int(-2,5)-0.123*0.4;
7777
END;
7878
END;
7979
END;

0 commit comments

Comments
 (0)