MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_QueryGraphConnectedComponents

Function test_QueryGraphConnectedComponents

tests/unit/test_query_graph.c:287–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287void test_QueryGraphConnectedComponents() {
288 QueryGraph *g;
289 QueryGraph **connected_components;
290
291 //--------------------------------------------------------------------------
292 // single node graph
293 //--------------------------------------------------------------------------
294 g = SingleNodeGraph();
295 connected_components = QueryGraph_ConnectedComponents(g);
296
297 TEST_ASSERT(array_len(connected_components) == 1);
298
299 // Clean up.
300 QueryGraph_Free(g);
301 for(int i = 0; i < array_len(connected_components); i++) {
302 QueryGraph_Free(connected_components[i]);
303 }
304 array_free(connected_components);
305
306 //--------------------------------------------------------------------------
307 // triangle graph
308 //--------------------------------------------------------------------------
309
310 g = TriangleGraph();
311 connected_components = QueryGraph_ConnectedComponents(g);
312
313 TEST_ASSERT(array_len(connected_components) == 1);
314
315 // clean up
316 QueryGraph_Free(g);
317 for(int i = 0; i < array_len(connected_components); i++) {
318 QueryGraph_Free(connected_components[i]);
319 }
320 array_free(connected_components);
321
322 //--------------------------------------------------------------------------
323 // disjoint graph
324 //--------------------------------------------------------------------------
325
326 g = DisjointGraph();
327 connected_components = QueryGraph_ConnectedComponents(g);
328
329 TEST_ASSERT(array_len(connected_components) == 2);
330
331 // clean up
332 QueryGraph_Free(g);
333 for(int i = 0; i < array_len(connected_components); i++) {
334 QueryGraph_Free(connected_components[i]);
335 }
336 array_free(connected_components);
337
338 //--------------------------------------------------------------------------
339 // single node cycle graph
340 //--------------------------------------------------------------------------
341
342 g = SingleNodeCycleGraph();
343 connected_components = QueryGraph_ConnectedComponents(g);
344

Callers

nothing calls this directly

Calls 8

SingleNodeGraphFunction · 0.85
array_lenFunction · 0.85
QueryGraph_FreeFunction · 0.85
array_freeFunction · 0.85
TriangleGraphFunction · 0.85
DisjointGraphFunction · 0.85
SingleNodeCycleGraphFunction · 0.85

Tested by

no test coverage detected