#include #include #include "Graph.h" #include "Stack.h" bool enemyAlliance(Graph g) { //TODO return false; } static void runTest(Graph g, const char *name) { printf("Test: %s -> %s\n", name, enemyAlliance(g) ? "TRUE" : "FALSE"); GraphFree(g); } int main(void) { // ------------------------- // Test 1: Direct connection // 0 -- 1 (enemy) // ------------------------- Graph g1 = GraphNew(2); GraphInsertEdge(g1, 0, 1); runTest(g1, "Direct connection"); // ------------------------- // Test 2: Indirect connection // 0 -- 1 -- 2 (enemy) // ------------------------- Graph g2 = GraphNew(3); GraphInsertEdge(g2, 0, 1); GraphInsertEdge(g2, 1, 2); runTest(g2, "Indirect connection"); // ------------------------- // Test 3: No connection // 0 1 -- 2 (enemy) // ------------------------- Graph g3 = GraphNew(3); GraphInsertEdge(g3, 1, 2); runTest(g3, "No connection"); // ------------------------- // Test 4: Disconnected graph // 0 -- 1 2 (enemy) // ------------------------- Graph g4 = GraphNew(3); GraphInsertEdge(g4, 0, 1); runTest(g4, "Disconnected graph"); // ------------------------- // Test 5: Cycle but still connected // 0 -- 1 -- 2 (enemy) // \______/ // ------------------------- Graph g5 = GraphNew(3); GraphInsertEdge(g5, 0, 1); GraphInsertEdge(g5, 1, 2); GraphInsertEdge(g5, 2, 0); runTest(g5, "Cycle graph"); // ------------------------- // Test 6: Larger graph with multiple paths // 0 -- 1 -- 3 (enemy) // \ / // 2 ---- // ------------------------- Graph g6 = GraphNew(4); GraphInsertEdge(g6, 0, 1); GraphInsertEdge(g6, 0, 2); GraphInsertEdge(g6, 1, 3); GraphInsertEdge(g6, 2, 3); runTest(g6, "Multiple paths"); return 0; }