Skip to content

Commit

Permalink
Merge pull request #139 from tigergraph/3.9
Browse files Browse the repository at this point in the history
Updating master to 3.9
  • Loading branch information
TannerW authored Mar 7, 2023
2 parents 8383057 + 9d4a391 commit 4d91fb1
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 40 deletions.
13 changes: 7 additions & 6 deletions .github/auto_request_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ reviewers:
group1:
- yimingpantg
- TannerW
- wyatt-joyner-tg
- parkererickson
- lennessyy
- a-m-thomas
- wyattjoynertg
- parkererickson-tg
- alexthomasTG
secondary:
- yimingpantg
- wyatt-joyner-tg
- wyattjoynertg
- TannerW
tertiary:
- xinyuchtg
- victor-gsl
- victorleeTG
- TannerW

files:
# All review request will be sent to the following groups/people.
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
auto-request-review:
runs-on: ubuntu-latest
steps:
- uses: necojackarc/auto-request-review@v0.4.0
- uses: necojackarc/auto-request-review@v0.10.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
config: .github/auto_request_review.yml
15 changes: 12 additions & 3 deletions GDBMS_ALGO/centrality/pagerank.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CREATE TEMPLATE QUERY GDBMS_ALGO.centrality.pagerank (STRING v_type, STRING e_ty

TYPEDEF TUPLE<VERTEX Vertex_ID, FLOAT score> Vertex_Score;
HeapAccum<Vertex_Score>(top_k, score DESC) @@top_scores_heap;
SetAccum<VERTEX> @@top_vertices; # vertices with top score
MaxAccum<FLOAT> @@max_diff = 9999; # max score change in an iteration
SumAccum<FLOAT> @sum_recvd_score = 0; # sum of scores each vertex receives FROM neighbors
SumAccum<FLOAT> @sum_score = 1; # initial score for every vertex is 1.
Expand Down Expand Up @@ -99,11 +100,19 @@ V = SELECT s
IF print_results THEN
PRINT @@top_scores_heap;
IF display_edges THEN
PRINT Start[Start.@sum_score];
Start = SELECT s
FROM Start:s -(e_type:e)- v_type:t

FOREACH vert IN @@top_scores_heap DO
@@top_vertices += vert.Vertex_ID;
END;

Top = {@@top_vertices};
Top = SELECT s
FROM Top:s -(e_type:e)- v_type:t
WHERE @@top_vertices.contains(t)
ACCUM @@edge_set += e;

PRINT @@edge_set;
PRINT Top;
END;
END;
}
19 changes: 14 additions & 5 deletions GDBMS_ALGO/centrality/pagerank_wt.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CREATE TEMPLATE QUERY GDBMS_ALGO.centrality.pagerank_wt (STRING v_type, STRING e

TYPEDEF TUPLE<VERTEX Vertex_ID, FLOAT score> Vertex_Score;
HeapAccum<Vertex_Score>(top_k, score DESC) @@top_scores_heap;
SetAccum<VERTEX> @@top_vertices; # vertices with top score
MaxAccum<FLOAT> @@max_diff = 9999; # max score change in an iteration
SumAccum<FLOAT> @sum_recvd_score = 0; # sum of scores each vertex receives FROM neighbors
SumAccum<FLOAT> @sum_score = 1; # initial score for every vertex is 1.
Expand Down Expand Up @@ -107,11 +108,19 @@ V = SELECT s
IF print_results THEN
PRINT @@top_scores_heap;
IF display_edges THEN
PRINT Start[Start.@sum_score];
Start = SELECT s
FROM Start:s -(e_type:e)- v_type:t
ACCUM @@edge_set += e;
PRINT @@edge_set;

FOREACH vert IN @@top_scores_heap DO
@@top_vertices += vert.Vertex_ID;
END;

Top = {@@top_vertices};
Top = SELECT s
FROM Top:s -(e_type:e)- v_type:t
WHERE @@top_vertices.contains(t)
ACCUM @@edge_set += e;

PRINT @@edge_set;
PRINT Top;
END;
END;
}
15 changes: 12 additions & 3 deletions algorithms/Centrality/pagerank/global/unweighted/tg_pagerank.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CREATE QUERY tg_pagerank (STRING v_type, STRING e_type,

TYPEDEF TUPLE<VERTEX Vertex_ID, FLOAT score> Vertex_Score;
HeapAccum<Vertex_Score>(top_k, score DESC) @@top_scores_heap;
SetAccum<VERTEX> @@top_vertices; # vertices with top score
MaxAccum<FLOAT> @@max_diff = 9999; # max score change in an iteration
SumAccum<FLOAT> @sum_recvd_score = 0; # sum of scores each vertex receives FROM neighbors
SumAccum<FLOAT> @sum_score = 1; # initial score for every vertex is 1.
Expand Down Expand Up @@ -99,11 +100,19 @@ V = SELECT s
IF print_results THEN
PRINT @@top_scores_heap;
IF display_edges THEN
PRINT Start[Start.@sum_score];
Start = SELECT s
FROM Start:s -(e_type:e)- v_type:t

FOREACH vert IN @@top_scores_heap DO
@@top_vertices += vert.Vertex_ID;
END;

Top = {@@top_vertices};
Top = SELECT s
FROM Top:s -(e_type:e)- v_type:t
WHERE @@top_vertices.contains(t)
ACCUM @@edge_set += e;

PRINT @@edge_set;
PRINT Top;
END;
END;
}
19 changes: 14 additions & 5 deletions algorithms/Centrality/pagerank/global/weighted/tg_pagerank_wt.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CREATE QUERY tg_pagerank_wt (STRING v_type, STRING e_type, STRING weight_attribu

TYPEDEF TUPLE<VERTEX Vertex_ID, FLOAT score> Vertex_Score;
HeapAccum<Vertex_Score>(top_k, score DESC) @@top_scores_heap;
SetAccum<VERTEX> @@top_vertices; # vertices with top score
MaxAccum<FLOAT> @@max_diff = 9999; # max score change in an iteration
SumAccum<FLOAT> @sum_recvd_score = 0; # sum of scores each vertex receives FROM neighbors
SumAccum<FLOAT> @sum_score = 1; # initial score for every vertex is 1.
Expand Down Expand Up @@ -107,11 +108,19 @@ V = SELECT s
IF print_results THEN
PRINT @@top_scores_heap;
IF display_edges THEN
PRINT Start[Start.@sum_score];
Start = SELECT s
FROM Start:s -(e_type:e)- v_type:t
ACCUM @@edge_set += e;
PRINT @@edge_set;

FOREACH vert IN @@top_scores_heap DO
@@top_vertices += vert.Vertex_ID;
END;

Top = {@@top_vertices};
Top = SELECT s
FROM Top:s -(e_type:e)- v_type:t
WHERE @@top_vertices.contains(t)
ACCUM @@edge_set += e;

PRINT @@edge_set;
PRINT Top;
END;
END;
}
4 changes: 2 additions & 2 deletions algorithms/GraphML/Embeddings/FastRP/tg_algo_fastRP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
sha_id: ed6ea869749977cc0f3df71225d7325fb81c9767
description: "Generates node embeddings of low dimensionality through random projections from the graph's adjacency matrix (a high-dimensional matrix) to a low-dimensional matrix, significantly reducing the computing power required for data processing. "
schema_constraints: This algorithm can optionally write the embedding results back to the graph if the target vertex type(s) have a list attribute of type DOUBLE.
version: lib3.0
include: false
version: lib3.8
include: true
dependencies:
ExprFunctions:
sha_id: ed6ea869749977cc0f3df71225d7325fb81c9767
28 changes: 14 additions & 14 deletions algorithms/GraphML/Embeddings/FastRP/tg_fastRP.gsql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE QUERY tg_fastRP(
SET<STRING> v_type,
SET<STRING> e_type,
SET<STRING> output_v_type,
SET<STRING> v_type_set,
SET<STRING> e_type_set,
SET<STRING> output_v_type_set,
STRING iteration_weights,
FLOAT beta,
INT embedding_dimension,
Expand Down Expand Up @@ -57,11 +57,11 @@ CREATE QUERY tg_fastRP(


Parameters:
v_type:
v_type_set:
Set of all vertex types to traverse in the graph.
e_type:
e_type_set:
Set of all edge types to traverse in the graph.
output_v_type:
output_v_type_set:
Set of vertex types to produce output embeddings for.
iteration_weights:
A comma-separated string of numbers to weight each iteration of the embedding process.
Expand Down Expand Up @@ -165,7 +165,7 @@ CREATE QUERY tg_fastRP(
weight_idx = weight_idx + 1;
END;

verts = {v_type};
verts = {v_type_set};
// component_attr should indicate which batch each vertex belongs to, if none defined, just use all vertex types provided
IF component_attribute != "" THEN
verts =
Expand All @@ -182,22 +182,22 @@ CREATE QUERY tg_fastRP(
// L stores the normalized diagonal elements of an inverse degree matrix
// this is defined in the original algorithm and is useful for initialization
verts =
SELECT s FROM verts:s -(e_type:e)- v_type:t
SELECT s FROM verts:s -(e_type_set:e)- v_type_set:t
WHERE t.@include == TRUE
ACCUM @@m += 1
POST-ACCUM s.@L = pow(s.outdegree(e_type) / @@m, beta);
POST-ACCUM s.@L = pow(s.outdegree(e_type_set) / @@m, beta);

// randomly initialize the topological embedding regions
verts =
SELECT s FROM verts:s -(e_type:e)- v_type:t
SELECT s FROM verts:s -(e_type_set:e)- v_type_set:t
WHERE t.@include == TRUE
ACCUM
// PRNG code
INT inc = (getvid(s)+_inc),
INT r = ((inc+_mult*random_seed) % _mod),
FLOAT mr = 0,
STRING temp_e_type = e.type,
// if the edge type wasn't explicitly specified, but was provided in e_type,
// if the edge type wasn't explicitly specified, but was provided in e_type_set,
// then its information will reside in the 'default' region of the embedding vector
IF @@embedding_dim_map.containsKey(e.type) == FALSE THEN
temp_e_type = "default"
Expand All @@ -221,14 +221,14 @@ CREATE QUERY tg_fastRP(

// propagate embeddings to neighbors and normalize
verts =
SELECT s FROM verts:s -(e_type)- v_type:t
SELECT s FROM verts:s -(e_type_set)- v_type_set:t
WHERE t.@include == TRUE
ACCUM
t.@embedding_arr += s.@embedding_arr
POST-ACCUM
// first calculate square sum to help normalize
FLOAT square_sum = 0,
FLOAT out = max([1.0, t.outdegree(e_type)]),
FLOAT out = max([1.0, t.outdegree(e_type_set)]),
FOREACH (i,total) IN t.@embedding_arr DO
square_sum = square_sum + pow(total / out, 2)
END,
Expand Down Expand Up @@ -256,7 +256,7 @@ CREATE QUERY tg_fastRP(
// the arrays are converted to lists for compatibility with GSQL's LIST type
verts =
SELECT s FROM verts:s
WHERE output_v_type.size() == 0 OR output_v_type.contains(s.type)
WHERE output_v_type_set.size() == 0 OR output_v_type_set.contains(s.type)
POST-ACCUM
FOREACH i IN RANGE[0, embedding_dimension-1] DO
s.@final_embedding_list += s.@final_embedding_arr.get(i) / @@weights.size() // Average by # of iterations
Expand Down
8 changes: 7 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@
"path": "algorithms/Community/connected_components/strongly_connected_components/standard/tg_scc.gsql",
"schema_type": "VERTEX",
"value_type": "INT"
}
},
"weakly_connected_components": {
"name": "tg_wcc",
"path": "algorithms/Community/connected_components/weakly_connected_components/standard/tg_wcc.gsql",
"schema_type": "VERTEX",
"value_type": "INT"
}
},
"k_core": {
"name": "tg_kcore",
Expand Down

0 comments on commit 4d91fb1

Please sign in to comment.