//你要完成的功能总入口 void search_route(char *topo[5000], int edge_num, char *demand) { graph=CreatGraph(topo,edge_num); AnalysisCondition(demand); pthread_t thread_id; pthread_mutex_init(&lock,NULL); pthread_cond_init(&condition,NULL); pthread_mutex_lock(&lock); struct timespec outtime; struct timeval now; gettimeofday(&now, NULL); outtime.tv_sec = now.tv_sec + 9; //outtime.tv_nsec = now.tv_usec * 1000; pthread_create(&thread_id,NULL,run,NULL); pthread_cond_timedwait(&condition,&lock,&outtime); pthread_mutex_unlock(&lock); pthread_cancel(thread_id); vector<int> *path=solution.GetPath(); if(path->size()){ for(int id:*path) record_result(id); } delete graph; }
/* * === FUNCTION ====================================================================== * Name: main * Description: main function * ===================================================================================== */ int main(int argc, char *argv[]) { VNode G[5]; CreatGraph(5, G); DFS(G,0); printf("\nProgram %s\n\n", argv[0]); return EXIT_SUCCESS; } /* ---------- end of function main ---------- */
/* * === FUNCTION ====================================================================== * Name: main * Description: main function * ===================================================================================== */ int main(int argc, char *argv[]) { int i; VNode G[5]; CreatGraph(5, G); for (i = 0; i < 5; i ++) printf("G[%d].data = %d, (G[%d].firstarc)->adjvex = %d\n", i, G[i].data, i, (G[i].firstarc)->adjvex); //DFS(G,0); BFS(G,0); printf("\nProgram %s\n\n", argv[0]); return EXIT_SUCCESS; } /* ---------- end of function main ---------- */