-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from tigergraph/GML-1574
[GML-1574] fix(files): sync files with algos repository;
- Loading branch information
Showing
13 changed files
with
187 additions
and
8 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
63 changes: 63 additions & 0 deletions
63
GDBMS_ALGO/topological_link_prediction/common_neighbors.gsql
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
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 { | ||
|
||
/* | ||
First Author: <First Author Name> | ||
First Commit Date: <First Commit Date> | ||
|
||
Recent Author: <Recent Commit Author Name> | ||
Recent Commit Date: <Recent Commit Date> | ||
|
||
|
||
Repository: | ||
https://github.com/tigergraph/gsql-graph-algorithms/tree/master/algorithms/Topological%20Link%20Prediction | ||
|
||
Maturity: | ||
production | ||
|
||
Description: | ||
This query calculates the number of common neighbors between two vertices. | ||
The higher the number, the closer two vertices are. | ||
|
||
Publications: | ||
NA | ||
|
||
TigerGraph Documentation: | ||
https://docs.tigergraph.com/graph-ml/current/link-prediction/common-neighbors | ||
|
||
Parameters: | ||
v_source: | ||
Input vertex one | ||
v_target: | ||
Input vertex two | ||
e_type_set: | ||
edge types to traverse. If all edge types are desired, pass in "ALL" to the set. | ||
print_results: | ||
if True, print result (True by default) | ||
*/ | ||
|
||
avs = {v_source}; | ||
bvs = {v_target}; | ||
|
||
IF "ALL" NOT IN e_type_set THEN # Specific edge types defined | ||
# Get neighbors of source vertices | ||
na = SELECT n | ||
FROM avs -(e_type_set)- :n; | ||
|
||
nb = SELECT n | ||
FROM bvs -(e_type_set)- :n; | ||
|
||
ELSE # Use any edge types | ||
# Get neighbors of source vertices | ||
na = SELECT n | ||
FROM avs -()- :n; | ||
|
||
nb = SELECT n | ||
FROM bvs -()- :n; | ||
END; | ||
# Get neighbors in common | ||
u = na INTERSECT nb; | ||
|
||
IF print_results THEN | ||
PRINT u.size() as closeness; | ||
END; | ||
} |
62 changes: 62 additions & 0 deletions
62
GDBMS_ALGO/topological_link_prediction/preferential_attachment.gsql
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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 { | ||
|
||
/* | ||
First Author: <First Author Name> | ||
First Commit Date: <First Commit Date> | ||
|
||
Recent Author: <Recent Commit Author Name> | ||
Recent Commit Date: <Recent Commit Date> | ||
|
||
|
||
Repository: | ||
https://github.com/tigergraph/gsql-graph-algorithms/tree/master/algorithms/Topological%20Link%20Prediction | ||
|
||
Maturity: | ||
production | ||
|
||
Description: | ||
This query calculates the preferential attachment value between two vertices. | ||
The higher the number, the closer two vertices are. | ||
|
||
Preferential attachment is calculated by multiplying the number of each input vertices neighbors together. | ||
|
||
Publications: | ||
NA | ||
|
||
TigerGraph Documentation: | ||
https://docs.tigergraph.com/graph-ml/current/link-prediction/preferential-attachment | ||
|
||
Parameters: | ||
v_source: | ||
Input vertex one | ||
v_target: | ||
Input vertex two | ||
e_type_set: | ||
edge types to traverse. If all edge types are desired, pass in "ALL" to the set. | ||
print_results: | ||
if True, print result (True by default) | ||
*/ | ||
|
||
avs = {v_source}; | ||
bvs = {v_target}; | ||
|
||
# See if user specified edge types to traverse | ||
IF "ALL" NOT IN e_type_set THEN | ||
na = SELECT n | ||
FROM avs -(e_type_set)- :n; # Get neighbors of vertex A | ||
|
||
nb = SELECT n | ||
FROM bvs -(e_type_set)- :n; // Get neighbors of vertex B | ||
|
||
ELSE // traverse all edge types | ||
na = SELECT n | ||
FROM avs -()- :n; // Get neighbors of vertex A | ||
|
||
nb = SELECT n | ||
FROM bvs -()- :n; // Get neighbors of vertex B | ||
END; | ||
|
||
IF print_results THEN | ||
PRINT na.size()*nb.size() as closeness; // calculate and return closeness value | ||
END; | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
GDBMS_ALGO/topological_link_prediction/total_neighbors.gsql
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
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 { | ||
|
||
/* | ||
First Author: <First Author Name> | ||
First Commit Date: <First Commit Date> | ||
|
||
Recent Author: <Recent Commit Author Name> | ||
Recent Commit Date: <Recent Commit Date> | ||
|
||
|
||
Repository: | ||
https://github.com/tigergraph/gsql-graph-algorithms/tree/master/algorithms/Topological%20Link%20Prediction | ||
|
||
Maturity: | ||
production | ||
|
||
Description: | ||
This query calculates the number of total neighbors of two vertices. | ||
The higher the number, the closer two vertices are. | ||
|
||
Publications: | ||
NA | ||
|
||
TigerGraph Documentation: | ||
https://docs.tigergraph.com/graph-ml/current/link-prediction/total-neighbors | ||
|
||
Parameters: | ||
v_source: | ||
Input vertex one | ||
v_target: | ||
Input vertex two | ||
e_type_set: | ||
edge types to traverse. If all edge types are desired, pass in "ALL" to the set. | ||
print_results: | ||
if True, print result (True by default) | ||
*/ | ||
|
||
avs = {v_source}; | ||
bvs = {v_target}; | ||
|
||
IF "ALL" NOT IN e_type_set THEN # Specific edge types defined as parameters | ||
na = SELECT n | ||
FROM avs -(e_type_set)- :n; # Get vertex A's neighbors | ||
|
||
nb = SELECT n | ||
FROM bvs -(e_type_set)- :n; # Get vertex B's neighbors | ||
|
||
ELSE # Use all edge types | ||
na = SELECT n | ||
FROM avs -()- :n; # Get vertex A's neighbors | ||
|
||
nb = SELECT n | ||
FROM bvs -()- :n; # Get vertex B's neighbors | ||
END; | ||
u = na UNION nb; # Get all neighbors | ||
IF print_results THEN | ||
PRINT u.size() as closeness; | ||
END; | ||
} |
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
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