-
Notifications
You must be signed in to change notification settings - Fork 1
/
GraphTest.c
77 lines (66 loc) · 1.85 KB
/
GraphTest.c
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
/**********************************************************************************
*
* Raj Maitra
* Rmaitra
* Assignment: pa5
*
***********************************************************************************/
#include<stdio.h>
#include"Graph.h"
#include"List.h"
int main(int argc, char* argv[]){
int i;
GraphRef G = newGraph(6);
GraphRef Q;
ListRef L = newList();
/* Test Initialized Access Functions */
printf("---------------Test Initializations:----------------\n");
printf("Order\n");
printf("%d\n", getOrder(G));
printf("Size\n");
printf("%d\n\n", getSize(G));
printf("Source\n");
printf("%d\n\n", getSource(G));
printfGraph(G);
/* Test Insertion Back and Insertion Front */
printf("---------------Test addEdge:----------------\n");
printf("add arc between 1 -> 2\n");
addArc(G, 1, 2);
printf("Size\n");
printf("%d\n\n", getSize(G));
printf("add arc between 1 -> 3\n");
addArc(G, 1, 3);
printf("Size\n");
printf("%d\n\n", getSize(G));
printf("add arc between 2 -> 4\n");
addArc(G, 2, 4);
printf("Size\n");
printf("%d\n\n", getSize(G));
printf("add arc between 2 -> 5\n");
addArc(G, 2, 5);
printf("Size\n");
printf("%d\n\n", getSize(G));
printf("add arc between 4 -> 6\n");
addArc(G, 4, 6);
printf("Size\n");
printf("%d\n\n", getSize(G));
printfGraph(G);
/* Test DFS */
printf("------------------Test DFS:-----------------------\n");
for(i=1;i<=getOrder(G);i++){
insertBack(L, i);
}
DFS(G, L);
printflist(L);
/* Test Transpose */
printf("------------------Test Transpose:-----------------------\n");
Q = transpose(G);
printfGraph(Q);
/* Test Copy */
printf("------------------Test Copy:-----------------------\n");
Q = copyGraph(G);
printfGraph(Q);
freeList(&L);
freeGraph(&G);
return(0);
}