/*terminate the processor so cancel it*/ void ProcessorHandler( int _numSig) { /*need destroy everything... item struct in both Hash */ DataBaseDestroy( GetPtrDataBaseObi()); DataBaseDestroy( GetPtrDataBaseSbi()); GraphDestroy(GetPtrGraph()); if (0 != pthread_cancel( GetProcThreadID() ) ) { return; } if (0 != pthread_kill( GetProcThreadID(), SIGINT)) { return; } }
int main(void){ ALGraph graph; GraphInit(&graph, 5); AddEdge(&graph, A, B); AddEdge(&graph, A, D); AddEdge(&graph, B, C); AddEdge(&graph, C, D); AddEdge(&graph, D, E); AddEdge(&graph, E, A); ShowGraphEdgeInfo(&graph); GraphDestroy(&graph); return 0; }
int main(int argc, char **argv) { graphT graph = ReadFileAndBuildGraph(argv[1]); n = GraphNumVertices(graph); float avg; int max; findAvgPathLengthNetworkDiameter(graph, &avg, &max); const char *outputFile = argv[2]; FILE *out = fopen(outputFile, "w"); if (out == NULL) { fprintf(stderr, "Couldn't open output file %s!\n", outputFile); exit(1); } fprintf(out, "Graph: %s\n Average Shortest Path: %f Network Diameter: %d\n", argv[1], avg, max); fclose(out); GraphDestroy(graph); return 0; }
bool graph_test_create(){ logInfo("graph_test_create..."); Graph *graph = NULL; CreateTestGraph1(&graph); if(GraphIsDestroyed(graph)){ logError("fail - CreateTestGraph1() returned null."); return false; } logDebug(GraphToString(graph)); GraphDestroy(&graph); if(!GraphIsDestroyed(graph)){ logError("fail - GraphIsDestroyed() was not successful."); return false; } logInfo("success."); return true; }