-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphClient.c
73 lines (63 loc) · 1.61 KB
/
GraphClient.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
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
//-----------------------------------------------------------------------------
// GraphClient.c
// Test client for the Graph ADT
//-----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include"List.h"
#include"Graph.h"
int main(int argc, char* argv[]){
int i, n=8;
List S = newList();
Graph G = newGraph(n);
Graph T=NULL, C=NULL;
for(i=1; i<=n; i++) append(S, i);
addArc(G, 1,2);
addArc(G, 1,5);
addArc(G, 2,5);
addArc(G, 2,6);
addArc(G, 3,2);
addArc(G, 3,4);
addArc(G, 3,6);
addArc(G, 3,7);
addArc(G, 3,8);
addArc(G, 6,5);
addArc(G, 6,7);
addArc(G, 8,4);
addArc(G, 8,7);
printGraph(stdout, G);
DFS(G, S);
fprintf(stdout, "\n");
fprintf(stdout, "x: d f p\n");
for(i=1; i<=n; i++){
fprintf(stdout, "%d: %2d %2d %2d\n", i, getDiscover(G, i), getFinish(G, i), getParent(G, i));
}
fprintf(stdout, "\n");
printList(stdout, S);
fprintf(stdout, "\n");
T = transpose(G);
C = copyGraph(G);
fprintf(stdout, "\n");
printGraph(stdout, C);
fprintf(stdout, "\n");
printGraph(stdout, T);
fprintf(stdout, "\n");
DFS(T, S);
fprintf(stdout, "\n");
fprintf(stdout, "x: d f p\n");
for(i=1; i<=n; i++){
fprintf(stdout, "%d: %2d %2d %2d\n", i, getDiscover(T, i), getFinish(T, i), getParent(T, i));
}
fprintf(stdout, "\n");
printList(stdout, S);
fprintf(stdout, "\n");
freeList(&S);
freeGraph(&G);
freeGraph(&T);
freeGraph(&C);
return(0);
}