#include #include #include #include #include #include #include #if defined(__linux__) char *strdup(const char *string); #endif // written by Chris.McDonald@uwa.edu.au // compile with: // cc -std=c11 -Wall -Werror -o buildrandomroutes buildrandomroutes.c #define AUTHOR_EMAIL "Chris.McDonald@uwa.edu.au" #define OPTLIST "l" #define TT_PREFIX "tt-" #define FILENM_ADJACENCY "adjacency" #define MIN_NODES 2 #define MAX_NODES (26*26) #define RANDOM_LAT (-31.9 + (rand() % 40) / 100.0) #define RANDOM_LON (115.8 + (rand() % 40) / 100.0) // JUST A VERY HELPFUL MACRO #define CHECKALLOC(p) do { if((p) == NULL) { \ fprintf(stderr, "allocation failed - %s:%s(), line %d\n",__FILE__,__func__,__LINE__); \ exit(2); } \ } while(false) // --------------------------------------------------------------------- static char *argv0; static int N; #define FOREACH_i for(int i=0 ; i MAX_NODES) { usage(EXIT_FAILURE); } w = new2D(N); adj = new2D(N); srand(getpid()); type0 = rand() % 10; if(lflag) { build_linear_routes(); } else { build_routes(); } build_timetables(TT_PREFIX); print_adjacency(FILENM_ADJACENCY); return EXIT_SUCCESS; } // vim: ts=8 sw=4