Skip to content

Commit 9f417c3

Browse files
committed
Updated bench_utils_graph.rs to new causal graph api.
1 parent 4d9e703 commit 9f417c3

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

deep_causality/src/utils/bench_utils_graph.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn build_linear_graph(
4646
let current_idx = g.add_causaloid(causaloid);
4747

4848
// link current causaloid to previos causaloid
49-
g.add_edge(previous_idx, current_idx);
49+
g.add_edge(previous_idx, current_idx).expect("Failed to add edge");
5050

5151
previous_idx = current_idx;
5252
}
@@ -81,24 +81,24 @@ fn build_multi_cause_graph()
8181
let idx_a = g.add_causaloid(causaloid);
8282

8383
// Link causaloid A to root causaloid
84-
g.add_edge(root_index, idx_a);
84+
g.add_edge(root_index, idx_a).expect("Failed to add edge between root and A");
8585

8686
// Add causaloid B
8787
let causaloid = test_utils::get_test_causaloid();
8888
let idx_b = g.add_causaloid(causaloid);
8989

9090
// Link causaloid B to root causaloid
91-
g.add_edge(root_index, idx_b);
91+
g.add_edge(root_index, idx_b).expect("Failed to add edge between root and B");
9292

9393
// Add causaloid C
9494
let causaloid = test_utils::get_test_causaloid();
9595
let idx_c = g.add_causaloid(causaloid);
9696

9797
// Link causaloid C to A
98-
g.add_edge(idx_a, idx_c);
98+
g.add_edge(idx_a, idx_c).expect("Failed to add edge between A and C");
9999

100100
// Link causaloid C to B
101-
g.add_edge(idx_b, idx_c);
101+
g.add_edge(idx_b, idx_c).expect("Failed to add edge between C and B");
102102

103103
g
104104
}
@@ -131,49 +131,49 @@ fn build_multi_layer_cause_graph()
131131
let causaloid = test_utils::get_test_causaloid();
132132
let idx_a = g.add_causaloid(causaloid);
133133
// Link causaloid A to root causaloid
134-
g.add_edge(root_index, idx_a);
134+
g.add_edge(root_index, idx_a).expect("Failed to add edge between root and A");
135135

136136
// Add causaloid B
137137
let causaloid = test_utils::get_test_causaloid();
138138
let idx_b = g.add_causaloid(causaloid);
139139
// Link causaloid B to root causaloid
140-
g.add_edge(root_index, idx_b);
140+
g.add_edge(root_index, idx_b).expect("Failed to add edge between root and B");
141141

142142
// Add causaloid C
143143
let causaloid = test_utils::get_test_causaloid();
144144
let idx_c = g.add_causaloid(causaloid);
145145
// Link causaloid C to root causaloid
146-
g.add_edge(root_index, idx_c);
146+
g.add_edge(root_index, idx_c).expect("Failed to add edge between root and C");
147147

148148
// ### Second layer ### //
149149

150150
// Add causaloid D
151151
let causaloid = test_utils::get_test_causaloid();
152152
let idx_d = g.add_causaloid(causaloid);
153153
// Link causaloid D to A
154-
g.add_edge(idx_a, idx_d);
154+
g.add_edge(idx_a, idx_d).expect("Failed to add edge between D and A");
155155

156156
// Add causaloid E
157157
let causaloid = test_utils::get_test_causaloid();
158158
let idx_e = g.add_causaloid(causaloid);
159159
// Link causaloid E to A
160-
g.add_edge(idx_a, idx_e);
160+
g.add_edge(idx_a, idx_e).expect("Failed to add edge between A and E");
161161
// Link causaloid E to B
162-
g.add_edge(idx_b, idx_e);
162+
g.add_edge(idx_b, idx_e).expect("Failed to add edge between B and E");
163163

164164
// Add causaloid F
165165
let causaloid = test_utils::get_test_causaloid();
166166
let idx_f = g.add_causaloid(causaloid);
167167
// Link causaloid F to B
168-
g.add_edge(idx_b, idx_f);
168+
g.add_edge(idx_b, idx_f).expect("Failed to add edge between B and F");
169169
// Link causaloid F to C
170-
g.add_edge(idx_c, idx_f);
170+
g.add_edge(idx_c, idx_f).expect("Failed to add edge between C and F");
171171

