Exemplo n.º 1
0
void printOverview(FREQUENCY_TABLE *ft){
    if(ft == NULL){
        return;
    }
    
    printOverview(ft->smaller);
    fprintf(stderr, "%d cycle%s with %d vertices.\n",
            ft->frequency, ft->frequency == 1 ? "" : "s", ft->key);
    printOverview(ft->larger);
}
Exemplo n.º 2
0
int main(int argc, char** argv) {
    unsigned long int timeOut = 0;
    
    GRAPH graph;
    ADJACENCY adj;

    /*=========== commandline parsing ===========*/

    int c;
    char *name = argv[0];
    static struct option long_options[] = {
        {"timeout", required_argument, NULL, 't'},
        {"help", no_argument, NULL, 'h'}
    };
    int option_index = 0;

    while ((c = getopt_long(argc, argv, "ht:", long_options, &option_index)) != -1) {
        switch (c) {
            case 't':
                timeOut = strtoul(optarg, NULL, 10);
                break;
            case 'h':
                help(name);
                return EXIT_SUCCESS;
            case '?':
                usage(name);
                return EXIT_FAILURE;
            default:
                fprintf(stderr, "Illegal option %c.\n", c);
                usage(name);
                return EXIT_FAILURE;
        }
    }
    
    //register handlers for signals 
    signal(SIGALRM, handleAlarmSignal);
    signal(SIGINT, handleInterruptSignal);
    
    if(timeOut) {
        fprintf(stderr, "Sending time-out signal in %lu second%s.\n", 
                            timeOut, timeOut == 1 ? "" : "s");
        alarm(timeOut);
    }
    
    unsigned short code[MAXCODELENGTH];
    int length;
    while (!interrupted && readMultiCode(code, &length, stdin)) {
        decodeMultiCode(code, length, graph, adj);
        
        buildOverviewTable(graph, adj);
        
        printOverview(overviewTable);
        
        freeFrequencyTable(overviewTable);
        overviewTable = NULL;
    }

    return (EXIT_SUCCESS);
}
Exemplo n.º 3
0
void printTestsSummary(uint numTests, lineStruct **tests, char *baseFileName) {
    char *summaryFileName, *overviewFileName, *ratioOverviewFileName,*ratioSummaryFileName;
    summaryFileName = (char*) malloc(100 * sizeof(char));
    ratioSummaryFileName = (char*) malloc(100 * sizeof(char));
    ratioOverviewFileName = (char*) malloc(100 * sizeof(char));

    overviewFileName = (char*) malloc(100 * sizeof(char));
    //create the names for the output files
    sprintf(summaryFileName, "Summary%s.csv", baseFileName);
    sprintf(overviewFileName, "Overview%s.csv", baseFileName);
    sprintf(ratioSummaryFileName, "RatioSummary%s.csv", baseFileName);
    sprintf(ratioOverviewFileName, "RatioOverview%s.csv", baseFileName);

    //open and close the output files, this is a simple way to erase their contents
    std::ofstream outFileStream;
    outFileStream.open(summaryFileName);
    outFileStream.close();
    outFileStream.open(overviewFileName);
    outFileStream.close();
    //create sets one containing all of the  (n,k) pairs
    //another containing just the various valeus of n
    std::set<std::pair<uint,uint> > problemSizeKSet;
    std::set<uint> problemSizeSet;
    std::set<std::pair<uint,uint> >::iterator it;
    std::set<uint>::iterator it2;
    uint i;
    //populate the sets
    for(i =0; i < numTests; i++) {
        problemSizeKSet.insert(std::make_pair((tests[i])->size, (tests[i])->k));
        problemSizeSet.insert(tests[i]->size);
    }
    //for each element in the set of (n,k) pairs print out the information for that combination
    for(it = problemSizeKSet.begin(); it != problemSizeKSet.end(); it++) {
        printSizeKCombination((*it).first, (*it).second, tests,numTests, tests[0]->numAlgorithms,summaryFileName);
        printRatios((*it).first, (*it).second, tests,numTests, tests[0]->numAlgorithms,ratioSummaryFileName);
    }
    //for each element in the set of sizes print out the information for that combination
    for(it2 = problemSizeSet.begin(); it2 != problemSizeSet.end(); it2++) {
        printOverview((*it2), tests,numTests, tests[0]->numAlgorithms,overviewFileName);
        printRatioOverview((*it2), tests,numTests, tests[0]->numAlgorithms,ratioOverviewFileName);

    }
}