Skip to content

Commit

Permalink
[ALGOS-267] feat(algos): Fix bugs for template query;
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanleilin committed Jul 22, 2024
1 parent ae0522e commit 8c3431e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions GDBMS_ALGO/community/louvain.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,24 @@ CREATE TEMPLATE QUERY GDBMS_ALGO.community.louvain(
// -------------------- 1. First pass --------------------
// Initialization
All_Nodes = {v_type_set};
Pass_Nodes = SELECT s
FROM All_Nodes:s -(e_type_set:e)- :t
ACCUM @@m += e.getAttr(weight_attribute, "DOUBLE") / 2,
s.@k += e.getAttr(weight_attribute, "DOUBLE"),
IF s == t THEN // Self-loop link
s.@k_self_loop += e.getAttr(weight_attribute, "DOUBLE")
END
POST-ACCUM
s.@community_id = s,
s.@vid = getvid(s),
s.@batch_id = s.@vid % total_batch_count;
All_Nodes = SELECT s
FROM All_Nodes:s -(e_type_set:e)- :t
ACCUM @@m += e.getAttr(weight_attribute, "DOUBLE") / 2,
s.@k += e.getAttr(weight_attribute, "DOUBLE"),
IF s == t THEN // Self-loop link
s.@k_self_loop += e.getAttr(weight_attribute, "DOUBLE")
END
POST-ACCUM
s.@community_id = s,
s.@vid = getvid(s),
s.@batch_id = s.@vid % total_batch_count;
IF @@m < 0.00000000001 THEN
RETURN;
END;

// Local moving
INT hop = 0;
Pass_Nodes = All_Nodes;
Candidates (ANY) = Pass_Nodes;
WHILE Candidates.size() > 0 AND hop < maximum_iteration DO
hop = hop + 1;
Expand Down

0 comments on commit 8c3431e

Please sign in to comment.