172172
// Add causaloid G
173173
let causaloid = test_utils::get_test_causaloid();
174174
let idx_g = g.add_causaloid(causaloid);
175175
// Link causaloid G to C
176-
g.add_edge(idx_c, idx_g);
176+
g.add_edge(idx_c, idx_g).expect("Failed to add edge between A and C");
177177

178178
g
179179
}
@@ -206,33 +206,33 @@ fn build_left_imbalanced_cause_graph()
206206
let causaloid = test_utils::get_test_causaloid();
207207
let idx_a = g.add_causaloid(causaloid);
208208
// Link causaloid A to root causaloid
209-
g.add_edge(root_index, idx_a);
209+
g.add_edge(root_index, idx_a).expect("Failed to add edge between root and A");
210210

211211
// Add causaloid B
212212
let causaloid = test_utils::get_test_causaloid();
213213
let idx_b = g.add_causaloid(causaloid);
214214
// Link causaloid B to root causaloid
215-
g.add_edge(root_index, idx_b);
215+
g.add_edge(root_index, idx_b).expect("Failed to add edge between root and B");
216216

217217
// Add causaloid C
218218
let causaloid = test_utils::get_test_causaloid();
219219
let idx_c = g.add_causaloid(causaloid);
220220
// Link causaloid C to root causaloid
221-
g.add_edge(root_index, idx_c);
221+
g.add_edge(root_index, idx_c).expect("Failed to add edge between root and C");
222222

223223
// ### Second layer ### //
224224

225225
// Add causaloid D
226226
let causaloid = test_utils::get_test_causaloid();
227227
let idx_d = g.add_causaloid(causaloid);
228228
// Link causaloid D to A
229-
g.add_edge(idx_a, idx_d);
229+
g.add_edge(idx_a, idx_d).expect("Failed to add edge between A and E");
230230

231231
// Add causaloid E
232232
let causaloid = test_utils::get_test_causaloid();
233233
let idx_e = g.add_causaloid(causaloid);
234234
// Link causaloid E to A
235-
g.add_edge(idx_a, idx_e);
235+
g.add_edge(idx_a, idx_e).expect("Failed to add edge between A and B");
236236

237237
g
238238
}
@@ -265,33 +265,33 @@ fn build_right_imbalanced_cause_graph()
265265
let causaloid = test_utils::get_test_causaloid();
266266
let idx_a = g.add_causaloid(causaloid);
267267
// Link causaloid A to root causaloid
268-
g.add_edge(root_index, idx_a);
268+
g.add_edge(root_index, idx_a).expect("Failed to add edge between rootCause and A");
269269

270270
// Add causaloid B
271271
let causaloid = test_utils::get_test_causaloid();
272272
let idx_b = g.add_causaloid(causaloid);
273273
// Link causaloid B to root causaloid
274-
g.add_edge(root_index, idx_b);
274+
g.add_edge(root_index, idx_b).expect("Failed to add edge between rootCause and B");
275275

276276
// Add causaloid C
277277
let causaloid = test_utils::get_test_causaloid();
278278
let idx_c = g.add_causaloid(causaloid);
279279
// Link causaloid C to root causaloid
280-
g.add_edge(root_index, idx_c);
280+
g.add_edge(root_index, idx_c).expect("Failed to add edge between root and C");
281281

282282
// ### Second layer ### //
283283

284284
// Add causaloid D
285285
let causaloid = test_utils::get_test_causaloid();
286286
let idx_d = g.add_causaloid(causaloid);
287287
// Link causaloid D to C
288-
g.add_edge(idx_c, idx_d);
288+
g.add_edge(idx_c, idx_d).expect("Failed to add edge between D to C");
289289

290290
// Add causaloid E
291291
let causaloid = test_utils::get_test_causaloid();
292292
let idx_e = g.add_causaloid(causaloid);
293293
// Link causaloid E to C
294-
g.add_edge(idx_c, idx_e);
294+
g.add_edge(idx_c, idx_e).expect("Failed to add edge between c and e");
295295

296296
g
297297
}

0 commit comments

Comments
 (0)