43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
#include "c_BipartiteBFS.h"
|
|||
|
|
#include "c_Test.h"
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
TEST_CASE(test_c_bipartite_bfs_engine) {
|
||
|
|
// Graph configuration containing an odd cycle (Pentagon shape: 5 elements)
|
||
|
|
c_Graph_t g_odd;
|
||
|
|
c_Graph_Init(&g_odd, 5, 0);
|
||
|
|
c_Graph_AddEdge(&g_odd, 0, 1);
|
||
|
|
c_Graph_AddEdge(&g_odd, 1, 2);
|
||
|
|
c_Graph_AddEdge(&g_odd, 2, 3);
|
||
|
|
c_Graph_AddEdge(&g_odd, 3, 4);
|
||
|
|
c_Graph_AddEdge(&g_odd, 4, 0); // odd loop boundary closure
|
||
|
|
|
||
|
|
c_BipartiteBFS_t search;
|
||
|
|
c_err_t err = c_BipartiteBFS_Init(&search, &g_odd, 0);
|
||
|
|
|
||
|
|
ASSERT_INT_EQ(C_SUCCESS, err);
|
||
|
|
ASSERT_FALSE(c_BipartiteBFS_IsBipartite(&search)); // Must identify non-bipartite structural properties
|
||
|
|
|
||
|
|
// Verify shortest odd cycle path extraction
|
||
|
|
const c_VertexIdList_t* loop_cycle = c_BipartiteBFS_Cycle(&search);
|
||
|
|
ASSERT_PTR_NOT_NULL(loop_cycle);
|
||
|
|
ASSERT_TRUE(loop_cycle->size == 6); // A closed 5-vertex loop cycle holds 6 routing entries
|
||
|
|
|
||
|
|
c_BipartiteBFS_Destroy(&search);
|
||
|
|
c_Graph_Destroy(&g_odd);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
int main(int argc, char** argv){
|
||
|
|
|
||
|
|
TEST_START(Component Tests);
|
||
|
|
|
||
|
|
// Execution list configurations
|
||
|
|
RUN_TEST(test_c_bipartite_bfs_engine);
|
||
|
|
|
||
|
|
TEST_REPORT();
|
||
|
|
|
||
|
|
RETURN_TEST_STATUS;
|
||
|
|
}
|