-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphprofile_test.c
More file actions
107 lines (97 loc) · 2.99 KB
/
graphprofile_test.c
File metadata and controls
107 lines (97 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <stdio.h>
#include <stdlib.h>
#include "graphprofile.h"
int main(int argc, char const *argv[]) {
int tc, n, i, j, ans, ret;
int **g;
scanf("%d", &tc);
while(tc--) {
printf("New testcase begin...\n");
scanf("%d", &n);
g = (int**) malloc(n * sizeof(int*));
for (i = 0; i < n; i++) {
g[i] = (int*) malloc(n * sizeof(int));
for (j = 0; j < n; j++) {
scanf("%d", &g[i][j]);
}
}
//AvgDegreeTest
scanf("%d", &ans);
ret = avgDegree(g, n);
if(ret == ans) {
printf("AvgDegreeTest passed.\n");
} else {
printf("AvgDegreeTest ***FAILED***! ");
printf("(Expected: %d, Returned: %d)\n", ans, ret);
}
//IsRegularTest
scanf("%d", &ans);
ret = isRegular(g, n);
if(ret == ans) {
printf("IsRegularTest passed.\n");
} else {
printf("IsRegularTest ***FAILED***! ");
printf("(Expected: %d, Returned: %d)\n", ans, ret);
}
//IsCompleteTest
scanf("%d", &ans);
ret = isComplete(g, n);
if(ret == ans) {
printf("IsCompleteTest passed.\n");
} else {
printf("IsCompleteTest ***FAILED***! ");
printf("(Expected: %d, Returned: %d)\n", ans, ret);
}
//IsCycleTest
scanf("%d", &ans);
ret = isCycleGraph(g, n);
if(ret == ans) {
printf("IsCycleTest passed.\n");
} else {
printf("IsCycleTest ***FAILED***! ");
printf("(Expected: %d, Returned: %d)\n", ans, ret);
}
//IsPathTest
scanf("%d", &ans);
ret = isPathGraph(g, n);
if(ret == ans) {
printf("IsPathTest passed.\n");
} else {
printf("IsPathTest ***FAILED***! ");
printf("(Expected: %d, Returned: %d)\n", ans, ret);
}
//HasEulerCktTest
scanf("%d", &ans);
ret = hasEulerCkt(g, n);
if(ret == ans) {
printf("HasEulerCktTest passed.\n");
} else {
printf("HasEulerCktTest ***FAILED***! ");
printf("(Expected: %d, Returned: %d)\n", ans, ret);
}
//HasEulerPathTest
scanf("%d", &ans);
ret = hasEulerPath(g, n);
if(ret == ans) {
printf("HasEulerPathTest passed.\n");
} else {
printf("HasEulerPathTest ***FAILED***! ");
printf("(Expected: %d, Returned: %d)\n", ans, ret);
}
//OresTheoremTest
scanf("%d", &ans);
ret = satifiesOresTheorem(g, n);
if(ret == ans) {
printf("OresTheoremTest passed.\n");
} else {
printf("OresTheoremTest ***FAILED***! ");
printf("(Expected: %d, Returned: %d)\n", ans, ret);
}
for (i = 0; i < n; i++) {
free(g[i]);
}
free(g);
printf("\n%d testcase left.\n\n", tc);
}
return 0;
}