Skip to content

Commit bbcf2dc

Browse files
committed
[ALGOS-266] feat(algos): Adjust the code indentation to comply with the formatting standards.
1 parent e52b383 commit bbcf2dc

File tree

1 file changed

+78
-87
lines changed

1 file changed

+78
-87
lines changed

GDBMS_ALGO/community/label_prop.gsql

Lines changed: 78 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ CREATE TEMPLATE QUERY GDBMS_ALGO.community.label_prop(
6666

6767
// Initialization
6868
All_Nodes = {v_type_set};
69-
Tmp =
70-
SELECT s
71-
FROM All_Nodes:s -(e_type_set:e)- :t
72-
POST-ACCUM
73-
s.@community_id = s,
74-
s.@vid = getvid(s),
75-
s.@batch_id = s.@vid % batch_num,
76-
s.@degree = s.outdegree(e_type_set);
69+
Tmp = SELECT s
70+
FROM All_Nodes:s -(e_type_set:e)- :t
71+
POST-ACCUM
72+
s.@community_id = s,
73+
s.@vid = getvid(s),
74+
s.@batch_id = s.@vid % batch_num,
75+
s.@degree = s.outdegree(e_type_set);
7776
@@vertex_num = All_Nodes.size();
7877
@@vertex_num = @@vertex_num / batch_num;
7978

@@ -84,104 +83,96 @@ CREATE TEMPLATE QUERY GDBMS_ALGO.community.label_prop(
8483
hop = hop + 1;
8584
// Find the best move
8685
IF hop == 1 THEN // First iteration
87-
ChangedNodes =
88-
SELECT s
89-
FROM Candidates:s -(e_type_set:e)- :t
90-
WHERE s.@degree < t.@degree
91-
ACCUM s.@best_move += MoveScore(t.@degree, t.@community_id)
92-
POST-ACCUM
93-
IF s.@best_move.community != s.@community_id THEN
94-
s.@to_change_community = TRUE
95-
END
96-
HAVING s.@to_change_community == TRUE;
86+
ChangedNodes = SELECT s
87+
FROM Candidates:s -(e_type_set:e)- :t
88+
WHERE s.@degree < t.@degree
89+
ACCUM s.@best_move += MoveScore(t.@degree, t.@community_id)
90+
POST-ACCUM
91+
IF s.@best_move.community != s.@community_id THEN
92+
s.@to_change_community = TRUE
93+
END
94+
HAVING s.@to_change_community == TRUE;
9795
ELSE // Remaining iterations
9896
IF Candidates.size() < @@vertex_num OR batch_num == 1 THEN // No batch processing
99-
ChangedNodes =
100-
SELECT s
101-
FROM Candidates:s -(e_type_set:e)- :t
102-
SAMPLE sample_edge_num EDGE WHEN s.outdegree(e_type_set) > sample_edge_num
103-
ACCUM s.@community_k_in_map += (t.@community_id -> 1)
104-
POST-ACCUM
105-
s.@best_move = MoveScore(@@min_double, s), // Reset best move
106-
FOREACH (community_id, k_in) IN s.@community_k_in_map DO
107-
s.@best_move += MoveScore(k_in, community_id)
108-
END,
109-
IF s.@best_move.community != s.@community_id THEN
110-
s.@to_change_community = TRUE
111-
END,
112-
s.@community_k_in_map.clear()
113-
HAVING s.@to_change_community == TRUE;
97+
ChangedNodes = SELECT s
98+
FROM Candidates:s -(e_type_set:e)- :t
99+
SAMPLE sample_edge_num EDGE WHEN s.outdegree(e_type_set) > sample_edge_num
100+
ACCUM s.@community_k_in_map += (t.@community_id -> 1)
101+
POST-ACCUM
102+
s.@best_move = MoveScore(@@min_double, s), // Reset best move
103+
FOREACH (community_id, k_in) IN s.@community_k_in_map DO
104+
s.@best_move += MoveScore(k_in, community_id)
105+
END,
106+
IF s.@best_move.community != s.@community_id THEN
107+
s.@to_change_community = TRUE
108+
END,
109+
s.@community_k_in_map.clear()
110+
HAVING s.@to_change_community == TRUE;
114111
ELSE // Use batch processing
115112
ChangedNodes = {};
116113
FOREACH batch_id IN RANGE[0, batch_num-1] DO
117-
Nodes =
118-
SELECT s
119-
FROM Candidates:s
120-
WHERE s.@batch_id == batch_id;
121-
Nodes =
122-
SELECT s
123-
FROM Nodes:s -(e_type_set:e)- :t
124-
SAMPLE sample_edge_num EDGE WHEN s.outdegree(e_type_set) > sample_edge_num
125-
ACCUM s.@community_k_in_map += (t.@community_id -> 1)
126-
POST-ACCUM
127-
s.@best_move = MoveScore(@@min_double, s), // Reset best move
128-
FOREACH (community_id, k_in) IN s.@community_k_in_map DO
129-
s.@best_move += MoveScore(k_in, community_id)
130-
END,
131-
IF s.@best_move.community != s.@community_id THEN
132-
s.@to_change_community = TRUE
133-
END,
134-
s.@community_k_in_map.clear()
135-
HAVING s.@to_change_community == TRUE;
114+
Nodes = SELECT s
115+
FROM Candidates:s
116+
WHERE s.@batch_id == batch_id;
117+
Nodes = SELECT s
118+
FROM Nodes:s -(e_type_set:e)- :t
119+
SAMPLE sample_edge_num EDGE WHEN s.outdegree(e_type_set) > sample_edge_num
120+
ACCUM s.@community_k_in_map += (t.@community_id -> 1)
121+
POST-ACCUM
122+
s.@best_move = MoveScore(@@min_double, s), // Reset best move
123+
FOREACH (community_id, k_in) IN s.@community_k_in_map DO
124+
s.@best_move += MoveScore(k_in, community_id)
125+
END,
126+
IF s.@best_move.community != s.@community_id THEN
127+
s.@to_change_community = TRUE
128+
END,
129+
s.@community_k_in_map.clear()
130+
HAVING s.@to_change_community == TRUE;
136131
ChangedNodes = ChangedNodes UNION Nodes;
137132
END;
138133
END;
139134
END;
140135

141136
// Handle nodes that swap communities
142-
SwapNodes =
143-
SELECT s
144-
FROM ChangedNodes:s -(e_type_set:e)- :t
145-
WHERE s.@best_move.community == t.@community_id
146-
AND t.@to_change_community == TRUE
147-
AND t.@best_move.community == s.@community_id
148-
AND (s.@best_move.score < t.@best_move.score
149-
OR (abs(s.@best_move.score - t.@best_move.score) < 0.00000000001
150-
AND s.@vid > t.@vid))
151-
POST-ACCUM
152-
s.@to_change_community = FALSE;
137+
SwapNodes = SELECT s
138+
FROM ChangedNodes:s -(e_type_set:e)- :t
139+
WHERE s.@best_move.community == t.@community_id
140+
AND t.@to_change_community == TRUE
141+
AND t.@best_move.community == s.@community_id
142+
AND (s.@best_move.score < t.@best_move.score
143+
OR (abs(s.@best_move.score - t.@best_move.score) < 0.00000000001
144+
AND s.@vid > t.@vid))
145+
POST-ACCUM
146+
s.@to_change_community = FALSE;
153147
ChangedNodes = ChangedNodes MINUS SwapNodes;
154148

155149
// Update community IDs
156-
ChangedNodes =
157-
SELECT s
158-
FROM ChangedNodes:s
159-
POST-ACCUM
160-
s.@community_id = s.@best_move.community,
161-
s.@to_change_community = FALSE;
150+
ChangedNodes = SELECT s
151+
FROM ChangedNodes:s
152+
POST-ACCUM
153+
s.@community_id = s.@best_move.community,
154+
s.@to_change_community = FALSE;
162155

163156
// Find candidates for the next iteration
164-
Candidates =
165-
SELECT t
166-
FROM ChangedNodes:s -(e_type_set:e)- :t
167-
WHERE t.@community_id != s.@community_id;
157+
Candidates = SELECT t
158+
FROM ChangedNodes:s -(e_type_set:e)- :t
159+
WHERE t.@community_id != s.@community_id;
168160
END;
169161

170162
// Output results
171-
Nodes =
172-
SELECT s
173-
FROM All_Nodes:s
174-
POST-ACCUM
175-
IF result_attribute != "" THEN
176-
s.setAttr(result_attribute, getvid(s.@community_id))
177-
END,
178-
IF print_results THEN
179-
@@comm_sizes_map += (s.@community_id -> 1)
180-
END,
181-
IF file_path != "" THEN
182-
f.println(s.id, s.@community_id)
183-
END
184-
LIMIT print_limit;
163+
Nodes = SELECT s
164+
FROM All_Nodes:s
165+
POST-ACCUM
166+
IF result_attribute != "" THEN
167+
s.setAttr(result_attribute, getvid(s.@community_id))
168+
END,
169+
IF print_results THEN
170+
@@comm_sizes_map += (s.@community_id -> 1)
171+
END,
172+
IF file_path != "" THEN
173+
f.println(s.id, s.@community_id)
174+
END
175+
LIMIT print_limit;
185176

186177
// Print results if print_results is True
187178
IF print_results THEN

0 commit comments

Comments
 (0)