コード例 #1
0
ファイル: disambiguation.c プロジェクト: dtaht/rabeld
static const struct babel_route *
min_conflict(const struct zone *zone, const struct babel_route *rt)
{
    struct babel_route *rt1 = NULL;
    const struct babel_route *min = NULL;
    struct route_stream *stream = NULL;
    struct zone curr_zone;
    stream = route_stream(ROUTE_INSTALLED);
    if(!stream) {
        fprintf(stderr, "Couldn't allocate route stream.\n");
        return NULL;
    }
    while(1) {
        rt1 = route_stream_next(stream);
        if(rt1 == NULL) break;
        __builtin_prefetch(rt1->src,0,1);
        __builtin_prefetch(rt->src,0,1);

        if(!(conflicts(rt, rt1) &&
             zone_equal(inter(rt, rt1, &curr_zone), zone)))
             continue;
        min = min_route(rt1, min);
    }
    route_stream_done(stream);
    return min;
}
コード例 #2
0
ファイル: main.c プロジェクト: harryna/bridgeECTna
int main()
{
    int c,ectnum;
    nlist[MAX_NODES+1].nid=0;
    system("clear");

    //scanfile();
    printf("\nSucessfully Scanned the graph.\n");
    //djkstra();
    for(;;)
    {
        view();

        printf("\n1.Rescan file.");
        printf("\n2.View minimum route between nodes with ECT 1-16.");
        printf("\n3.Exit.");
        printf("\nEnter:");
        scanf("%d",&c);
        switch(c)
        {
        case 1:
        {
            scanfile();
            djkstra();
            system("clear");
            break;
        }
        case 2:
        {
            for(ectnum=0; ectnum<17; ectnum++) {
                printf("ECT%d-%2X\n",ectnum,ECT[ectnum]);
                scanfile(ectnum);
                sort();
                djkstra();
                view();
                min_route(ectnum);
                //if(ectnum==10)
                //break;
            }
            system("clear");
            break;
        }
        case 3:
        {
            exit(0);
        }
        default:
        {
            printf("\nEnter proper choice.\n");
            break;
        }
        }
    }
    return (EXIT_SUCCESS);
}
コード例 #3
0
ファイル: disambiguation.c プロジェクト: dtaht/rabeld
static const struct babel_route *
conflict_solution(const struct babel_route *rt)
{
    const struct babel_route *rt1 = NULL, *rt2 = NULL;
    struct route_stream *stream1 = NULL;
    struct route_stream *stream2 = NULL;
    const struct babel_route *min = NULL; /* == solution */
    struct zone zone;
    struct zone tmp;
    /* Having a conflict requires at least one specific route. */
    stream1 = route_stream(ROUTE_SS_INSTALLED);
    if(!stream1) {
        return NULL;
    }
    while(1) {
        rt1 = route_stream_next(stream1);
        if(rt1 == NULL) break;

        stream2 = route_stream(ROUTE_INSTALLED);
        if(!stream2) {
            route_stream_done(stream1);
            fprintf(stderr, "Couldn't allocate route stream.\n");
            return NULL;
        }

        while(1) {
            rt2 = route_stream_next(stream2);
            if(rt2 == NULL) break;
            if(!(conflicts(rt1, rt2) &&
                 zone_equal(inter(rt1, rt2, &tmp), to_zone(rt, &zone)) &&
                 rt_cmp(rt1, rt2) < 0))
                continue;
            min = min_route(rt1, min);
        }
        route_stream_done(stream2);
    }
    route_stream_done(stream1);
    return min;
}