//----------------------------------------------------------------------------- // // GraphClient.c // // This is a fancy test client that calculates the Radius and Diameter of // the graph defined on lines 41-49, along with its Central and Peripheral // vertices. The definitions of these terms at: // // http://en.wikipedia.org/wiki/Distance_(graph_theory) // // Place this file in a directory with copies of your List.c, List.h, Graph.c, // Graph.h and an appropriate Makefile, then compile and run. The output // is contained in the file GraphClientOut. // // This program does not exercise all functions in your Graph ADT, but it // does a pretty good job of testing BFS(). If your output differs from // the above, you have a logical problem in either your Graph or List ADT. // // Remember you are required to submit a file named GraphTest.c with pa4 that // exercises your Graph functions. Do not submit this file. // //----------------------------------------------------------------------------- #include #include #include"Graph.h" int main(int argc, char* argv[]){ int i, s, max, min, d, n=35; List C = newList(); // central vertices List P = newList(); // peripheral vertices List E = newList(); // eccentricities Graph G = NULL; // Build graph G G = newGraph(n); for(i=1; imax ){ max = d; clear(P); append(P, i); } moveNext(E); } // Print results printf("\n"); printf("Radius = %d\n", min); printf("Central vert%s: ", length(C)==1?"ex":"ices"); printList(stdout, C); printf("\n"); printf("Diameter = %d\n", max); printf("Peripheral vert%s: ", length(P)==1?"ex":"ices"); printList(stdout, P); printf("\n"); // Free objects freeList(&C); freeList(&P); freeList(&E); freeGraph(&G); return(0); }